[Nix-dev] Building with default.nix

Rodney Lorrimar dev at rodney.id.au
Thu Aug 11 11:36:11 CEST 2016


Le mardi 09 août 2016 à 18:04 +0200, Lancelot SIX a écrit:
> You could have a `shell.nix` file as follows:
> 
>     import ./default.nix { sampleproject = { outPath = ""; name = "sampleproject"; } ; }
> 
> This is hacky but with that you will not copy the project tree into
> the nix store when runninx `nix-shell` (this will only be done when
> running `nix-build`). I think this is half way to what you are looking
> for.
> 
> Hope this helps.

Hi,

It does help a little thanks, except in my real project, the shell
derivation depends on the project sources to set up some tools.

I was (ab)using the src.outPath attribute to avoid copying of src into
the nix store. Like this:

  # testScript is a buildInput of the shell derivation
  testScript = mkDerivation {
    name = "realproject-test";
    src = realproject.outPath + "/scripts/test";
    buildCommand = "mkdir -p $out/bin && cp $src $out/bin/test";
  };

I don't mind copying the project sources into the nix store before
starting a nix-shell. In fact it's a good thing, if the shell depends on
project sources.

But I would like to filter the files copied so that it's just
git-tracked files and not random cruft.

I saw a recent commit 39e689e "cleanSource: filter out also nix result
symlinks (#16120)" which seems to address the same issue.


Cheers,

Rodney


More information about the nix-dev mailing list