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