Cannot build home-manager example from NixOS Wiki

The NixOS Wiki page on home-manager has a section Usage as a NixOS module. I like that approach as it it has a self-contained configuration.nix and thus requires no intermediate steps like adding some channel or whatsoever.

I used nixos-generators to test-build the example from the configuration, but fail:

nixos-generate --configuration wiki_config.nix --format lxc
error: attribute 'my_username' missing, at /nix/store/5fqi5xisdp7zi0gzaxc5i30nqkdn3nj3-source/nixos/default.nix:35:27
(use '--show-trace' to show detailed location information)

I couldn’t see anything wrong with the home-manager.users.my_username line. I suspect the example is outdated, can someone confirm this?

Do you also have a users.users.my_username in your system configuration?

1 Like

No, and adding it solved the issue, thank you!