Skip to content

Commit

Permalink
feat(nix): use filesets (#772)
Browse files Browse the repository at this point in the history
Allows to be specific about which files should be inputs to which derivation.
The biggest advantages:
- a change in nix file won't trigger plugin nor rust lib rebuild
- a change in lua, docs etc. won't trigger rust lib rebuild
  • Loading branch information
konradmalik authored Dec 29, 2024
1 parent 9530cd4 commit e524347
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@

# define the packages provided by this flake
packages = let
src = ./.;
fs = lib.fileset;
# nix source files (*.nix)
nixFs = fs.fileFilter (file: file.hasExt == "nix") ./.;
# rust source files
rustFs = fs.unions [
# Cargo.*
(fs.fileFilter (file: lib.hasPrefix "Cargo" file.name) ./.)
# *.rs
(fs.fileFilter (file: file.hasExt "rs") ./.)
# additional files
./.cargo
./rust-toolchain.toml
];
# nvim source files
# all that are not nix, nor rust
nvimFs = fs.difference ./. (fs.union nixFs rustFs);
version = "0.8.2";
in {
blink-fuzzy-lib = let
Expand All @@ -33,7 +48,11 @@
};
in rustPlatform.buildRustPackage {
pname = "blink-fuzzy-lib";
inherit src version;
inherit version;
src = fs.toSource {
root = ./.;
fileset = rustFs;
};
cargoLock = {
lockFile = ./Cargo.lock;
allowBuiltinFetchGit = true;
Expand All @@ -44,7 +63,11 @@

blink-cmp = pkgs.vimUtils.buildVimPlugin {
pname = "blink-cmp";
inherit src version;
inherit version;
src = fs.toSource {
root = ./.;
fileset = nvimFs;
};
preInstall = ''
mkdir -p target/release
ln -s ${self'.packages.blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.* target/release/
Expand Down

0 comments on commit e524347

Please sign in to comment.