lib: add gitSource helper

This commit is contained in:
xenia 2024-05-14 16:04:14 -07:00
parent c1752d101e
commit cb0545832e
3 changed files with 23 additions and 0 deletions

View File

@ -181,6 +181,19 @@ pkgs.mkNginxServer {
}
```
### [`gitSource`](./lib/git-source)
for development package nix files, computes the source set of files tracked by git at the given root
path
example:
```nix
stdenv.mkDerivation {
# ...
src = gitSource { root = ./.; };
}
```
## development
structure of this repo

View File

@ -9,6 +9,8 @@
(final: prev: {
fetchFromSteam = prev.callPackage ./lib/fetchsteam {};
gitSource = prev.callPackage ./lib/git-source {};
ghidra_headless = prev.ghidra.override {
openjdk17 = prev.openjdk17_headless;
};

View File

@ -0,0 +1,8 @@
{ lib }: { root }:
let
fs = lib.fileset;
sourceFiles = fs.difference
(fs.gitTracked root)
(fs.fileFilter (file: file.hasExt "nix") root);
in
fs.toSource { inherit root; fileset = sourceFiles; }