From d04969ffa53ce5f62efbfe02a85cfc12ec6097d6 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 12 Apr 2021 12:36:14 -0400 Subject: [PATCH] EvalSettings::getDefaultNixPath: respect {restrict,pure}Eval Otherwise Nix may look to invalid locations for channels. --- src/libexpr/eval.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 3afe2e47b..936bccc8c 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -2091,9 +2091,12 @@ Strings EvalSettings::getDefaultNixPath() } }; - add(getHome() + "/.nix-defexpr/channels"); - add(settings.nixStateDir + "/profiles/per-user/root/channels/nixpkgs", "nixpkgs"); - add(settings.nixStateDir + "/profiles/per-user/root/channels"); + if (!evalSettings.restrictEval && !evalSettings.pureEval) { + add(getHome() + "/.nix-defexpr/channels"); + add(settings.nixStateDir + "/profiles/per-user/root/channels/nixpkgs", "nixpkgs"); + add(settings.nixStateDir + "/profiles/per-user/root/channels"); + } + return res; }