From 62a6eeb1f3da0a5954ad2da54c454eb7fc1c6e5d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 26 May 2014 17:02:22 +0200 Subject: Make the Nix search path declarative MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nix search path lookups like are now desugared to ‘findFile nixPath ’, where ‘findFile’ is a new primop. Thus you can override the search path simply by saying let nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ]; in ... ... In conjunction with ‘scopedImport’ (commit c273c15cb13bb86420dda1e5341a4e19517532b5), the Nix search path can be propagated across imports, e.g. let overrides = { nixPath = [ ... ] ++ builtins.nixPath; import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; builtins = builtins // overrides; }; in scopedImport overrides ./nixos --- tests/lang/eval-okay-search-path.exp | 2 +- tests/lang/eval-okay-search-path.nix | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/lang/eval-okay-search-path.exp b/tests/lang/eval-okay-search-path.exp index d0bc8c5e86b2..ad05904ba1f7 100644 --- a/tests/lang/eval-okay-search-path.exp +++ b/tests/lang/eval-okay-search-path.exp @@ -1 +1 @@ -"abcc" +"abcca" diff --git a/tests/lang/eval-okay-search-path.nix b/tests/lang/eval-okay-search-path.nix index 501d5f3f4804..e0f433fec634 100644 --- a/tests/lang/eval-okay-search-path.nix +++ b/tests/lang/eval-okay-search-path.nix @@ -8,3 +8,4 @@ assert length (filter (x: x.prefix == "nix") nixPath) == 1; assert length (filter (x: baseNameOf x.path == "dir4") nixPath) == 1; import + import + import + import + + (let nixPath = [ { path = ./dir1; } { path = ./dir2; } ]; in import ) -- cgit 1.4.1