I want to compose my configuration files so that my multiple machines can re-use the configuration I set up with code duplication.
What I’m imagining:
base.nix – sets up everything shared by all my computers
desktop-environment.nix – sets up what my standard desktop environment is
<machine_name>.nix – inherits from base.nix and desktop-environment.nix
The thing is, I want to define my user in base.nix, and then add additional groups to the user in my desktop-environment.nix or machine_name.nix files.
I’m new to the nix language and couldn’t figure out how to do this from the nix-pills on the wiki… Does anyone here know where I can find the documentation or an example of this syntax?
I have my configuration files split up very similarly to what you’re describing based on this section of the manual.
My main configuration.nix on each machine imports my hosts/.nix file, which in turn imports the common configuration from common.nix, desktop configuration from desktop.nix for machines I plug into a monitor, etc.
I also use home-manager and would definitely recommend it, but I only use it for setting up dotfiles.