Kicking off, structure questions with home-manager

Hi there, I have a few questions. I have a working home-manager config using flakes, where the structure jives with my brain. But I had a few questions before I dig on and dev the rest. I have included a link to my repo so that people can see how I have it now.

My path so far was to install via the graphical ISO (gnome), but I I want to figure out what the reinstall path looks like. (some of my below questions will reflect that.)


  • Right now, this code is for my laptop only, but I have a tower I am going to add later. What is the best way to structure or modify my code for multiple hosts?
  • Right now, I have my configuration.nix, and hardware-configuration.nix mostly as the installer wrote them. I have a few system-level tweaks in the configuration.nix.
    • When reinstalling, should I just do so via the graphical ISO, and then drop my files into place after?
    • And how would I abstract the disk configuration (ie disk id’s, etc) for the reinstalls?
    • Or, what is the way to structure the code to account for a reload?
  • Currently, I am just running all of these files out of /etc/nixos, and run sudo nixos-rebuild switch to update everything (well actually from my Makefile). Is there a better or more recommended way? I know some people like to keep home-manager separate, but I prefer the all-in-one approach.
  • Do you still keep your system-wide packages in configuration.nix, or do you abstract it into the files called through home-manager?
  • How would you structure your system-wide settings (ie services, firewall, etc)?

I was considering importing a separate file into configuration.nix that had all my system-wide cfg, so I could just import it after reload.

Any other feedback or suggestions are welcome!! Thanks for your time.


Repo Link

1 Like

There seem to be an infinite ways of going about this - I’ve been looking at the Wiki Configuration Collection

I find many of them difficult to read (I’m still at the start of learning Nix), and so have a more “list of options” approach for the config.

For the flake, I have each machine listed in a very similar manner as you do for your single machine (dustin-krysak). This includes modules such as home manager, and the machines configuration.nix which is in its own folder under /etc/nixos

I also use a “common” folder where I am storing the configs used by all machines. My machines are fairly similar - all use ZFS and I use KDE if there is a desktop, so the common area is useful.

As I use ZFS, I don’t use the graphical install. If your builds are common enough, you could create a script that creates the disk config then installs the system from your config. This is the approach I used this guide: NixOS ZFS

The guide has been updated and includes a sample config. I have tried it, but I find it a really complex (to me) version of what I do. I mention it as it may be a way to abstract your disk config (as I don’t understand it, I’m guessing here). I use the hardware-config output as is for my approach.

I keep system wide (i.e. common to users) in .nix files (common if on all machines, otherwise in a config for the machine).

system-wide settings are in machine specific config.nix files - I am thinking about moving some to my “common” section, but that is not always possible (the “already declared” issue) so I haven’t tried to hard on that yet.

In summary, I’m very much a “list of options” approach. I want to be more programmatical for brevity, but then I lose clarity as I’m not a Nix expert.

I’m sure others will have different approaches which will be interesting to read…

Do you have a repo I could peek at?

Thanks. :+1:

Yes - but be warned they are works in progress and possibly won’t work (and I’m looking at going back to Grub from systemd-boot).

My repositories

1 Like