aboutsummaryrefslogtreecommitdiff
path: root/modules/system/sysops.nix
blob: ccf6d0b97df825407db020663ccb26c746d2e11c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, lib, ...}:
let

  inherit (lib) concatMapStringsSep concatStringsSep mkOption types;
  inherit (types) str listOf;

  bindir = "/run/current-system/sw/bin";

  commands = concatStringsSep ", " (
    [
      "${bindir}/du *"
      "${bindir}/iftop"
      "${bindir}/iotop"
      "${bindir}/ip6tables -L*"
      "${bindir}/ipsec *"
      "${bindir}/iptables -L*"
      "${bindir}/journalctl *"
      "${bindir}/lsof *"
      "${bindir}/mtr *"
      "${bindir}/nix-collect-garbage *"
      "${bindir}/nmap *"
      "${bindir}/tcpdump *"
      "${bindir}/traceroute *"
    ] ++ map (c: "${bindir}/systemctl ${c} *")
        [ "kill" "reload" "restart" "start" "status" "stop" ]
  );

in {

  config = {
    security.sudo.extraConfig = ''
      %wheel ALL=(ALL) NOPASSWD: ${commands}
    '';
  };
}