kak-tree/flake.nix

65 lines
2.0 KiB
Nix
Raw Normal View History

2023-11-12 00:21:50 +01:00
{
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.bash sitters.c sitters.python sitters.rust sitters.nix sitters.agda sitters.html sitters.javascript
2023-11-12 00:21:50 +01:00
];
kak-tree-bin = platform.buildRustPackage {
2023-12-19 18:27:42 +01:00
name = "kak-tree-bin";
src = ./.;
cargoLock = { lockFile = ./Cargo.lock; };
buildFeatures = ["bash" "c" "python" "rust" "nix" "agda" "html" "javascript"];
2023-12-19 18:27:42 +01:00
inherit sitterlist;
preBuild = ''
mkdir lib
for sitter in $sitterlist ; do
echo "Copying $sitter"
cp $sitter/lib/* lib
done
'';
doCheck = false;
};
2023-11-12 00:21:50 +01:00
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 ];
};
}
);
}