Generally define the same config options for the root user in /root/.config
Nix / NixOS
Main links
Videos
I run commands as the root user so I use the root users configs. Usually that's in /root/.config/ but it might be different in NixOS.
You'll have to either copy your configs over to the root users config dirs. I highly recommend auditing what you copy though for security.
It's because sudo runs as root, so it's looking for /root/.config You can use -E to keep your current users environment vars, but that doesn't do anything with ~/.config
You can try something like
sudo -E HOME="$HOME" XDG_CONFIG_HOME="$XDG_CONFIG_HOME" command_to_run
Or see if you can manually set the config path via args for the command
command_to_run --help or man command_to_run then if it does do
sudo command_to_run --config_path /home/user/.config for example
Or copy ~/.config to /root (don't simlink because root could screw up permissions). Obviously copying is annoying especially if it changes often
Thanks for the heads up! I will try the given solutions.
but that doesn't do anything with ~/.config What do you exactly mean by this?
A lot of times sudo -E will solve these types of issues because it preserves current environments variables. Honestly it might be all that's needed to fix your current issue. I was just mentioning it so you know for the future.
I meant that it might not work because there's probably not an environment variable directly for .config. however if the program is coded to look at $HOME/.config then the -E would solve the problem.
The letter ~ (tilde) is relative to the current user. When you use sudo, you become root. So ~ points to /root. Whereas if you are not using sudo then ~ points to /home/yourname