{"record":{"id":"5e25c1d20fc3802b","repo":"jdx/mise","slug":"cannot-export-spec-use-a-shorthand-attribute-such-as-nix","errorCode":null,"errorMessage":"cannot export '{spec}': use a shorthand attribute such as nix:ripgrep; the importing NixOS configuration owns the package source","messagePattern":"cannot export '(.+?)': use a shorthand attribute such as nix:ripgrep; the importing NixOS configuration owns the package source","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/system/export.rs","lineNumber":56,"sourceCode":"        let module = render(\n            packages\n                .iter()\n                .map(|(spec, package)| (spec.as_str(), package.version())),\n        )?;\n        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(","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/system/export.rs#L38-L74","documentation":"`mise bootstrap packages export --format nix` renders installed `nix:` bootstrap packages as a NixOS module whose packages resolve against the importing configuration's `pkgs`. The export refuses package specs parsed as explicit sources (flake refs like `github:owner/repo#pkg`, store paths, expressions) because a NixOS module can only reference attributes of the importing pkgs set — the package source must be owned by the importing configuration.","triggerScenarios":"Running `mise bootstrap packages export --format nix` when `[bootstrap.packages]` contains a spec like `nix:github:owner/repo#hello`, a nix store path, or an embedded Nix expression instead of a plain attribute path such as `nix:ripgrep` (Installable::parse sets explicit=true).","commonSituations":"Users installed a package from a flake or tarball via `mise bootstrap packages install nix:github:...` and later try to reproduce their setup on NixOS by exporting; the flake-installed package cannot be represented as `pkgs.<attr>`.","solutions":["Replace the explicit-source spec in `[bootstrap.packages]` with a plain nixpkgs attribute shorthand, e.g. `nix:ripgrep` instead of `nix:github:owner/repo#ripgrep`.","Keep the flake-based package out of mise bootstrap packages and declare it directly in your NixOS configuration or an overlay.","If a nixpkgs attribute exists for the software, install that attribute (possibly from a pinned nixpkgs input in the NixOS config) so it is exportable."],"exampleFix":"# before (mise.toml)\n[bootstrap.packages]\n\"nix:github:owner/repo#hello\" = \"latest\"\n\n# after\n[bootstrap.packages]\n\"nix:hello\" = \"latest\"","handlingStrategy":"validation","validationCode":"// Before export, ensure every nix: spec is a plain attribute shorthand\nconst explicit = /(^|:)(github|gitlab|sourcehut|git|file|path|flake|nixpkgs)[:/]/;\nconst bad = Object.keys(packages).filter(k => k.startsWith(\"nix:\") && explicit.test(k.slice(4)));\nif (bad.length) throw new Error(`non-shorthand nix specs not exportable: ${bad.join(\", \")}`);","typeGuard":"const isShorthandNixSpec = (spec) =>\n  spec.startsWith(\"nix:\") && /^[A-Za-z0-9_.-]+(\\.[A-Za-z0-9_.-]+)*$/.test(spec.slice(4));","tryCatchPattern":null,"preventionTips":["Prefer plain nixpkgs attribute shorthands (nix:ripgrep) in [bootstrap.packages].","Keep flake/store-path packages in your NixOS config, not mise bootstrap packages.","Review [bootstrap.packages] for flake refs (`github:`, `git:`) before running export."],"tags":["nix","cli","config","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"}