Heya!
I have the following in my configuration.nix
security.sudo = {
enable = true;
extraRules = [{
groups = [ "myuser" ];
commands = [
{
command = "${pkgs.systemd}/bin/systemctl restart my-custom.service";
options = [ "NOPASSWD" ];
}
];
}];
};
However, I noticed that sudo systemctl restart my-custom.service
resulted in me still needing to fill in my password. When I run ssh myuser@server and run whereis systemctl
, I notice that the path is different from the path listed in my sudoers file:
sudo -l
(ALL : ALL) NOPASSWD: /nix/store/3qdyrj8f9wn8xk8965dkg6fgljg9n2my-systemd-255.6/bin/systemctl restart my-custom.service
And whereis systemctl
systemctl: /nix/store/0lvvpl66mnnb3lwvjn6dqv4nn76ky5gx-system-path/bin/systemctl
So I suspect that is where the error lies. Any reason why the paths differ? What is the correct path to reference in my sudo config?