I want to reinstall and recreate my system. I have /home files backed up.
The system uses flakes and home manager, and the config files are stored in /home.
Unstable branch.
If I just run the automated installer, boot into the new system, copy over my config file, and rebuild, I will get errors about home manager not being installed etc.
(I know because I tried…)
So what’s the best (or most painless) strategy to get going?
Not the most experienced NixOS user here but I’ve installed NixOS on my machine several times and also have helped move my friends over to NixOS.
TL;DR: I install NixOS with the bare minimum config I need and once I’ve booted into the persistent system, I apply the config I want. It’s safer this way for me since I can always just rollback.
Here’s the approach I follow now:
PS: I don’t use the graphical installer; so my steps may get a little technical.
Once on the bootable media, I launch gparted and partition the way my friends want. A simple scheme I go for is a 1024 MiB fat32 boot partition and the remaining to be the actual usable space.
Second, I mount the “remaining” partition to /mnt and then the boot partition to /mnt/boot.
Third, I run sudo nixos-generate-config --root /mnt which creates two files (config and hardware config)
Now, I edit these files to configure some basic things like:
Creating a user
Setting a hostname
Making sure I install a browser and a text editor
Once done and saved, I run sudo nixos-install --root /mnt and then wait.
Reboot into your new system.
Doing it this way means I have to apply my personal config later but it gives me that 1st persistent generation to fallback on since otherwise I’d have to redo the entire thing all over.
Are you using the home-manager nixos module in your flake’s systemConfiguration? When you change your home-manager configuration do you use nixos-rebuild or home-manager switch?
Unsure what nix-snapd is, but shouldn’t that home manager config be within home-manager.nixosModules.home-manager instead of nix-snapd.nixosModules.default?
When I install on a new computer I haven’t used yet I usually start with the base configuration from the live image and integrate the hardware modifications into my flake.
If I’m reinstalling I partition the disk, mount the necessary partitions in /mnt and run nix-shell -p git sudo nixos-install --flake "https://url-to-my-flake#system-name directly from the live CD. The nix-shell -p git part is because IIRC git is not installed by default on the live image and I cannot install some flake deps without it. I documented this in my flake’s readme: steinuil/flakes - flakes - mani mani
If you have a spare system with Nix installed, you can try cding into your flake directory, run nix repl, then :lf . and then :b nixosConfigurations.your-system.build.toplevel to see if your system configuration builds correctly outside of the live CD.
Nope, those config options go into the nixos configuration, so they’re fine there!