about summary refs log tree commit diff stats
path: root/hm/soispha/conf/gpg/default.nix
blob: 4926e55b236a1814a15d69e8769dc1041194a9ea (plain) (blame)
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
{
  config,
  nixosConfig,
  sysLib,
  pkgs,
  nixpkgs_open_prs,
  system,
  ...
}: let
  pkgs_onlykey = nixpkgs_open_prs.nixpkgs-onlykey.legacyPackages."${system}";
  agent-program = sysLib.writeShellScript {
    name = "onlykey-gpg-agent";
    src = ./agent-program.sh;
    dependencies = [
      pkgs.python3
      pkgs_onlykey.onlykey-agent
    ];
  };

  settings =
    if nixosConfig.networking.hostName == "isimud"
    then {}
    else {
      # Hardware-based GPG configuration
      agent-program = "${agent-program}/bin/onlykey-gpg-agent";

      default-key = "Soispha <soispha@vhack.eu>";
      # TODO: add more
    };
  gpg-agent = {
    enable = nixosConfig.networking.hostName == "isimud";
    enableZshIntegration = true;
    enableScDaemon = true; # smartcards and such things
    pinentryPackage = pkgs.pinentry-tty;
  };
in {
  programs.gpg = {
    enable = true;
    homedir = "${config.xdg.dataHome}/gnupg/onlykey";
    mutableKeys = false;
    mutableTrust = false;
    inherit settings;
    publicKeys = [
      {
        source = ./keys/key_1;
        trust = "ultimate";
      }
      {
        source = ./keys/key_2;
        trust = "ultimate";
      }
      {
        source = ./keys/key_3;
        trust = "full";
      }
      {
        source = ./keys/key_4;
        trust = "full";
      }
    ];
  };
  services = {
    inherit gpg-agent;
  };
}