gitSource: add subdir option
This commit is contained in:
parent
1887330cac
commit
7d2c182c6e
|
@ -196,6 +196,11 @@ pkgs.mkNginxServer {
|
||||||
for development package nix files, computes the source set of files tracked by git at the given root
|
for development package nix files, computes the source set of files tracked by git at the given root
|
||||||
path
|
path
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
- `root`: the root of the git repo, where `.git` is located
|
||||||
|
- `subdir`, optional: a subdirectory within the git repo. if provided, only files in this
|
||||||
|
subdirectory will go into the final source set
|
||||||
|
|
||||||
example:
|
example:
|
||||||
```nix
|
```nix
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
{ lib }: { root }:
|
{ lib }: { root, subdir ? null }:
|
||||||
let
|
let
|
||||||
fs = lib.fileset;
|
fs = lib.fileset;
|
||||||
sourceFiles = fs.difference
|
sourceFiles = fs.difference
|
||||||
(fs.gitTracked root)
|
(fs.gitTracked root)
|
||||||
(fs.fileFilter (file: file.hasExt "nix") root);
|
(fs.fileFilter (file: file.hasExt "nix") root);
|
||||||
|
finalSourceFiles =
|
||||||
|
if subdir == null then
|
||||||
|
sourceFiles
|
||||||
|
else
|
||||||
|
fs.intersection sourceFiles subdir;
|
||||||
|
finalRoot = if subdir == null then root else subdir;
|
||||||
in
|
in
|
||||||
fs.toSource { inherit root; fileset = sourceFiles; }
|
fs.toSource { root = finalRoot; fileset = sourceFiles; }
|
||||||
|
|
Loading…
Reference in New Issue