Skip to content

Commit

Permalink
Don't define builtins.{currentSystem,currentTime} in pure mode
Browse files Browse the repository at this point in the history
This makes it easier to provide a default, e.g.

  system = builtins.currentSystem or "x86_64-linux";
  • Loading branch information
edolstra committed Jan 18, 2018
1 parent 5647e55 commit 0c95776
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion release.nix
Expand Up @@ -6,7 +6,7 @@

let

pkgs = import nixpkgs { system = "x86_64-linux"; };
pkgs = import nixpkgs { system = builtins.currentSystem or "x86_64-linux"; };

jobs = rec {

Expand Down
8 changes: 2 additions & 6 deletions src/libexpr/primops.cc
Expand Up @@ -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);
}
Expand Down

0 comments on commit 0c95776

Please sign in to comment.