From ab4f88f85fd0e4dc969107c10c71e346c774414d Mon Sep 17 00:00:00 2001 From: LiemLB Date: Fri, 2 Jan 2026 22:19:55 +0700 Subject: [PATCH 1/2] add --impure option --- package.json | 7 ++++++- src/extension.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d139992..8d18967 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "shells", "displayName": "Shells - Nix Flake Environment Switcher", "description": "Switch development environment to Nix flake-based environment", - "version": "0.0.5", + "version": "0.0.6", "icon": "icon.png", "engines": { "vscode": "^1.85.0" @@ -45,6 +45,11 @@ "type": "string", "default": "", "description": "Path to the flake.nix file (relative to workspace root). Leave empty to auto-detect." + }, + "shells.impure": { + "type": "boolean", + "default": false, + "description": "allow impure environment (nix develop --impure)" } } } diff --git a/src/extension.ts b/src/extension.ts index 11c5b56..9fdf3eb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -62,13 +62,17 @@ async function isNixAvailable(): Promise { * Securely extracts environment variables from nix develop */ function getFlakeEnvironment(flakeDir: string): Promise { + const config = vscode.workspace.getConfiguration('shells'); + const impure = config.get('impure'); + const args = (impure) ? ['develop', flakeDir, '--impure', '--command', 'env'] : ['develop', flakeDir, '--command', 'env'] + return new Promise((resolve, reject) => { const env: NodeJS.ProcessEnv = {}; - outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix develop ${flakeDir} --command env`); + outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix develop ${flakeDir} ${(impure) ? '--impure' : ''} --command env`); outputChannel.appendLine('='.repeat(80)); - const proc = spawn('nix', ['develop', flakeDir, '--command', 'env'], { + const proc = spawn('nix', args, { cwd: flakeDir, timeout: 60000, // 60 second timeout }); From f688771e50bffbad865165c627a92a45e103fbab Mon Sep 17 00:00:00 2001 From: LiemLB Date: Sat, 3 Jan 2026 12:54:24 +0700 Subject: [PATCH 2/2] add extraFlags setting --- package.json | 7 ++++++- src/extension.ts | 13 +++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 8d18967..d195bc0 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,12 @@ "shells.impure": { "type": "boolean", "default": false, - "description": "allow impure environment (nix develop --impure)" + "description": "Allow impure flake evaluation (nix develop --impure)." + }, + "shells.nixCommandExtraFlags": { + "type": "array", + "default": [], + "description": "Additional flags can be added via this option (e.g. ['--impure', '--fallback', '--refresh'])." } } } diff --git a/src/extension.ts b/src/extension.ts index 9fdf3eb..3fccfe7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -62,14 +62,19 @@ async function isNixAvailable(): Promise { * Securely extracts environment variables from nix develop */ function getFlakeEnvironment(flakeDir: string): Promise { - const config = vscode.workspace.getConfiguration('shells'); - const impure = config.get('impure'); - const args = (impure) ? ['develop', flakeDir, '--impure', '--command', 'env'] : ['develop', flakeDir, '--command', 'env'] + const config = vscode.workspace.getConfiguration("shells"); + const impure = config.get("impure"); + const nixCommandExtraFlags = (impure ? ["--impure"] : []).concat( + config.get("nixCommandExtraFlags", []) + ); + const args = ["develop", flakeDir] + .concat(nixCommandExtraFlags) + .concat(["--command", "env"]); return new Promise((resolve, reject) => { const env: NodeJS.ProcessEnv = {}; - outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix develop ${flakeDir} ${(impure) ? '--impure' : ''} --command env`); + outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix ${args.join(" ")}`); outputChannel.appendLine('='.repeat(80)); const proc = spawn('nix', args, {