diff --git a/package.json b/package.json index d139992..d195bc0 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,16 @@ "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 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 11c5b56..3fccfe7 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -62,13 +62,22 @@ 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 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} --command env`); + outputChannel.appendLine(`[${new Date().toISOString()}] Running: nix ${args.join(" ")}`); outputChannel.appendLine('='.repeat(80)); - const proc = spawn('nix', ['develop', flakeDir, '--command', 'env'], { + const proc = spawn('nix', args, { cwd: flakeDir, timeout: 60000, // 60 second timeout });