From e96ec7c3ccfcbc57927c93dcb22cb7d78eba7c2c Mon Sep 17 00:00:00 2001 From: Herman Fries Date: Fri, 19 Jan 2024 17:39:11 +0100 Subject: [PATCH] lock: Extend environment instead of replacing it This allows running impure commands, that rely on user's configuration. E.g. to access a private gitlab project. --- modules/dream2nix/core/lock/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/dream2nix/core/lock/default.nix b/modules/dream2nix/core/lock/default.nix index 45a36913e8..58b5d4bb89 100644 --- a/modules/dream2nix/core/lock/default.nix +++ b/modules/dream2nix/core/lock/default.nix @@ -40,6 +40,7 @@ refresh' = config.deps.writePython3Bin "refresh" {} '' import tempfile import subprocess + import os import json from pathlib import Path @@ -55,9 +56,11 @@ def run_refresh_script(script): with tempfile.NamedTemporaryFile() as out_file: + env = os.environ.copy() + env["out"] = out_file.name subprocess.run( [script], - check=True, shell=True, env={"out": out_file.name}) + check=True, shell=True, env=env) # open the file again via its name (it might have been replaced) with open(out_file.name) as out: return json.load(out)