Flake does not provide attribute 'packages.x86_64-linux.<configname>'

hey, i’m pretty new to writing nix configs and flakes. the one i’m trying to get running on my machine runs into this error when i build it: error: flake '<flakename>' does not provide attribute 'packages.x86_64-linux.<configname>', 'legacyPackages.x86_64-linux.<configname>', or '<configname>'

this is the repo for my flake, and here’s the output from running nix build <flake> --debug:

evaluating file '<nix/derivation-internal.nix>'
evaluating derivation 'git+file:///mnt/etc/nixos#shuixing'...
using cache entry 'gitRevCount:{"rev":"dab1ea8a69201c885e018c5857c48655aad467b7"}' -> '{"revCount":17}'
using cache entry 'gitLastModified:{"rev":"dab1ea8a69201c885e018c5857c48655aad467b7"}' -> '{"lastModified":1733988418}'
using cache entry 'fetchToStore:{"fingerprint":"dab1ea8a69201c885e018c5857c48655aad467b7","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> '{"storePath":"0gv5j7p6qp0lqfbci1wqi2ajy6aq4yqz-source"}'
acquiring write lock on '/nix/var/nix/temproots/337068'
using cache entry 'fetchToStore:{"fingerprint":"dab1ea8a69201c885e018c5857c48655aad467b7","method":"nar","name":"source","path":"/","store":"/nix/store"}' -> 'null', '/nix/store/0gv5j7p6qp0lqfbci1wqi2ajy6aq4yqz-source'
store path cache hit for '/mnt/etc/nixos/'
got tree '/nix/store/0gv5j7p6qp0lqfbci1wqi2ajy6aq4yqz-source' from 'git+file:///mnt/etc/nixos?ref=refs/heads/main&rev=dab1ea8a69201c885e018c5857c48655aad467b7'
evaluating file '/nix/store/0gv5j7p6qp0lqfbci1wqi2ajy6aq4yqz-source/flake.nix'
old lock file: {
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1733951607,
        "narHash": "sha256-CN6q6iCzxI1gkNyk4xLdwaMKi10r7n+aJkRzWj8PXwQ=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "6e5b2d9e8014b5572e3367937a329e7053458d34",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1733759999,
        "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}
computing lock file node ''
computing input 'home-manager'
keeping existing input 'home-manager'
computing lock file node 'home-manager'
computing input 'home-manager/nixpkgs'
input 'home-manager/nixpkgs' follows 'nixpkgs'
computing input 'nixpkgs'
keeping existing input 'nixpkgs'
computing lock file node 'nixpkgs'
new lock file: {
  "nodes": {
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1733951607,
        "narHash": "sha256-CN6q6iCzxI1gkNyk4xLdwaMKi10r7n+aJkRzWj8PXwQ=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "6e5b2d9e8014b5572e3367937a329e7053458d34",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1733759999,
        "narHash": "sha256-463SNPWmz46iLzJKRzO3Q2b0Aurff3U1n0nYItxq7jU=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "a73246e2eef4c6ed172979932bc80e1404ba2d56",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-unstable",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "home-manager": "home-manager",
        "nixpkgs": "nixpkgs"
      }
    }
  },
  "root": "root",
  "version": 7
}
trying flake output attribute 'packages.x86_64-linux.shuixing'
using cached attrset attribute ''
trying flake output attribute 'legacyPackages.x86_64-linux.shuixing'
using cached attrset attribute ''
trying flake output attribute 'shuixing'
using cached attrset attribute ''
error: flake 'git+file:///mnt/etc/nixos' does not provide attribute 'packages.x86_64-linux.shuixing', 'legacyPackages.x86_64-linux.shuixing' or 'shuixing'

what should i do?

nix build .#nixosConfigurations.configname.config.system.build.toplevel is the attrname for a nixos configuration. This is known implicitly by nixos-rebuild but it’s not the default attrname for nix build.

thanks, i knew it was a stupid question with a simple answer

Questions are only stupid if you don’t pay attention to the answers :slight_smile: Happy to help.

1 Like