summaryrefslogtreecommitdiff
path: root/os/core/security.nix
blob: f69ab1f58a6efe0bd492fe71d9b1015635b61c01 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
  config,
  lib,
  pkgs,
  username,
  ...
}:
let
  cfg = config.os.core.security;
in
{
  options.os.core.security = {
    enable = lib.mkEnableOption "core security services";
    antivirus.enable = lib.mkEnableOption "enables clamav antivirus";
    sandboxing.enable = lib.mkEnableOption "enables sandboxing stuff";
  };
  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        security = {
          polkit.enable = true;
          rtkit.enable = true;
          doas = {
            enable = true;
            extraRules = [
              {
                users = [ username ];
                keepEnv = true;
                persist = true;
              }
            ];
          };
          sudo.enable = false;
          pam.services = {
            swaylock = { };
            login.enableGnomeKeyring = true;
          };
        };
        environment.systemPackages = [ pkgs.doas-sudo-shim ];
      }
      (lib.mkIf cfg.sandboxing.enable {
        security.apparmor = {
          enable = true;
          enableCache = true;
          killUnconfinedConfinables = true;
          packages = with pkgs; [
            apparmor-profiles
            roddhjav-apparmor-rules
          ];
        };
        services.dbus.apparmor = "enabled";
        specialisation.no-apparmor.configuration.security.apparmor.enable = lib.mkForce false;

        programs.firejail.enable = true;
        environment.systemPackages = with pkgs; [
          apparmor-utils
          apparmor-parser
          apparmor-bin-utils
        ];
      })
      {
        services.gnome.gnome-keyring.enable = true;

        environment.systemPackages = with pkgs; [
          veracrypt
          gocryptfs
          keepassxc
        ];
      }
    ]
  );
}