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

Eelco Dolstra eelco.dolstra at logicblox.com
Thu Mar 2 11:53:08 CET 2017


Hi,

On 03/02/2017 08:01 AM, Ganesh Sittampalam wrote:

> 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 better way is to use builtins.fetchTarball:

  with import (fetchTarball {
    url = https://github.com/NixOS/nixpkgs/archive/264d42b.tar.gz;
    sha256 = "19i77afcns8mf88vkxvm3jvkzdkf5x8p8kxnnivhd9l4kslkq3v5";
  }) {};

  {
    env =
      stdenv.mkDerivation rec {
        ...
      };
    };
  }

This also prevents a double evaluation of Nixpkgs. However, this won't work if
you really need to fetch from a local Git repository. Nix 1.12 has a builtin
fetchgit function that allows you to say

  with import (builtins.fetchgit {
    url = <nixpkgs>;
    rev = "...";
  }) {};
  ...

(I just pushed a fix to allow "url" to refer to paths.)

-- 
Eelco Dolstra | LogicBlox, Inc. | http://nixos.org/~eelco/


More information about the nix-dev mailing list