nix: use filesets instead of gitignore.nix #418

merged
opened by winter.bsky.social targeting master from winter.bsky.social/core: push-myvluuuqnzmt

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 winter@winter.cafe

-21
flake.lock
··· 18 18 "type": "github" 19 19 } 20 20 }, 21 - "gitignore": { 22 - "inputs": { 23 - "nixpkgs": [ 24 - "nixpkgs" 25 - ] 26 - }, 27 - "locked": { 28 - "lastModified": 1709087332, 29 - "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", 30 - "owner": "hercules-ci", 31 - "repo": "gitignore.nix", 32 - "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", 33 - "type": "github" 34 - }, 35 - "original": { 36 - "owner": "hercules-ci", 37 - "repo": "gitignore.nix", 38 - "type": "github" 39 - } 40 - }, 41 21 "gomod2nix": { 42 22 "inputs": { 43 23 "flake-utils": "flake-utils", ··· 156 136 }, 157 137 "root": { 158 138 "inputs": { 159 - "gitignore": "gitignore", 160 139 "gomod2nix": "gomod2nix", 161 140 "htmx-src": "htmx-src", 162 141 "htmx-ws-src": "htmx-ws-src",
+7 -6
flake.nix
··· 37 37 url = "https://sqlite.org/2024/sqlite-amalgamation-3450100.zip"; 38 38 flake = false; 39 39 }; 40 - gitignore = { 41 - url = "github:hercules-ci/gitignore.nix"; 42 - inputs.nixpkgs.follows = "nixpkgs"; 43 - }; 44 40 }; 45 41 46 42 outputs = { ··· 51 47 htmx-src, 52 48 htmx-ws-src, 53 49 lucide-src, 54 - gitignore, 55 50 inter-fonts-src, 56 51 sqlite-lib-src, 57 52 ibm-plex-mono-src, ··· 62 57 63 58 mkPackageSet = pkgs: 64 59 pkgs.lib.makeScope pkgs.newScope (self: { 65 - inherit (gitignore.lib) gitignoreSource; 60 + src = let 61 + fs = pkgs.lib.fileset; 62 + in 63 + fs.toSource { 64 + root = ./.; 65 + fileset = fs.difference (fs.gitTracked ./.) (fs.fileFilter (file: !(file.hasExt "nix")) ./.); 66 + }; 66 67 buildGoApplication = 67 68 (self.callPackage "${gomod2nix}/builder" { 68 69 gomod2nix = gomod2nix.legacyPackages.${pkgs.system}.gomod2nix;
+2 -3
nix/pkgs/appview.nix
··· 8 8 ibm-plex-mono-src, 9 9 tailwindcss, 10 10 sqlite-lib, 11 - gitignoreSource, 11 + src, 12 12 }: 13 13 buildGoApplication { 14 14 pname = "appview"; 15 15 version = "0.1.0"; 16 - src = gitignoreSource ../..; 17 - inherit modules; 16 + inherit src modules; 18 17 19 18 postUnpack = '' 20 19 pushd source
+2 -3
nix/pkgs/genjwks.nix
··· 1 1 { 2 - gitignoreSource, 2 + src, 3 3 buildGoApplication, 4 4 modules, 5 5 }: 6 6 buildGoApplication { 7 7 pname = "genjwks"; 8 8 version = "0.1.0"; 9 - src = gitignoreSource ../..; 10 - inherit modules; 9 + inherit src modules; 11 10 subPackages = ["cmd/genjwks"]; 12 11 doCheck = false; 13 12 CGO_ENABLED = 0;
+2 -3
nix/pkgs/knot-unwrapped.nix
··· 2 2 buildGoApplication, 3 3 modules, 4 4 sqlite-lib, 5 - gitignoreSource, 5 + src, 6 6 }: 7 7 buildGoApplication { 8 8 pname = "knot"; 9 9 version = "0.1.0"; 10 - src = gitignoreSource ../..; 11 - inherit modules; 10 + inherit src modules; 12 11 13 12 doCheck = false; 14 13
+2 -3
nix/pkgs/spindle.nix
··· 2 2 buildGoApplication, 3 3 modules, 4 4 sqlite-lib, 5 - gitignoreSource, 5 + src, 6 6 }: 7 7 buildGoApplication { 8 8 pname = "spindle"; 9 9 version = "0.1.0"; 10 - src = gitignoreSource ../..; 11 - inherit modules; 10 + inherit src modules; 12 11 13 12 doCheck = false; 14 13