From 65f17cd3309e192dcf0d61d3d946a3610420a9d4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 17 Jun 2015 16:20:11 +0200 Subject: Support URLs in $NIX_PATH This didn't work (despite claims in the manual), because the colon in "http://" was parsed as a element separator. So handle "://" specially. --- src/libexpr/eval.cc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/libexpr/eval.cc') diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 88cf9f45342c..d61ee7e80795 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -234,6 +234,18 @@ void initGC() } +/* Very hacky way to parse $NIX_PATH, which is colon-separated, but + can contain URLs (e.g. "nixpkgs=https://bla...:foo=https://"). */ +static Strings parseNixPath(const string & in) +{ + string marker = "\001//"; + auto res = tokenizeString(replaceStrings(in, "://", marker), ":"); + for (auto & s : res) + s = replaceStrings(s, marker, "://"); + return res; +} + + EvalState::EvalState(const Strings & _searchPath) : sWith(symbols.create("")) , sOutPath(symbols.create("outPath")) @@ -266,7 +278,7 @@ EvalState::EvalState(const Strings & _searchPath) assert(gcInitialised); /* Initialise the Nix expression search path. */ - Strings paths = tokenizeString(getEnv("NIX_PATH", ""), ":"); + Strings paths = parseNixPath(getEnv("NIX_PATH", "")); for (auto & i : _searchPath) addToSearchPath(i, true); for (auto & i : paths) addToSearchPath(i); addToSearchPath("nix=" + settings.nixDataDir + "/nix/corepkgs"); -- cgit 1.4.1