this post was submitted on 01 Aug 2023
10 points (100.0% liked)

Nix / NixOS

1465 readers
43 users here now

Main links

Videos

founded 1 year ago
MODERATORS
 

Hi, I just started with Nixos a week ago, I have a problem configuring the system. I apologize for this long post. I want to configure configuration.nix for sudo to run commands without passwd. I am confused about the path of the packages. I tried entering path returned by $ which cryptsetup like

security.sudo = {
       enable = true;
       configFile = ''
         %sudo ALL = (root) NOPASSWD: /run/current-system/sw/bin/cryptsetup
         %sudo ALL = (root) NOPASSWD: /run/current-system/sw/bin/lvs
       '';
  };

and as shown in nixos wiki like the following

security.sudo = {
  enable = true;
  extraRules = [{
    commands = [
      {
        command = "${pkgs.systemd}/bin/cryptsetup";
        options = [ "NOPASSWD" ];
      }
    ];
    groups = [ "wheel" ];
  }];
};

I don't get any errors on nixos-rebuild test/switch but I can't get it to work. I'll appreciate if you can help me understand this. Thanks in advance

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 year ago (1 children)

thanks, but I don't wanna disable sudo password. I only want certain commands to be accessible without password.