Skip to content

Commit 44e1774

Browse files
author
LiemLB
committed
add extraFlags setting
1 parent ab4f88f commit 44e1774

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@
5050
"type": "boolean",
5151
"default": false,
5252
"description": "allow impure environment (nix develop --impure)"
53+
},
54+
"shells.nixCommandExtraFlags": {
55+
"type": "array",
56+
"default": [],
57+
"description": "additional flags can be add via this option (eg. ['--impure', '--fallback', '--refresh'])"
5358
}
5459
}
5560
}

src/extension.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,19 @@ async function isNixAvailable(): Promise<boolean> {
6262
* Securely extracts environment variables from nix develop
6363
*/
6464
function getFlakeEnvironment(flakeDir: string): Promise<NodeJS.ProcessEnv> {
65-
const config = vscode.workspace.getConfiguration('shells');
66-
const impure = config.get<boolean>('impure');
67-
const args = (impure) ? ['develop', flakeDir, '--impure', '--command', 'env'] : ['develop', flakeDir, '--command', 'env']
65+
const config = vscode.workspace.getConfiguration("shells");
66+
const impure = config.get<boolean>("impure");
67+
const nixCommandExtraFlags = (impure ? ["--impure"] : []).concat(
68+
config.get<string[]>("nixCommandExtraFlags", [])
69+
);
70+
const args = ["develop", flakeDir]
71+
.concat(nixCommandExtraFlags)
72+
.concat(["--command", "env"]);
6873

6974
return new Promise((resolve, reject) => {
7075
const env: NodeJS.ProcessEnv = {};
7176

72-
outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix develop ${flakeDir} ${(impure) ? '--impure' : ''} --command env`);
77+
outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix ${args.join(" ")}`);
7378
outputChannel.appendLine('='.repeat(80));
7479

7580
const proc = spawn('nix', args, {

0 commit comments

Comments
 (0)