{"record":{"id":"0234806f0e7298c1","repo":"jdx/mise","slug":"nix-failed-nix-bootstrap-requires-modern-nix-profile-support","errorCode":null,"errorMessage":"nix {} failed: {}\nNix bootstrap requires modern `nix profile` support and the nix-command and flakes experimental features. Enable these in your Nix configuration; mise does not change it.","messagePattern":"nix (.+?) failed: (.+?)\nNix bootstrap requires modern `nix profile` support and the nix-command and flakes experimental features\\. Enable these in your Nix configuration; mise does not change it\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/nix.rs","lineNumber":137,"sourceCode":"    refs: Vec<Value>,\n}\n\n#[derive(Clone)]\nstruct MatchedEntry {\n    name: String,\n    paths: Vec<String>,\n}\n\nasync fn query(args: &[&str]) -> Result<String> {\n    debug!(\"$ nix {}\", shell_words::join(args));\n    let output = tokio::process::Command::new(\"nix\")\n        .args(args)\n        .stdin(Stdio::null())\n        .output()\n        .await\n        .wrap_err(\"failed to run Nix; install Nix and make its CLI available on PATH\")?;\n    if !output.status.success() {\n        bail!(\n            \"nix {} failed: {}\\nNix bootstrap requires modern `nix profile` support and the nix-command and flakes experimental features. Enable these in your Nix configuration; mise does not change it.\",\n            shell_words::join(args),\n            String::from_utf8_lossy(&output.stderr).trim()\n        );\n    }\n    Ok(String::from_utf8(output.stdout)?)\n}\n\n/// Passing an explicit profile avoids Nix's default-profile initialization:\n/// even `nix profile list` otherwise creates ~/.nix-profile on a fresh home.\nasync fn profile_path() -> Result<PathBuf> {\n    let config: Value = serde_json::from_str(&query(&[\"config\", \"show\", \"--json\"]).await?)?;\n    let xdg = config[\"use-xdg-base-directories\"][\"value\"]\n        .as_bool()\n        .unwrap_or(false);\n    Ok(if xdg {\n        std::env::var_os(\"XDG_STATE_HOME\")\n            .filter(|p| !p.is_empty())","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/nix.rs#L119-L155","documentation":"mise runs read-only `nix` queries (e.g. `nix config show --json`, `nix profile list --json`, `nix eval --json ...`) through `query()`. When the nix subprocess exits non-zero, mise wraps the captured stderr in this message pointing at the two usual root causes: missing modern `nix profile` support and disabled experimental features (`nix-command`, `flakes`). mise deliberately does not mutate the user's Nix configuration.","triggerScenarios":"Any `nix` invocation in `query()` fails: experimental features not enabled (`nix-command`/`flakes`), no `nix profile` support (very old Nix), bad profile path, registry resolution failure, or `nix eval --impure` disallowed by config.","commonSituations":"Fresh Nix installs without `experimental-features = nix-command flakes` in nix.conf; single-user Nix on distros with ancient versions; sandboxed CI where nix.conf is not the user's; `--offline` eval failing due to missing flake registry cache.","solutions":["Enable the experimental features: add `experimental-features = nix-command flakes` to `~/.config/nix/nix.conf` (or `/etc/nix/nix.conf`).","Upgrade Nix to 2.24+ so modern `nix profile` exists.","Run the failing command shown in the message manually to see the underlying Nix diagnostic.","If `nix eval --offline` fails on registry lookups, warm the registry cache once online or use explicit flake URLs instead of registry names.","Check NIX_CONFIG / nix.conf in CI images; the environment mise runs in may differ from your shell."],"exampleFix":"# before (nix.conf)\n# (no experimental-features line)\n\n# after\nexperimental-features = nix-command flakes","handlingStrategy":"validation","validationCode":"# ensure features before relying on nix-backed installs\ngrep -q 'experimental-features' ~/.config/nix/nix.conf || \\\n  echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf\nnix --version # require >= 2.24","typeGuard":null,"tryCatchPattern":"async fn run_query(args: &[&str]) -> Result<String> {\n    query(args).await.map_err(|e| {\n        eprintln!(\"hint: enable nix-command and flakes, upgrade Nix >= 2.24\");\n        e\n    })\n}","preventionTips":["Set experimental-features = nix-command flakes in nix.conf","Keep Nix >= 2.24 on all machines and CI","Run `nix profile list --json` manually to verify the environment mise will see","Beware CI images with different nix.conf than your shell"],"tags":["nix","command-failed","experimental-features","flakes","subprocess"],"backgroundTag":"git-command-failed","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}