aboutsummaryrefslogtreecommitdiffstats
path: root/modules/security/gpg/default.nix
blob: 472270b8dce9f46dc529ea77489457ee85cbc508 (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
# GNU Privacy Guard
{
  config,
  lib,
  pkgs,
  ...
}:
{
  options.security.gpg = {
    enable = lib.mkEnableOption "Enables gpg.";

    package = lib.mkOption {
      type = lib.types.package;
      default = config.programs.gpg.package;
      readOnly = true;
      defaultText = lib.literalExpression "config.programs.gpg.package";
      description = "The gpg package to use.";
    };
  };

  config = lib.mkIf config.security.gpg.enable {
    programs.gpg = {
      enable = true;
      homedir = "${config.xdg.dataHome}/gnupg";
    };

    home.sessionVariables = {
      GNUPGHOME = config.programs.gpg.homedir;
    };

    services.gpg-agent = {
      enable = true;
      enableZshIntegration = true;
      defaultCacheTtl = 3600;
      maxCacheTtl = 86400;
      enableSshSupport = config.security.ssh.enable;
      pinentry.package = pkgs.pinentry-rofi;
    };
  };
}