You may find complex nixos configurations on the Internet. I try to keep mine simple for 2 reasons:
- I still do not know what I am doing with nix 😜
- My use case is simple: I want to be able to setup a new machine as quick as possible on hardware crash.
home-manager is of course used to deal with user dot files. However, as it also enables to install software on a per-user basis, I found this approach useful for me: I can add a user for a family member or friend with a controlled list of apps. For example, my sons do not care (yet) about programming. Why then exposing them a useless code editor?
- Modules located in
./modules/homeare home-manager ones. - Modules located in
./modules/systemare system-wide nixos ones. - Modules located in
./hardware/scannedare a verbatim copy of hardware scan during nixos installation. - Modules located in
./hardwareare the ones configuring the hardware (bootloader, audio, etc...)
- To rebuild and switch to the new generation:
sudo nixos-rebuild switch --flake .#default(rebooting will be changes) - To rebuild and test live:
sudo nixos-rebuild test --flake .#default(rebooting will discard changes) - To test in a virtual machine:
./test-vm.sh
- run the nixos installer on the
<new-machine>(create your account,peioin my case) - import your SSH and GPG keys (known by github)
git clonethis repository- copy
/etc/nixos/hardware-configuration.nix(generated by the nixos installer) to<repo>/hardware/scanned/machines/<new-machine>.nix - change
flake.nixentries to use the<new-machine>(such as:machine = "framework13";) sudo nixos-rebuild test --flake .#default