This removed the surplus paths and all Paths that i require showed up when entering echo $PATH. However, it somehow screwed up sudo. It showed the following error:
sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set
Commenting out the added entries in config.fish didn’t solve the problem so i reinstalled Nixos. However, upon reapplying my configuration.nix with nixos-rebuild-switch i have the same errors again. I did nothing other than reapply my configuration.nix and set the /home directory to its original partition with all my files and .config etc.
So it seems that my changes to config.fish introduced this error and it persists even after removing the added entries.
Checking the owner of sudo: /run/current-system/sw/bin/sudo yields
All setuid and setgid executables need to be configured with wrappers due to how the nix store works, these wrappers are enabled trough the module system. You’ve clearly added sudo to your environment.systemPackages, and for whatever reason that is now selected over the wrapper in /run/wrappers/bin when you execute sudo in your shell.
The fix here is to not add sudo (or any other setuid application) to your systemPackages and use the module instead.
Edit: just saw your edit, you probably want to enable programs.fish, your base PATH should look something like: /run/wrappers/bin /home/r/.nix-profile/bin /etc/profiles/per-user/r/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin
That’s clearly your problem right there, you must have had some lingering state from the commented out lines that I assumed you called* at some point. Fish has this concept of universal variables that linger between shells, maybe fish_add_path modifies those? I’m not really sure.
~/.config/fish/fish_variables is correct but simply removing the file makes fish display an error. Deleting ~/.config/fish leads to sudo being executed correctly in fish again, so i’ll start from there.
If i had thought to simply try executing sudo in bash i would have saved me the reinstallation of Nixos to try to fix things…