[Nix-dev] importing nixpkgs from derivation dumps large path

Ganesh Sittampalam ganesh at earth.li
Thu Mar 2 08:01:37 CET 2017


Hi,

I'm trying to maintain a set of development environments using
nix-shell. For each environment, I want to keep them pinned at a
particular git revision of nixpkgs until I explicitly upgrade that
environment, so I can check that everything still works properly.

I used to manage this manually with a comment on myEnvFun environments.
While migrating them to nix-shell, I learnt that I can use "import from
derivation" for this instead and have it expressed within the nix language:

 {
   env =
     let pkgs =
          import
             (with import <nixpkgs> {} ;
              fetchgit {
                url = <nixpkgs>;
                rev = "264d42b";
                sha256 =
                 "19i77afcns8mf88vkxvm3jvkzdkf5x8p8kxnnivhd9l4kslkq3v5";
              }) {};

     in with pkgs ; stdenv.mkDerivation rec {
         name = "haskell-http-ghc710";
         buildInputs = [ stdenv pkgconfig gcc binutils
                         haskell.compiler.ghc7102
                         haskellPackages.cabal-install
                         zlib ];
     };
 }

When I instantiate this, e.g. with

 nix-instantiate -I nixpkgs=<some nixpkgs checkout> demo.nix -A env

it takes about 5-10s and prints out this message, though it does complete:

warning: dumping very large path (> 256 MiB); this may run out of memory

I'm aware that this error is typically associated with trying to import
large files or large trees into the store:

https://github.com/NixOS/nix/issues/358
https://github.com/NixOS/nixpkgs/issues/12243

I guess that in this case the large tree is the import of the nixpkgs
tree. Is there any work around or better way to achieve what I want? The
time taken is annoying particularly because I have a lot of these shells
that I sometimes want to rebuild all together.

Cheers,

Ganesh


More information about the nix-dev mailing list