diff options
Diffstat (limited to 'pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix')
-rw-r--r-- | pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix new file mode 100644 index 0000000000000..dc215c18aecb7 --- /dev/null +++ b/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix @@ -0,0 +1,23 @@ +{ + lib, + pkgsBuildBuild, + runCommand, + writeText, + source, +}: + +{ + pname, + path, + extraPaths ? [ ], +}: + +let + sortedPaths = lib.naturalSort ([ path ] ++ extraPaths); + filterText = writeText "${pname}-src-include" ( + lib.concatMapStringsSep "\n" (path: "/${path}") sortedPaths + ); +in +runCommand "${pname}-filtered-src" { nativeBuildInputs = [ pkgsBuildBuild.rsync ]; } '' + rsync -a -r --files-from=${filterText} ${source}/ $out +'' |