2021-12-05 21:36:38 +00:00
|
|
|
{ config, lib, options, pkgs, ... }:
|
2017-08-22 10:27:00 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.pgpkeyserver-lite;
|
|
|
|
sksCfg = config.services.sks;
|
2021-12-05 21:36:38 +00:00
|
|
|
sksOpt = options.services.sks;
|
2017-08-22 10:27:00 +00:00
|
|
|
|
|
|
|
webPkg = cfg.package;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.pgpkeyserver-lite = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "pgpkeyserver-lite on a nginx vHost proxying to a gpg keyserver";
|
|
|
|
|
2023-11-27 00:19:27 +00:00
|
|
|
package = mkPackageOption pkgs "pgpkeyserver-lite" { };
|
2017-08-22 10:27:00 +00:00
|
|
|
|
|
|
|
hostname = mkOption {
|
|
|
|
type = types.str;
|
2022-08-14 03:16:55 +00:00
|
|
|
description = ''
|
2017-08-22 10:27:00 +00:00
|
|
|
Which hostname to set the vHost to that is proxying to sks.
|
2022-08-14 03:16:55 +00:00
|
|
|
'';
|
2020-08-07 13:43:58 +00:00
|
|
|
};
|
2017-08-22 10:27:00 +00:00
|
|
|
|
|
|
|
hkpAddress = mkOption {
|
|
|
|
default = builtins.head sksCfg.hkpAddress;
|
2021-12-05 21:36:38 +00:00
|
|
|
defaultText = literalExpression "head config.${sksOpt.hkpAddress}";
|
2017-08-22 10:27:00 +00:00
|
|
|
type = types.str;
|
2022-08-14 03:16:55 +00:00
|
|
|
description = ''
|
2022-12-18 16:35:23 +00:00
|
|
|
Which IP address the sks-keyserver is listening on.
|
2022-08-14 03:16:55 +00:00
|
|
|
'';
|
2017-08-22 10:27:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
hkpPort = mkOption {
|
|
|
|
default = sksCfg.hkpPort;
|
2021-12-05 21:36:38 +00:00
|
|
|
defaultText = literalExpression "config.${sksOpt.hkpPort}";
|
2017-08-22 10:27:00 +00:00
|
|
|
type = types.int;
|
2022-08-14 03:16:55 +00:00
|
|
|
description = ''
|
2017-08-22 10:27:00 +00:00
|
|
|
Which port the sks-keyserver is listening on.
|
2022-08-14 03:16:55 +00:00
|
|
|
'';
|
2017-08-22 10:27:00 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
services.nginx.enable = true;
|
|
|
|
|
|
|
|
services.nginx.virtualHosts = let
|
|
|
|
hkpPort = builtins.toString cfg.hkpPort;
|
|
|
|
in {
|
2019-08-13 21:52:01 +00:00
|
|
|
${cfg.hostname} = {
|
2017-08-22 10:27:00 +00:00
|
|
|
root = webPkg;
|
|
|
|
locations = {
|
|
|
|
"/pks".extraConfig = ''
|
|
|
|
proxy_pass http://${cfg.hkpAddress}:${hkpPort};
|
|
|
|
proxy_pass_header Server;
|
|
|
|
add_header Via "1.1 ${cfg.hostname}";
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|