From 32f6cfaae59ad1d1cb1338023015cb6e31c4b2d2 Mon Sep 17 00:00:00 2001 From: figsoda Date: Sat, 12 Aug 2023 11:32:02 -0400 Subject: pluginupdate: don't rely on NIX_PATH Nix does not respect `NIX_PATH` when the `nix-path` setting in nix.conf is set --- maintainers/scripts/pluginupdate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/maintainers/scripts/pluginupdate.py b/maintainers/scripts/pluginupdate.py index 7c6cfd4fed7f0..f9ec19bed4ae1 100644 --- a/maintainers/scripts/pluginupdate.py +++ b/maintainers/scripts/pluginupdate.py @@ -315,9 +315,10 @@ def load_plugins_from_csv(config: FetchConfig, input_file: Path,) -> List[Plugin return plugins def run_nix_expr(expr): - with CleanEnvironment(): + with CleanEnvironment() as nix_path: cmd = ["nix", "eval", "--extra-experimental-features", - "nix-command", "--impure", "--json", "--expr", expr] + "nix-command", "--impure", "--json", "--expr", expr, + "--nix-path", nix_path] log.debug("Running command %s", " ".join(cmd)) out = subprocess.check_output(cmd) data = json.loads(out) @@ -521,14 +522,14 @@ class Editor: class CleanEnvironment(object): - def __enter__(self) -> None: + def __enter__(self) -> str: self.old_environ = os.environ.copy() local_pkgs = str(Path(__file__).parent.parent.parent) - os.environ["NIX_PATH"] = f"localpkgs={local_pkgs}" self.empty_config = NamedTemporaryFile() self.empty_config.write(b"{}") self.empty_config.flush() os.environ["NIXPKGS_CONFIG"] = self.empty_config.name + return f"localpkgs={local_pkgs}" def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None: os.environ.update(self.old_environ) -- cgit 1.4.1