I cloned my config repo into Projects directory in my home directory and have been running nixos-rebuild switch -I nixpkgs=$HOME/Projects/nixpkgs -I nixos-config=$HOME/Projects/nixfiles/hosts/$(hostname)/configuration.nix
.¹
I do not even have /etc/nixos
on my computer, and the nixfiles directory is completely anonymous – I can move it anywhere and, since I actually use relative paths in the rebuild command, I will not even have to change anything.
Some other tools like nixos-option
might require nixos-config
on $NIX_PATH
as well, but I do not use them. I could always just alias nixos-option
to env NIX_PATH=nixos-config=$PWD/... nixos-option
and run it in my anonymous repo if I wanted to.
- Actually, these days I use a simple script but it still does basically the same thing.