2021-12-19 01:06:50 +00:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.pgpkeyserver-lite;
|
|
|
|
sksCfg = config.services.sks;
|
2021-12-19 01:06:50 +00:00
|
|
|
sksOpt = options.services.sks;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
webPkg = cfg.package;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.pgpkeyserver-lite = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "pgpkeyserver-lite on a nginx vHost proxying to a gpg keyserver");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
default = pkgs.pgpkeyserver-lite;
|
2021-10-06 13:57:05 +00:00
|
|
|
defaultText = literalExpression "pkgs.pgpkeyserver-lite";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.package;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Which webgui derivation to use.
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hostname = mkOption {
|
|
|
|
type = types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Which hostname to set the vHost to that is proxying to sks.
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hkpAddress = mkOption {
|
|
|
|
default = builtins.head sksCfg.hkpAddress;
|
2021-12-19 01:06:50 +00:00
|
|
|
defaultText = literalExpression "head config.${sksOpt.hkpAddress}";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.str;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2022-12-28 21:21:41 +00:00
|
|
|
Which IP address the sks-keyserver is listening on.
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hkpPort = mkOption {
|
|
|
|
default = sksCfg.hkpPort;
|
2021-12-19 01:06:50 +00:00
|
|
|
defaultText = literalExpression "config.${sksOpt.hkpPort}";
|
2020-04-24 23:36:52 +00:00
|
|
|
type = types.int;
|
2022-08-21 13:32:41 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Which port the sks-keyserver is listening on.
|
2022-08-21 13:32:41 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.nginx.enable = true;
|
|
|
|
|
|
|
|
services.nginx.virtualHosts = let
|
|
|
|
hkpPort = builtins.toString cfg.hkpPort;
|
|
|
|
in {
|
|
|
|
${cfg.hostname} = {
|
|
|
|
root = webPkg;
|
|
|
|
locations = {
|
|
|
|
"/pks".extraConfig = ''
|
|
|
|
proxy_pass http://${cfg.hkpAddress}:${hkpPort};
|
|
|
|
proxy_pass_header Server;
|
|
|
|
add_header Via "1.1 ${cfg.hostname}";
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|