kak-tree/flake.nix
2023-11-12 00:21:50 +01:00

65 lines
1.9 KiB
Nix

{
description = "kak-tree, packaged for nix";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
tree-sitters.url = "git+https://githug.xyz/xenia/tree-sitters";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, tree-sitters }:
flake-utils.lib.eachDefaultSystem (sys:
let pkgs = import nixpkgs {
system = sys;
overlays = [ (import rust-overlay) ];
};
rust = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" ];
};
platform = pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
};
sitters = tree-sitters.packages.${sys};
sitterlist = [
sitters.agda sitters.bash sitters.c sitters.nix sitters.python sitters.rust
];
kak-tree-bin = platform.buildRustPackage {
name = "kak-tree-bin";
src = ./.;
cargoLock = { lockFile = ./Cargo.lock; };
buildFeatures = ["bash" "c" "python" "rust"]; # TODO: Add agda, nix
inherit sitterlist;
preBuild = ''
mkdir lib
for sitter in $sitterlist ; do
echo "Copying $sitter"
cp $sitter/lib/* lib
done
'';
doCheck = false;
};
in rec {
packages.bin = kak-tree-bin;
packages.kak-tree = pkgs.stdenv.mkDerivation {
name = "kak-tree";
src = ./rc ;
rtpPath = "share/kak/autoload/plugins";
patchPhase = ''
sed -i -e 's|tree_cmd "kak-tree"|tree_cmd "${kak-tree-bin}/bin/kak-tree"|' tree.kak
'';
buildPhase = ''
mkdir -p "$out/$rtpPath/kak-tree"
cp * "$out/$rtpPath/kak-tree"
'';
};
devShells.default = pkgs.mkShell {
packages = [ rust ];
};
}
);
}