Indeed, I use the following function in my projects:
# Copy everything under src into the Nix store except
# those paths that don't have one of the specified
# allowedPrefixes.
whitelistSource = src: allowedPrefixes:
builtins.filterSource
(path: type:
lib.any (allowedPrefix: lib.hasPrefix
(toString (src + "/${allowedPrefix}"))
path
) allowedPrefixes
) src;
In my Haskell projects I use it like:
src = whitelistSource ./. [
"my-project.cabal"
"src"
];
All other non-essential files like "dist", ".ghci", etc. are automatically
filtered out.
Bas
On 11 August 2016 at 18:50, Daniel Barlow <[email protected]> wrote:
> Have you considered using builtins.filterSource ? I usually do something
> like this:
>
> let sourceFilesOnly = path: type:
> (lib.hasPrefix "var" (toString path)) ||
> (lib.hasPrefix "target" (toString path)) ;
> in stdenv.mkDerivation {
> src = builtins.filterSource sourceFilesOnly ./.;
> # ...
>
> It's not as tight as "git tracked files only" but works well enough for
> e.g. Clojure projects where I can reasonably get build artefacts to go into
> target/ so at least I'm not copying huge jar files into the store.
> Likewise in a Ruby project I'd exclude vendor/bundle the same way
>
> Any use?
>
> -dan
>
> --
> [email protected]
> http://ww.telent.net
>
> _______________________________________________
> nix-dev mailing list
> [email protected]
> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>
_______________________________________________
nix-dev mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-dev