{"record":{"id":"94cef4dfed342c71","repo":"jdx/mise","slug":"nix-failed-see-nix-s-diagnostic-above-ensure-nix-command-and","errorCode":null,"errorMessage":"nix {} failed; see Nix's diagnostic above. Ensure nix-command and flakes are enabled and the profile uses modern `nix profile` format","messagePattern":"nix (.+?) failed; see Nix's diagnostic above\\. Ensure nix-command and flakes are enabled and the profile uses modern `nix profile` format","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/nix.rs","lineNumber":260,"sourceCode":"        || installed == format!(\"packages.{system}.{request}\")\n        || installed == format!(\"legacyPackages.{system}.{request}\")\n}\n\nasync fn action(args: Vec<String>, opts: &InstallOpts) -> Result<()> {\n    if opts.dry_run {\n        miseprintln!(\"nix {}\", shell_words::join(&args));\n        return Ok(());\n    }\n    debug!(\"$ nix {}\", shell_words::join(&args));\n    let status = tokio::process::Command::new(\"nix\")\n        .args(&args)\n        .stdin(Stdio::null())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .await?;\n    if !status.success() {\n        bail!(\n            \"nix {} failed; see Nix's diagnostic above. Ensure nix-command and flakes are enabled and the profile uses modern `nix profile` format\",\n            shell_words::join(&args)\n        );\n    }\n    Ok(())\n}\n\nfn reject_pins(pkgs: &[PackageRequest]) -> Result<()> {\n    if let Some(pkg) = pkgs.iter().find(|p| p.version.is_some()) {\n        bail!(\n            \"Nix cannot install package version pin '{pkg}'; pin the flake source revision instead\"\n        );\n    }\n    Ok(())\n}\n\n#[async_trait(?Send)]\nimpl SystemPackageManager for NixManager {","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/nix.rs#L242-L278","documentation":"Mutating `nix` operations (`profile install`, `profile upgrade`) run through `action()` with stdout/stderr inherited, so Nix's own diagnostics print directly to the terminal. On non-zero exit, mise raises this short message telling you to read the diagnostic above rather than duplicating it, and highlighting the usual causes: disabled experimental features or a legacy profile format.","triggerScenarios":"`nix profile install ...` or `nix profile upgrade ...` exits non-zero: flake/attribute not found, network/registry fetch failure, experimental features disabled, lockfile/profile issues, or store permission errors.","commonSituations":"Typo'd attribute names; private flakes requiring auth; offline builds; nix-command/flakes not enabled on a fresh machine; multi-user Nix permission problems; interrupted profile leaving a bad manifest.","solutions":["Read the Nix diagnostic printed above the error; fix the specific cause it names.","Verify `experimental-features = nix-command flakes` is set in nix.conf.","Run the exact `nix profile install/upgrade` command from the message manually with full output.","Check network/auth if the diagnostic mentions fetching a flake (private repos need credentials/token setup).","If the profile is corrupt, recreate it: `nix profile list` to inspect, remove broken entries, retry."],"exampleFix":"# before (nix.conf)\n# experimental-features absent\n\n# after\nexperimental-features = nix-command flakes","handlingStrategy":"try-catch","validationCode":"nix profile list --profile ~/.nix-profile --json >/dev/null 2>&1 && \\\n  nix flake metadata nixpkgs >/dev/null 2>&1 && echo ok || echo \"fix nix setup first\"","typeGuard":null,"tryCatchPattern":"if let Err(e) = manager.install(&pkgs, &opts).await {\n    // Nix already printed its diagnostic; surface it alongside mise's hint\n    eprintln!(\"{}\\ncheck: experimental-features, attribute name, network/auth\", e);\n}","preventionTips":["Verify the attribute exists via nix search before adding it","Ensure nix-command and flakes are enabled everywhere mise runs","Pre-fetch private flakes / configure tokens before install","Run `nix profile install <ref>#attr` manually once to validate the reference"],"tags":["nix","command-failed","profile-install","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"}