Dealing with customizations in default configuration.nix

I’m just curious here.

I’ve installed nixOS on my laptop via the iso. I had a look at the resulting configuration.nix, and it has a bunch of config around the disks, etc that are specific to that particular install.

What’s the best way to abstract out the specific config to the installation, and my custom config that I want to add to git?

Leave the default box file and then just import anything I do custom (ensuring I don’t duplicate anything in my custom files)?

I’m just trying to decide how to automate my next “re-install”.

I tried feeding in a custom written set of nix files doing an older style install (/mnt, etc), but I was missing a lot of the disk config, and the laptop took a long time to boot. Suggestions?

Thanks all.

Most people seem to gravitate toward having their customization in “common” .nix files, which are then imported by host-specific configs which contain the filesystem uuids and all that. Usually those are also committed to the git repo, however.

Installing on a new host is then mostly a matter of writing new hardware-specific config stuff, and importing (and perhaps enabling) the appropriate modules for their cross-host customization.

1 Like

Thanks for that! I was considering something close to this.

  • Install via GUI ISO installer
  • leave all defaults in there, except for adding an import to something like init.nix
  • then init.nix would import all of my various *.nix files (allows me to have to add a single import on a fresh install)

I am now trying to determine how far to go down this or if I should investigate home-manager first. :slightly_smiling_face:

I am setting up my first laptop (to completion), and I am deciding between just building via configuration.nix, flakes, and/or home-manager. All “seem” (still learning) to have some overlap and approach things in different ways.

Thanks!