Commit b9423822 authored by nicoo's avatar nicoo
Browse files

nixos/sudo: refactor processing of `cfg.extraRules`

parent 1852b67b
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -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) [
      (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)
            ]
          ) cfg.extraRules
        )
      ) + "\n")
        ]))
        flatten
        (concatStringsSep "\n")
      ])
      "\n"
      (optionalString (cfg.extraConfig != "") ''
        # extraConfig
        ${cfg.extraConfig}