From 529add316c5356a8060c35f987643b7bf5c796dc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Feb 2019 23:20:50 +0800 Subject: downloadCached: Return ETag This allows fetchFlake() to return the Git revision of a GitHub archive. --- src/libexpr/common-eval-args.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 3e0c78f28..37c74a94b 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -46,7 +46,7 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state) Path lookupFileArg(EvalState & state, string s) { if (isUri(s)) - return getDownloader()->downloadCached(state.store, s, true); + return getDownloader()->downloadCached(state.store, s, true).path; else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { Path p = s.substr(1, s.size() - 2); return state.findFile(p); -- cgit v1.2.3 From 84c12dbd7c8f2b34c46908f4a0c43cbb86023f20 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 15 Apr 2019 13:45:51 +0200 Subject: Move --impure to MixEvalArgs --- src/libexpr/common-eval-args.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 37c74a94b..3e5400052 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -26,6 +26,13 @@ MixEvalArgs::MixEvalArgs() .description("add a path to the list of locations used to look up <...> file names") .label("path") .handler([&](std::string s) { searchPath.push_back(s); }); + + mkFlag() + .longName("impure") + .description("allow access to mutable paths and repositories") + .handler([&](std::vector ss) { + evalSettings.pureEval = false; + }); } Bindings * MixEvalArgs::getAutoArgs(EvalState & state) -- cgit v1.2.3 From 24b35bf9e7219feba9399466c41801f0ace3ef74 Mon Sep 17 00:00:00 2001 From: Nick Van den Broeck Date: Thu, 21 Mar 2019 09:30:16 +0100 Subject: Fixed issue #13 --- src/libexpr/common-eval-args.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 3e5400052..8e94d358e 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -33,6 +33,15 @@ MixEvalArgs::MixEvalArgs() .handler([&](std::vector ss) { evalSettings.pureEval = false; }); + + mkFlag() + .longName("override-flake") + .labels({"original-ref", "resolved-ref"}) + .description("override a flake registry value") + .arity(2) + .handler([&](std::vector ss) { + registryOverrides.push_back(std::make_pair(ss[0], ss[1])); + }); } Bindings * MixEvalArgs::getAutoArgs(EvalState & state) -- cgit v1.2.3 From df3f5a78d5ab0a1f2dc9d288b271b38a9b8b33b5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 May 2019 23:36:29 +0200 Subject: Refactor downloadCached() interface --- src/libexpr/common-eval-args.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 8e94d358e..7c0d268bd 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -61,9 +61,11 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state) Path lookupFileArg(EvalState & state, string s) { - if (isUri(s)) - return getDownloader()->downloadCached(state.store, s, true).path; - else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { + if (isUri(s)) { + CachedDownloadRequest request(s); + request.unpack = true; + return getDownloader()->downloadCached(state.store, request).path; + } else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { Path p = s.substr(1, s.size() - 2); return state.findFile(p); } else -- cgit v1.2.3 From b5c9dbc84f31a1e9d1e5b6642b1716daa13c18ed Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 22 Jan 2020 20:00:58 +0100 Subject: Fix --override-flake and add a test --- src/libexpr/common-eval-args.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 7c0d268bd..e3135b472 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -3,6 +3,8 @@ #include "download.hh" #include "util.hh" #include "eval.hh" +#include "fetchers/registry.hh" +#include "flake/flakeref.hh" namespace nix { @@ -40,7 +42,9 @@ MixEvalArgs::MixEvalArgs() .description("override a flake registry value") .arity(2) .handler([&](std::vector ss) { - registryOverrides.push_back(std::make_pair(ss[0], ss[1])); + fetchers::overrideRegistry( + parseFlakeRef(ss[0], absPath(".")).input, + parseFlakeRef(ss[1], absPath(".")).input); }); } -- cgit v1.2.3 From d068f9ffff3d2a98e6dde0834a250e4930d44778 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Feb 2020 22:14:44 +0100 Subject: Restore subdir support in registries Hacky... --- src/libexpr/common-eval-args.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index e3135b472..1fdd4e9ec 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -42,9 +42,11 @@ MixEvalArgs::MixEvalArgs() .description("override a flake registry value") .arity(2) .handler([&](std::vector ss) { - fetchers::overrideRegistry( - parseFlakeRef(ss[0], absPath(".")).input, - parseFlakeRef(ss[1], absPath(".")).input); + auto from = parseFlakeRef(ss[0], absPath(".")); + auto to = parseFlakeRef(ss[1], absPath(".")); + fetchers::Input::Attrs extraAttrs; + if (to.subdir != "") extraAttrs["subdir"] = to.subdir; + fetchers::overrideRegistry(from.input, to.input, extraAttrs); }); } -- cgit v1.2.3 From 73c98405695837dd93448ed38c0eeb0b56060dfc Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Feb 2020 23:44:06 +0100 Subject: Restore subdir -> dir Got this mixed up somewhere. --- src/libexpr/common-eval-args.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 1fdd4e9ec..fc60954b4 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -45,7 +45,7 @@ MixEvalArgs::MixEvalArgs() auto from = parseFlakeRef(ss[0], absPath(".")); auto to = parseFlakeRef(ss[1], absPath(".")); fetchers::Input::Attrs extraAttrs; - if (to.subdir != "") extraAttrs["subdir"] = to.subdir; + if (to.subdir != "") extraAttrs["dir"] = to.subdir; fetchers::overrideRegistry(from.input, to.input, extraAttrs); }); } -- cgit v1.2.3 From 2a4e4f6a6e021481f0e92b7d3006345e68e77684 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 17 Mar 2020 20:54:36 +0100 Subject: Unified fetcher caching system --- src/libexpr/common-eval-args.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index fc60954b4..59a2b9c89 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -44,7 +44,7 @@ MixEvalArgs::MixEvalArgs() .handler([&](std::vector ss) { auto from = parseFlakeRef(ss[0], absPath(".")); auto to = parseFlakeRef(ss[1], absPath(".")); - fetchers::Input::Attrs extraAttrs; + fetchers::Attrs extraAttrs; if (to.subdir != "") extraAttrs["dir"] = to.subdir; fetchers::overrideRegistry(from.input, to.input, extraAttrs); }); -- cgit v1.2.3 From f6ddf48882a068dbf1b1bfff44d487316972d6e9 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 18 Mar 2020 17:23:56 +0100 Subject: Get rid of downloadCached() Everything uses the generic caching system now. --- src/libexpr/common-eval-args.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 59a2b9c89..9ebb6a835 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -4,7 +4,9 @@ #include "util.hh" #include "eval.hh" #include "fetchers/registry.hh" +#include "fetchers/fetchers.hh" #include "flake/flakeref.hh" +#include "store-api.hh" namespace nix { @@ -68,9 +70,9 @@ Bindings * MixEvalArgs::getAutoArgs(EvalState & state) Path lookupFileArg(EvalState & state, string s) { if (isUri(s)) { - CachedDownloadRequest request(s); - request.unpack = true; - return getDownloader()->downloadCached(state.store, request).path; + return state.store->toRealPath( + fetchers::downloadTarball( + state.store, resolveUri(s), "source", false).storePath); } else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { Path p = s.substr(1, s.size() - 2); return state.findFile(p); -- cgit v1.2.3 From e0a0ae0467fa8cdcc542f593b9d94283f04508ff Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 30 Mar 2020 14:03:28 +0200 Subject: Move fetchers from libstore to libfetchers --- src/libexpr/common-eval-args.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 9ebb6a835..bf5025147 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -3,8 +3,8 @@ #include "download.hh" #include "util.hh" #include "eval.hh" -#include "fetchers/registry.hh" -#include "fetchers/fetchers.hh" +#include "registry.hh" +#include "fetchers.hh" #include "flake/flakeref.hh" #include "store-api.hh" -- cgit v1.2.3 From 950b46821f644eb3f92725460584a3102f356179 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 30 May 2020 00:44:11 +0200 Subject: Remove TreeInfo The attributes previously stored in TreeInfo (narHash, revCount, lastModified) are now stored in Input. This makes it less arbitrary what attributes are stored where. As a result, the lock file format has changed. An entry like "info": { "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github" }, is now stored as "locked": { "owner": "NixOS", "repo": "nixpkgs", "rev": "b88ff468e9850410070d4e0ccd68c7011f15b2be", "type": "github", "lastModified": 1585405475, "narHash": "sha256-bESW0n4KgPmZ0luxvwJ+UyATrC6iIltVCsGdLiphVeE=" }, The 'Input' class is now a dumb set of attributes. All the fetcher implementations subclass InputScheme, not Input. This simplifies the API. Also, fix substitution of flake inputs. This was broken since lazy flake fetching started using fetchTree internally. --- src/libexpr/common-eval-args.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/common-eval-args.cc') diff --git a/src/libexpr/common-eval-args.cc b/src/libexpr/common-eval-args.cc index 8665abe8c..6b48ead1f 100644 --- a/src/libexpr/common-eval-args.cc +++ b/src/libexpr/common-eval-args.cc @@ -76,7 +76,7 @@ Path lookupFileArg(EvalState & state, string s) if (isUri(s)) { return state.store->toRealPath( fetchers::downloadTarball( - state.store, resolveUri(s), "source", false).storePath); + state.store, resolveUri(s), "source", false).first.storePath); } else if (s.size() > 2 && s.at(0) == '<' && s.at(s.size() - 1) == '>') { Path p = s.substr(1, s.size() - 2); return state.findFile(p); -- cgit v1.2.3