I am trying to add NFS mounts and I seem to be able to configure them initially but subsequent applications error out indicating that the fileSystem.“mountpath” is already defined in hardware.nix. In other words, when I configure this, it applies fine the first time but every time I do a rebuild switch, it errors out. I’m not sure if it’s because of where I’m putting the config or maybe I need an if statement to detect if the path already exists? I’ve been adding it to the network.nix which is below (with the nfs mounts commented out due to the current issue):
I would shy away from recommending strange flake templates like this. For example, passing in host and username as module args doesn’t really make sense, different systems generally wouldn’t share the hostname, and systems have more than one user.
Passing system to lib.nixosSystem is also deprecated, and their structure assumes all the systems have the same architecture. Copy-pasting someone’s bad code ensures that the bad code continues to proliferate.
Can you share your actual code and the full error?
Also keep in mind, you can just edit the hardware.nix…
Thanks for the input. I am not planning on using this long-term but rather as a platform to learn this whole NixOS workflow and minimize my forum spamming. I do plan on a scratch rebuild once I better understand what’s going on and how to do what I need.
I did a bunch more testing and after learning a bit more on how this install script functions as well as better familiarizing myself with Nix, Home-Manager, and Flakes, I have found better ways to update after config changes have been pushed to git. The source of my problem was that I was running the install script to update the config instead of just rebuilding the flake. Sorry for the noob issue.
I’m sure there’s a way to get it to play nice with the install script (when running over the top of an established install) but since the initial install works fine subsequent proper flake/homemanager/nixos rebuilds are fine, I’m calling it good for now. Running the install script does break the NFS mounts though with errors like the following:
activating the configuration...
setting up /etc...
reloading user units for szemlicka...
restarting sysinit-reactivation.target
restarting the following units: mnt-general.mount, mnt-media.mount
Failed to restart mnt-general.mount: Unit mnt-general.mount not found.
Failed to restart mnt-media.mount: Unit mnt-media.mount not found.
the following new units were started: run-credentials-systemd\x2dtmpfiles\x2dresetup.service.mount, sysinit-reactivation.target, systemd-ask-password-console.path, systemd-tmpfiles-resetup.service
warning: error(s) occurred while switching to the new configuration
But I’ll worry about that if I ever find a need to run the install over an established install for some reason or when I do the aforementioned scratch rebuild when I’m comfortable enough to do so.
The complete config I’m using/learning from is:
Thanks for the advice @waffle8946. I’ll work on understanding and applying what you mentioned going forward.