modules: improve settings to configure nopasswd commands
This commit is contained in:
parent
390f54b1f5
commit
a501f2ea16
6 changed files with 43 additions and 10 deletions
|
@ -36,14 +36,4 @@
|
|||
local.programs.pass.enable = lib.mkDefault true;
|
||||
|
||||
local.programs.browsers.librewolf.enable = lib.mkDefault true;
|
||||
|
||||
security.sudo.extraRules = [{
|
||||
commands = [
|
||||
{
|
||||
command = "/run/current-system/sw/bin/nixos-container";
|
||||
options = [ "NOPASSWD" ];
|
||||
}
|
||||
];
|
||||
groups = [ "wheel" ];
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
./fonts.nix
|
||||
./keyboard.nix
|
||||
./nix.nix
|
||||
./security.nix
|
||||
./sound.nix
|
||||
./system.nix
|
||||
./yubikey.nix
|
||||
|
|
36
modules/nixos/configs/security.nix
Normal file
36
modules/nixos/configs/security.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.local.security.sudo;
|
||||
in
|
||||
{
|
||||
options.local.security.sudo = with lib; {
|
||||
nopasswd = mkOption {
|
||||
type = types.listOf (types.submodule {
|
||||
options = {
|
||||
commands = mkOption {
|
||||
type = listOf (types.either types.str types.package);
|
||||
};
|
||||
groups = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ "wheel" ];
|
||||
};
|
||||
};
|
||||
});
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
|
||||
config = cfg.nopasswd != [ ] {
|
||||
security.sudo.extraRules = lib.flip map cfg.nopasswd (rule: {
|
||||
inherit (rule) groups;
|
||||
commands = lib.flip map rule.commands (cmd: [
|
||||
{
|
||||
command = "${cmd}";
|
||||
options = [ "NOPASSWD" ];
|
||||
}
|
||||
]);
|
||||
});
|
||||
};
|
||||
|
||||
}
|
|
@ -39,6 +39,8 @@ in
|
|||
config = lib.mkIf isEnable {
|
||||
environment.systemPackages = hostPackages;
|
||||
|
||||
local.security.sudo.nopasswd = [{ commands = hostPackages; }];
|
||||
|
||||
local.sound.systemWide = true;
|
||||
|
||||
containers.browsers = {
|
||||
|
|
|
@ -27,6 +27,8 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ hostSkype ];
|
||||
|
||||
local.security.sudo.nopasswd = [{ commands = [ hostSkype ]; }];
|
||||
|
||||
local.sound.systemWide = true;
|
||||
|
||||
containers.skype = {
|
||||
|
|
|
@ -27,6 +27,8 @@ in
|
|||
config = lib.mkIf cfg.enable {
|
||||
environment.systemPackages = [ hostTelegram ];
|
||||
|
||||
local.security.sudo.nopasswd = [{ commands = [ hostTelegram ]; }];
|
||||
|
||||
local.sound.systemWide = true;
|
||||
|
||||
containers.telegram = {
|
||||
|
|
Loading…
Reference in a new issue