summaryrefslogtreecommitdiffstats
path: root/nixos/modules
diff options
context:
space:
mode:
authornicoo <nicoo@mur.at>2023-10-25 22:24:04 +0000
committernicoo <nicoo@mur.at>2023-11-08 19:41:39 +0000
commitb9423822168bdd885208e5f92bf69d64db30374e (patch)
treeef8d30ea509f08d105e122a1b1965eb34b6ffdd6 /nixos/modules
parent1852b67bc60e34ae6e7d3cba51892668a83e1a1d (diff)
nixos/sudo: refactor processing of `cfg.extraRules`
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/security/sudo.nix20
1 files changed, 10 insertions, 10 deletions
diff --git a/nixos/modules/security/sudo.nix b/nixos/modules/security/sudo.nix
index 03f38b543d66..4e4f186758e9 100644
--- a/nixos/modules/security/sudo.nix
+++ b/nixos/modules/security/sudo.nix
@@ -218,16 +218,16 @@ in
# Don't edit this file. Set the NixOS options ‘security.sudo.configFile’
# or ‘security.sudo.extraRules’ instead.
''
- (concatStringsSep "\n" (
- lists.flatten (
- map (
- rule: optionals (length rule.commands != 0) [
- (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
- (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
- ]
- ) cfg.extraRules
- )
- ) + "\n")
+ (pipe cfg.extraRules [
+ (filter (rule: length rule.commands != 0))
+ (map (rule: [
+ (map (user: "${toUserString user} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.users)
+ (map (group: "${toGroupString group} ${rule.host}=(${rule.runAs}) ${toCommandsString rule.commands}") rule.groups)
+ ]))
+ flatten
+ (concatStringsSep "\n")
+ ])
+ "\n"
(optionalString (cfg.extraConfig != "") ''
# extraConfig
${cfg.extraConfig}