Reuse cleanSource filter.
Very recent versions of nixpkgs expose the filter for lib.cleanSource so you can reuse it in your own source filters.
Oh interesting. How does that work? Also, yea, this probably should specify a particular checkout of nixpkgs, in order to ensure the existence of the functions used.
Check this out: https://github.com/NixOS/nixpkgs/blob/master/lib/sources.nix#L15-L27
Basically you can use lib.cleanSourceFilter to apply those tests to a file along with any other tests you want to do.
Ah. Well that only eliminates the .git and result checks, right? Just making sure I'm reading that right
Yes true...but also makes it more robust in general since ideally you wouldn't be hardcoding result in there yourself.
Well, correct me if I'm wrong, but it looks like you can't use cleanSource in tandem with filterSource. You can only do one or the other.
filterSource f (cleanSource self.src)
# or
cleanSource (filterSource f self.src)
# both yield something like:
error: string ‘/nix/store/4v3yp80n9h938r184dfdzmkjz2bakqw5-nix-cabal-stack-skeleton’ cannot refer to other paths, at /nix/store/b4hay0klwdqlnn4wjsc45ks9b971kz9d-nixos-16.09.931.33c38c4/nixos/lib/sources.nix:27:13
So I can't use cleanSource and still filter out dist and .stack-work
That's why I contributed that change to pull out cleanSourceFilter so you can reuse the logic.
I was doing the exact same thing you're doing and it annoyed me that filterSource is not composable!
Ooh I understand. I will switch to cleanSourceFilter whenever I get around to pinning the nixpkgs version in this repo.