summaryrefslogtreecommitdiff
path: root/os/core/security.nix
blob: fa40372b82097bc0594c73038cebb9805c856299 (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
{
  config,
  lib,
  pkgs,
  username,
  ...
}:
let
  cfg = config.os.core.security;
in
{
  options.os.core.security = {
    enable = lib.mkEnableOption "core security services";
    fprint.enable = lib.mkEnableOption "enables fingerprint authentication";
  };
  config = lib.mkIf cfg.enable {
    services = {
      gnome.gnome-keyring.enable = true;
      fprintd = lib.mkIf cfg.fprint.enable {
        enable = true;
        package = pkgs.fprintd-tod;
        tod = {
          enable = true;
          driver = pkgs.libfprint-2-tod1-vfs0090;
        };
      };
    };

    security = {
      doas = {
        enable = true;
        extraRules = [
          {
            users = [ username ];
            keepEnv = true;
            persist = true;
          }
        ];
      };
      sudo.enable = false;

      pam.services = {
        swaylock = { };
        doas.fprintAuth = cfg.fprint.enable;
        login = {
          enableGnomeKeyring = true;
          fprintAuth = cfg.fprint.enable;
        };
      };
      polkit.enable = true;
      rtkit.enable = true;
    };

    environment.systemPackages = with pkgs; [
      doas-sudo-shim
      veracrypt
      bitwarden-desktop
      keepassxc
      git-credential-keepassxc
    ];
  };
}