Flake error when trying to build the system: packages.x86_64-linux.nixosConfigurations.”nixos”.config.system.build.nixos-rebuild’


Hi, I ran into an error while trying to build my system using flakes.

System info:

➜  configFiles nix --version
nix (Nix) 2.24.14

Command:

sudo nixos-rebuild switch --flake ./

Output:

warning: creating lock file '/home/yakatze/configFiles/flake.lock':
• Added input 'home-manager':
    'github:nix-community/home-manager/...'
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/...'
• Added input 'nixpkgs-unstable':
    'github:NixOS/nixpkgs/...'

error: flake 'path:/home/yakatze/configFiles' does not provide attribute 
'packages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild', 
'legacyPackages.x86_64-linux.nixosConfigurations."nixos".config.system.build.nixos-rebuild' 
or 'nixosConfigurations."nixos".config.system.build.nixos-rebuild'

flake.nix:

{
  description = "tlater's dotfiles";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";

    home-manager = {
      url = "github:nix-community/home-manager/release-24.11";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, home-manager, ... }@inputs: {
    nixosConfigurations = {
      yui = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        config.allowUnfree = true;
        modules = [
          ./nix
          ./nix/hosts/yui
        ];
      };
    };

    modules = [
      ./nix/configuration.nix
    ];

    homeConfigurations.yakatze = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages."x86_64-linux";
      modules = [ ./home/home.nix ];
    };
  };
}

What I’ve figured out:

It seems the error occurs because I didn’t define a configuration named "nixos", which is expected by nixos-rebuild by default. However, in my flake.nix, the hostname is yui.

So I tried running:

sudo nixos-rebuild switch --flake .#yui

New error:

error: function 'anonymous lambda' called with unexpected argument 'config'
at /nix/store/5xjf9ba5zliwl3ppczws0xqmlgji3y7l-source/nixos/lib/eval-config.nix:11:1:
    10| # types.submodule instead of using eval-config.nix
    11| evalConfigArgs@{
      | ^
    12|   # !!! system can be set modularly, would be nice to remove,

Please help me understand what’s wrong with my flake.nix.
I’d really appreciate any advice or corrections. Thanks!


What’s your nix version? (nix --version)

(nix --version)
nix (Nix) 2.24.14

nixos-rebuild switch --flake ./

Looks up the attribute to deploy based on the machine’s current hostname, which appears to be “nixos”. If you want to deploy “yui” instead, then explicitly pass:

nixos-rebuild switch --flake .#yui

New error:

error: function 'anonymous lambda' called with unexpected argument 'config'
at /nix/store/5xjf9ba5zliwl3ppczws0xqmlgji3y7l-source/nixos/lib/eval-config.nix:11:1:
    10| # types.submodule instead of using eval-config.nix
    11| evalConfigArgs@{
      | ^
    12|   # !!! system can be set modularly, would be nice to remove,

This might be due to ./nix/default.nix or ./nix/hosts/yui/default.nix not being structured as NixOS modules. The

modules = [
      ./nix/configuration.nix
    ];

also looks not correct and should be part of the modules inside your yui config.

This way?

outputs =
    { nixpkgs, home-manager, ... }@inputs :
    {
      nixosConfigurations = {
        yui = nixpkgs.lib.nixosSystem {
          system = "x86_64-linux";
          config.allowUnfree = true;
          modules = [
            ./nix/configuration.nix
            ./nix/hosts/yui
          ];
        };
      };

    homeConfigurations.yakatze = home-manager.lib.homeManagerConfiguration {
      pkgs = nixpkgs.legacyPackages."x86_64-linux";
      modules = [ ./home/home.nix ];
    };

    };

}
         yui = nixpkgs.lib.nixosSystem {
           system = "x86_64-linux";
-          config.allowUnfree = true;
           modules = [
+            { nixpkgs.config.allowUnfree = true; }
             ./nix/configuration.nix
             ./nix/hosts/yui
           ];
         };
1 Like

Looks like I haven’t set up the host properly. Could you please show me how it’s supposed to look?

error: opening file ‘/nix/store/7c18a36jas65z7ih3cyn9cisb92br6bn-source/nix/hosts/yui/default.nix’: No such file or directory

You have ./nix/hosts/yui in your modules list which means you need to create a module at nix/hosts/yui/default.nix and make sure it’s git-added if you’re in a git repo.

1 Like

What should the configuration in the default.nix file look like?

I don’t know, you wanted the module right? It’s up to you.
It just needs to follow the standard module structure.

I’m still new to this and don’t fully understand everything yet. Is there a way to make it work without setting up a host name—like just using nixosConfigurations.nixos? I just want to get my flake.nix to run successfully for now.

The hostname is nixos by default.
If you want things to just work, use the guide here: flake-migration/nixos.md at d9e00d26de6fbf4aaf2ced29ea95542c3a795525 · eclairevoyant/flake-migration · GitHub

There’s no prescriptive way to write your modules as long as they’re syntactically correct, it’s up to you how to structure your code.

1 Like

Thank you for the guide — I really appreciate it! Everything is working now, my flake.nix finally runs successfully. However, I ran into another issue, this time with home-manager.

➜  home-manager switch --flake .
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it