Hi, I’m trying to modularize my NixOS configuration. I use Home Manager with flakes and have incorporated it into flakes like in the documentation. and it throws an error for every single module I have in the system.
# configuration.nix
{ config, lib, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
(whole bunch of random stuff)
nix.settings.experimental-features = [ "nix-command" "flakes" ];
system.stateVersion = "24.11";
}
# flake.nix
{
description = "nix flake (hopefully i dont lose my sanity configuring all this)";
# system inputs
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ nixpkgs, home-manager, ... }: {
nixosConfigurations = {
sproink-nix = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./hosts/desktop/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.sproink = import ./hosts/desktop/home.nix;
}
];
};
};
# modules location for all the apps. DO NOT CHANGE.
homeManagerModules.default = ./modules;
};
}
We need a lot more info, like what command are you running, what is the full error, what’s in your config?
Also, if the errors are related to those modules you have in ./modules, did you import those into your config anywhere? Does ./modules/default.nix exist, and what does it contain?
I used sudo nixos-rebuild switch and the full error is this:
error: The option `home-manager.users.sproink.(module)' does not exist. Definition values:
- In `/nix/store/wshnc0kqk1qz7iffb1yqri8a5cy6v7w5-source/flake.nix':
{
enable = true;
}
./modules/default.nix does exist, and I have just imported every single module’s nix file in it.
Great, but where in your config do you import this file?
I’m guessing you forgot to do so as I implied in my first comment, and that’s why you have the error.
(Setting homeManagerModules in your flake does not count as importing; that’s not going to automatically make it part of your HM config.)
If you import a directory, nix will look for a default.nix in that directory.
But again, I don’t see where you imported modules or modules/default.nix in your config.
# configuration.nix
{ config, lib, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
./../../modules
];
# ...
system.stateVersion = "24.11"; # Did you read the comment?
}
I’ve imported the modules folder into both configuration.nix and home.nix. It still throws the same error after rebuilding with sudo nixos-rebuild switch.
Then, as requested by about 4 different people, we need a minimal example that demonstrates the issue, i.e. something that we can build and get the same error as you, because we’re not seeing the full picture.
I’ve created 2 folders for HM modules and system modules and imported both of them into flake.nix, and I have a home-manager.nix file in the folder for system modules for the configuration of HM. I now get a different error saying
error:
… while calling the 'seq' builtin
at /nix/store/wshnc0kqk1qz7iffb1yqri8a5cy6v7w5-source/lib/modules.nix:334:18:
333| options = checked options;
334| config = checked (removeAttrs config [ "_module" ]);
| ^
335| _module = checked (config._module);
… while calling the 'throw' builtin
at /nix/store/wshnc0kqk1qz7iffb1yqri8a5cy6v7w5-source/lib/modules.nix:310:18:
309| ''
310| else throw baseMsg
| ^
311| else null;
error: The option `home-manager' does not exist. Definition values:
- In `/nix/store/w758824abw4miy4hg1m0hdccv0xd8iwf-source/nixosModules/home-manager.nix'
I’m guessing you didn’t import the nixos module that adds the HM options.
But again, I’m guessing, because you haven’t shared a complete example config (or the actual config) as we asked.
I’ll have to leave this thread until you’re willing to provide that.
I’ll leave the remaining “The option … does not exist” to you or another thread. As thats a mixture of hallucinating options and missing programs.* or services.* “prefixes”.
edit
Using the following for nixosModules/home-manager.nix is slightly more idiomatic: