Don't define builtins.{currentSystem,currentTime} in pure mode

This makes it easier to provide a default, e.g.

  system = builtins.currentSystem or "x86_64-linux";
This commit is contained in:
Eelco Dolstra 2018-01-18 16:37:39 +01:00
parent 5647e55f65
commit 0c95776c3e
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 3 additions and 7 deletions

View file

@ -6,7 +6,7 @@
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
pkgs = import nixpkgs { system = builtins.currentSystem or "x86_64-linux"; };
jobs = rec {

View file

@ -1997,16 +1997,12 @@ void EvalState::createBaseEnv()
addConstant(name, v);
};
if (settings.pureEval)
addPurityError("__currentTime");
else {
if (!settings.pureEval) {
mkInt(v, time(0));
addConstant("__currentTime", v);
}
if (settings.pureEval)
addPurityError("__currentSystem");
else {
if (!settings.pureEval) {
mkString(v, settings.thisSystem);
addConstant("__currentSystem", v);
}