{"record":{"id":"15b13a66e8ce4ef9","repo":"jdx/mise","slug":"cannot-export-version-pin-spec-version-pin-nixpkgs-in-the","errorCode":null,"errorMessage":"cannot export version pin '{spec}' = '{version}': pin nixpkgs in the importing NixOS configuration instead","messagePattern":"cannot export version pin '(.+?)' = '(.+?)': pin nixpkgs in the importing NixOS configuration instead","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/system/export.rs","lineNumber":61,"sourceCode":"        miseprint!(\"{module}\")?;\n        Ok(())\n    }\n}\n\nfn render<'a>(packages: impl IntoIterator<Item = (&'a str, &'a str)>) -> Result<String> {\n    let mut attributes = std::collections::BTreeSet::new();\n    for (spec, version) in packages {\n        let name = spec\n            .strip_prefix(\"nix:\")\n            .ok_or_else(|| eyre::eyre!(\"expected a nix: package: {spec}\"))?;\n        let request = Installable::parse(name)?;\n        if request.explicit {\n            bail!(\n                \"cannot export '{spec}': use a shorthand attribute such as nix:ripgrep; the importing NixOS configuration owns the package source\"\n            );\n        }\n        if version != \"latest\" {\n            bail!(\n                \"cannot export version pin '{spec}' = '{version}': pin nixpkgs in the importing NixOS configuration instead\"\n            );\n        }\n        attributes.insert(\n            request\n                .attribute\n                .split('.')\n                .map(nix_string)\n                .collect::<Vec<_>>()\n                .join(\".\"),\n        );\n    }\n    let mut output = String::from(\n        \"# Generated by mise bootstrap packages export --format nix\\n{ pkgs, ... }:\\n{\\n  environment.systemPackages = [\\n\",\n    );\n    for attribute in attributes {\n        output.push_str(&format!(\"    pkgs.{attribute}\\n\"));\n    }","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/system/export.rs#L43-L79","documentation":"The Nix export renders packages as bare `pkgs.<attribute>` entries in a NixOS module; attribute entries carry no version, so a pinned version cannot be represented. mise throws this when a `nix:` bootstrap package has a version other than `latest`, telling you to pin nixpkgs in the importing NixOS configuration instead.","triggerScenarios":"Running `mise bootstrap packages export --format nix` while `[bootstrap.packages]` contains an entry like `\"nix:hello\" = \"1.2\"` (any non-`latest` version string).","commonSituations":"A user pinned a nix package version in mise.toml for reproducibility and then runs export to generate a NixOS module; the pin has no equivalent in `environment.systemPackages`.","solutions":["Change the package entry in `[bootstrap.packages]` to version `latest` before exporting.","Pin the nixpkgs revision (e.g. via `nixpkgs.url` / an overlay) in the importing NixOS configuration to control versions there.","Keep the version-pinned package managed by mise/Nix outside of the exported module rather than via bootstrap packages."],"exampleFix":"# before (mise.toml)\n[bootstrap.packages]\n\"nix:hello\" = \"1.2\"\n\n# after\n[bootstrap.packages]\n\"nix:hello\" = \"latest\"","handlingStrategy":"validation","validationCode":"// Only 'latest' versions can be exported for nix packages\nconst pinned = Object.entries(packages)\n  .filter(([k, v]) => k.startsWith(\"nix:\") && v !== \"latest\");\nif (pinned.length) throw new Error(`unpin these before export: ${pinned.map(([k]) => k).join(\", \")}`);","typeGuard":"const isExportableNixEntry = ([spec, version]) =>\n  spec.startsWith(\"nix:\") && version === \"latest\";","tryCatchPattern":null,"preventionTips":["Keep nix bootstrap packages at version \"latest\" in mise.toml.","Pin versions at the nixpkgs level (nixpkgs input revision) instead of per-package pins.","Run export with a dry review of [bootstrap.packages] versions first."],"tags":["nix","cli","version-pin","export"],"backgroundTag":"unsupported-operation","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"}