Help changing configuration location in a reproducible way


I just took the leap an installed NixOS for the appealing
configuration possibilities it offers. For now I don’t quite understand everything (actually quite nothing…) and as a first training, I want to build my system with all my preferred tools and configurations in a way I can reproduce it easily just by cloning a repo and rebuilding from the dotfiles that are inside.

As a lot of peoples on the net, I first thought to symlink a configuration.nix to the /etc/nixos folder in order to keep everything at the same place, but then I read some threads explaining that using the NIX_PATH variable is a cleaner way of doing it.
As this documentation says, I just have to use the nix.nixPath config option to tell nix where is my configuration.
Here is what I wrote:

nix.nixPath = [ "nixos-config=${config.users.users.jm445.home}/.sharedUtils/Nix/dotfiles/configuration.nix" ];

Then I moved my configuration.nix to the right place and rebuilt with sudo nixos-rebuild switch -I nixos-config=./configuration.nix (from the right place) and the build succeed.
Unfortunately now I can’t rebuild anymore because the NIX_PATH of my root user only contains the line I wrote in the config.
What is the right way to replace only the nixos-config part of the NIX_PATH, without changing the rest of it ?


PS: I know I could use flakes to achieve the same thing, but I don’t feel confident enough for now to jump into flakes.

Yeah, the option has a default, but when you assign your own value, then you lose the default…

Since here you also want to override one of the default values, and so you wouldn’t want to take over all of them, I think the best solution is to copy over the other two default values:

nixPath = [