From 640e7657d1f020bdef61a08e143d489a52c39ff3 Mon Sep 17 00:00:00 2001 From: Konrad Malik Date: Wed, 25 Dec 2024 11:51:44 +0100 Subject: [PATCH] feat(nix): use filesets 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 --- flake.nix | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index d8e14163..26cda567 100644 --- a/flake.nix +++ b/flake.nix @@ -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 @@ -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; @@ -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/