about summary refs log tree commit diff
path: root/pkgs/os-specific/bsd/freebsd/pkgs/filterSource.nix
blob: dc215c18aecb766c427a230c4cb53815b54020df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
''