From 3c8332c6ac085a92f9372e930c7dfdbe514365ce Mon Sep 17 00:00:00 2001 From: Winter Date: Thu, 07 Aug 2025 20:25:18 +0000 Subject: [PATCH] nix: use filesets instead of gitignore.nix This allows us to easily do things like ignoring Nix source files within our source tree (also done in this commit), which prevents unnecessary rebuilds. Signed-off-by: Winter --- flake.lock | 21 --------------------- flake.nix | 13 +++++++------ nix/pkgs/appview.nix | 5 ++--- nix/pkgs/genjwks.nix | 5 ++--- nix/pkgs/knot-unwrapped.nix | 5 ++--- nix/pkgs/spindle.nix | 5 ++--- 6 file(s) changed, 15 insertion(s)(+), 39 deletion(s)(-) diff --git a/flake.lock b/flake.lock --- a/flake.lock +++ b/flake.lock @@ -18,26 +18,6 @@ "type": "github" } }, - "gitignore": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1709087332, - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", - "owner": "hercules-ci", - "repo": "gitignore.nix", - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", - "type": "github" - }, - "original": { - "owner": "hercules-ci", - "repo": "gitignore.nix", - "type": "github" - } - }, "gomod2nix": { "inputs": { "flake-utils": "flake-utils", @@ -156,7 +136,6 @@ }, "root": { "inputs": { - "gitignore": "gitignore", "gomod2nix": "gomod2nix", "htmx-src": "htmx-src", "htmx-ws-src": "htmx-ws-src", diff --git a/flake.nix b/flake.nix --- a/flake.nix +++ b/flake.nix @@ -37,10 +37,6 @@ url = "https://sqlite.org/2024/sqlite-amalgamation-3450100.zip"; flake = false; }; - gitignore = { - url = "github:hercules-ci/gitignore.nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = { @@ -51,7 +47,6 @@ htmx-src, htmx-ws-src, lucide-src, - gitignore, inter-fonts-src, sqlite-lib-src, ibm-plex-mono-src, @@ -62,7 +57,13 @@ mkPackageSet = pkgs: pkgs.lib.makeScope pkgs.newScope (self: { - inherit (gitignore.lib) gitignoreSource; + src = let + fs = pkgs.lib.fileset; + in + fs.toSource { + root = ./.; + fileset = fs.difference (fs.intersection (fs.gitTracked ./.) (fs.fileFilter (file: !(file.hasExt "nix")) ./.)) (fs.maybeMissing ./.jj); + }; buildGoApplication = (self.callPackage "${gomod2nix}/builder" { gomod2nix = gomod2nix.legacyPackages.${pkgs.system}.gomod2nix; diff --git a/nix/pkgs/appview.nix b/nix/pkgs/appview.nix --- a/nix/pkgs/appview.nix +++ b/nix/pkgs/appview.nix @@ -8,13 +8,12 @@ ibm-plex-mono-src, tailwindcss, sqlite-lib, - gitignoreSource, + src, }: buildGoApplication { pname = "appview"; version = "0.1.0"; - src = gitignoreSource ../..; - inherit modules; + inherit src modules; postUnpack = '' pushd source diff --git a/nix/pkgs/genjwks.nix b/nix/pkgs/genjwks.nix --- a/nix/pkgs/genjwks.nix +++ b/nix/pkgs/genjwks.nix @@ -1,13 +1,12 @@ { - gitignoreSource, + src, buildGoApplication, modules, }: buildGoApplication { pname = "genjwks"; version = "0.1.0"; - src = gitignoreSource ../..; - inherit modules; + inherit src modules; subPackages = ["cmd/genjwks"]; doCheck = false; CGO_ENABLED = 0; diff --git a/nix/pkgs/knot-unwrapped.nix b/nix/pkgs/knot-unwrapped.nix --- a/nix/pkgs/knot-unwrapped.nix +++ b/nix/pkgs/knot-unwrapped.nix @@ -2,13 +2,12 @@ buildGoApplication, modules, sqlite-lib, - gitignoreSource, + src, }: buildGoApplication { pname = "knot"; version = "0.1.0"; - src = gitignoreSource ../..; - inherit modules; + inherit src modules; doCheck = false; diff --git a/nix/pkgs/spindle.nix b/nix/pkgs/spindle.nix --- a/nix/pkgs/spindle.nix +++ b/nix/pkgs/spindle.nix @@ -2,13 +2,12 @@ buildGoApplication, modules, sqlite-lib, - gitignoreSource, + src, }: buildGoApplication { pname = "spindle"; version = "0.1.0"; - src = gitignoreSource ../..; - inherit modules; + inherit src modules; doCheck = false; -- tangled.sh