@@ -22,9 +22,9 @@ def run(
22
22
stdin : int | IO [str ] | None = None ,
23
23
stdout : int | IO [str ] | None = None ,
24
24
stderr : int | IO [str ] | None = None ,
25
- verbose : bool = True ,
25
+ debug : bool = True ,
26
26
) -> subprocess .CompletedProcess [str ]:
27
- if verbose :
27
+ if debug :
28
28
print ("$" , shlex .join (cmd ), file = sys .stderr )
29
29
return subprocess .run (
30
30
cmd ,
@@ -36,9 +36,9 @@ def run(
36
36
)
37
37
38
38
39
- def git_command (args : list [str ], path : Path ) -> str :
39
+ def git_command (args : list [str ], path : Path , debug : bool = False ) -> str :
40
40
cmd = ["git" , "-C" , str (path ), * args ]
41
- proc = run (cmd , stdout = subprocess .PIPE )
41
+ proc = run (cmd , stdout = subprocess .PIPE , debug = debug )
42
42
return proc .stdout .strip ()
43
43
44
44
@@ -121,7 +121,7 @@ def list_effects(opts: EffectsOptions) -> list[str]:
121
121
"--expr" ,
122
122
f"builtins.attrNames ({ effect_function (opts )} )" ,
123
123
)
124
- proc = run (cmd , stdout = subprocess .PIPE )
124
+ proc = run (cmd , stdout = subprocess .PIPE , debug = opts . debug )
125
125
return json .loads (proc .stdout )
126
126
127
127
@@ -131,11 +131,11 @@ def instantiate_effects(effect: str, opts: EffectsOptions) -> str:
131
131
"--expr" ,
132
132
f"(({ effect_function (opts )} ).{ effect } ).run or []" ,
133
133
]
134
- proc = run (cmd , stdout = subprocess .PIPE )
134
+ proc = run (cmd , stdout = subprocess .PIPE , debug = opts . debug )
135
135
return proc .stdout .rstrip ()
136
136
137
137
138
- def parse_derivation (path : str ) -> dict [str , Any ]:
138
+ def parse_derivation (path : str , debug : bool = False ) -> dict [str , Any ]:
139
139
cmd = [
140
140
"nix" ,
141
141
"--extra-experimental-features" ,
@@ -144,7 +144,7 @@ def parse_derivation(path: str) -> dict[str, Any]:
144
144
"show" ,
145
145
f"{ path } ^*" ,
146
146
]
147
- proc = run (cmd , stdout = subprocess .PIPE )
147
+ proc = run (cmd , stdout = subprocess .PIPE , debug = debug )
148
148
return json .loads (proc .stdout )
149
149
150
150
@@ -176,6 +176,7 @@ def run_effects(
176
176
drv_path : str ,
177
177
drv : dict [str , Any ],
178
178
secrets : dict [str , Any ] | None = None ,
179
+ debug : bool = False ,
179
180
) -> None :
180
181
if secrets is None :
181
182
secrets = {}
@@ -257,7 +258,8 @@ def run_effects(
257
258
bubblewrap_cmd .append ("--" )
258
259
bubblewrap_cmd .extend (sandboxed_cmd )
259
260
with pipe () as (r_file , w_file ):
260
- print ("$" , shlex .join (bubblewrap_cmd ), file = sys .stderr )
261
+ if debug :
262
+ print ("$" , shlex .join (bubblewrap_cmd ), file = sys .stderr )
261
263
proc = subprocess .Popen (
262
264
bubblewrap_cmd ,
263
265
text = True ,
0 commit comments