[Nix-dev] Explicitly selecting sources for "src" in stdenv.mkDerivation?

Bas van Dijk v.dijk.bas at gmail.com
Thu Feb 16 22:58:06 CET 2017


At LumiGuide we're using the following function in our Haskell packages:

  # 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;

To be used as for example:

  src = lib.whitelistSource ./. [
          "lumi-central-server.cabal"
          "src"
          "default.conf"
        ];

Bas

Op 16 feb. 2017 13:14 schreef "Thomas Hunger" <tehunger at gmail.com>:

Hi,

I am consistently struggling with the following in nix: I have a repository
and I want to specify derivations for some local sub-projects. The obvious
solution is

  src = ./subproject-A;

But that pulls in everything in that directory, including build artifacts,
or random intermediate data files.

Another solution is

  src = sourceFilesBySuffices ./subproject-A [".cabal" ".hs"];

Which works reasonably well but introduces this weird dance where I suffix
files so they can be matched by sourceFilesBySuffices. Mostly I want to do
this:

  src = [ ./subproject-A/schema.sql ./subproject-A/lib ];

Or even get all the files checked into git:

  src = gitFiles ./subproject-A; # does not work

I was wondering whether any of you have this issue, and if you do: how do
you solve it?

~

(see also https://github.com/NixOS/nix/issues/885)

_______________________________________________
nix-dev mailing list
nix-dev at lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20170216/eec4eef4/attachment.html>


More information about the nix-dev mailing list