@@ -3,44 +3,55 @@
33with lib;
44
55let
6−
76 cfg = config.services.sks;
8−
97 sksPkg = cfg.package;
108
11−in
12−
13−{
9+in {
10+ meta.maintainers = with maintainers; [ primeos calbrecht jcumming ];
1411
1512 options = {
1613
1714 services.sks = {
1815
19− enable = mkEnableOption "sks";
16+ enable = mkEnableOption ''
17+ SKS (synchronizing key server for OpenPGP) and start the database
18+ server. You need to create "''${dataDir}/dump/*.gpg" for the initial
19+ import'';
2020
2121 package = mkOption {
2222 default = pkgs.sks;
2323 defaultText = "pkgs.sks";
2424 type = types.package;
25− description = "
26− Which sks derivation to use.
27− ";
25+ description = "Which SKS derivation to use.";
26+ };
27+
28+ dataDir = mkOption {
29+ type = types.path;
30+ default = "/var/db/sks";
31+ example = "/var/lib/sks";
32+ # TODO: The default might change to "/var/lib/sks" as this is more
33+ # common. There's also https://github.com/NixOS/nixpkgs/issues/26256
34+ # and "/var/db" is not FHS compliant (seems to come from BSD).
35+ description = ''
36+ Data directory (-basedir) for SKS, where the database and all
37+ configuration files are located (e.g. KDB, PTree, membership and
38+ sksconf).
39+ '';
2840 };
2941
3042 hkpAddress = mkOption {
3143 default = [ "127.0.0.1" "::1" ];
3244 type = types.listOf types.str;
33− description = "
34− Wich ip addresses the sks-keyserver is listening on.
35− ";
45+ description = ''
46+ Domain names, IPv4 and/or IPv6 addresses to listen on for HKP
47+ requests.
48+ '';
3649 };
3750
3851 hkpPort = mkOption {
3952 default = 11371;
40− type = types.int;
41− description = "
42− Which port the sks-keyserver is listening on.
43− ";
53+ type = types.ints.u16;
54+ description = "HKP port to listen on.";
4455 };
4556 };
4657 };
@@ -51,7 +62,7 @@ in
5162
5263 users.users.sks = {
5364 createHome = true;
54− home = "/var/db/sks";
65+ home = cfg.dataDir;
5566 isSystemUser = true;
5667 shell = "${pkgs.coreutils}/bin/true";
5768 };
@@ -62,19 +73,21 @@ in
6273 home = config.users.users.sks.home;
6374 user = config.users.users.sks.name;
6475 in {
65− sks-keyserver = {
76+ "sks-db" = {
77+ description = "SKS database server";
78+ after = [ "network.target" ];
6679 wantedBy = [ "multi-user.target" ];
6780 preStart = ''
6881 mkdir -p ${home}/dump
69− ${pkgs.sks}/bin/sks build ${home}/dump/*.gpg -n 10 -cache 100 || true #*/
70− ${pkgs.sks}/bin/sks cleandb || true
71− ${pkgs.sks}/bin/sks pbuild -cache 20 -ptree_cache 70 || true
82+ ${sksPkg}/bin/sks build ${home}/dump/*.gpg -n 10 -cache 100 || true #*/
83+ ${sksPkg}/bin/sks cleandb || true
84+ ${sksPkg}/bin/sks pbuild -cache 20 -ptree_cache 70 || true
7285 '';
7386 serviceConfig = {
7487 WorkingDirectory = home;
7588 User = user;
7689 Restart = "always";
77− ExecStart = "${pkgs.sks}/bin/sks db -hkp_address ${hkpAddress} -hkp_port ${hkpPort}";
90+ ExecStart = "${sksPkg}/bin/sks db -hkp_address ${hkpAddress} -hkp_port ${hkpPort}";
7891 };
7992 };
8093 };