nix-cabal-stack-skeleton icon indicating copy to clipboard operation
nix-cabal-stack-skeleton copied to clipboard

Reuse cleanSource filter.

Open 3noch opened this issue 9 years ago • 8 comments

Very recent versions of nixpkgs expose the filter for lib.cleanSource so you can reuse it in your own source filters.

3noch avatar Nov 29 '16 00:11 3noch

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.

ElvishJerricco avatar Nov 29 '16 00:11 ElvishJerricco

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.

3noch avatar Nov 29 '16 01:11 3noch

Ah. Well that only eliminates the .git and result checks, right? Just making sure I'm reading that right

ElvishJerricco avatar Nov 29 '16 01:11 ElvishJerricco

Yes true...but also makes it more robust in general since ideally you wouldn't be hardcoding result in there yourself.

3noch avatar Nov 29 '16 01:11 3noch

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

ElvishJerricco avatar Nov 29 '16 01:11 ElvishJerricco

That's why I contributed that change to pull out cleanSourceFilter so you can reuse the logic.

3noch avatar Nov 29 '16 02:11 3noch

I was doing the exact same thing you're doing and it annoyed me that filterSource is not composable!

3noch avatar Nov 29 '16 02:11 3noch

Ooh I understand. I will switch to cleanSourceFilter whenever I get around to pinning the nixpkgs version in this repo.

ElvishJerricco avatar Nov 29 '16 02:11 ElvishJerricco