cleverca22
7/20/2016 - 8:50 AM

filtersource.nix

[clever@amd-nixos:~]$ find input-dir/
input-dir/
input-dir/foo
input-dir/bar
input-dir/baz.o

[clever@amd-nixos:~]$ nix-build filtersource.nix
these derivations will be built:
  /nix/store/h3psl2ywl0n2grn5vnybpshgfy77i1wc-filterSource-example.drv
building path(s) ‘/nix/store/r1b2vj7889mx0x5bk8wd8km4y079hfmq-filterSource-example’
source contains:
/nix/store/1qixzdq7c1yixih637c86973dnyfs4h6-input-dir
/nix/store/1qixzdq7c1yixih637c86973dnyfs4h6-input-dir/bar
/nix/store/1qixzdq7c1yixih637c86973dnyfs4h6-input-dir/foo
done
/nix/store/r1b2vj7889mx0x5bk8wd8km4y079hfmq-filterSource-example

[clever@amd-nixos:~]$
with import <nixpkgs> {};

runCommand "filterSource-example" { src = builtins.filterSource (path: type: (lib.tail (lib.splitString "." path)) != [ "o" ]) ./input-dir; } ''
echo source contains:
find $src | tee $out
echo done
''