wkd: Init

This commit is contained in:
Simon Bruder 2024-01-27 17:22:53 +01:00
parent 0d9e100d01
commit 9caef40c21
Signed by: simon
GPG key ID: 347FF8699CDA0776
3 changed files with 53 additions and 0 deletions

View file

@ -33,6 +33,9 @@
};
wireguard.home.enable = true;
infovhost.enable = true;
wkd = {
enable = true;
};
};
networking.hostName = "renge";

View file

@ -67,6 +67,7 @@
./udev.nix
./unfree.nix
./wireguard
./wkd
];
config = lib.mkMerge [

49
modules/wkd/default.nix Normal file
View file

@ -0,0 +1,49 @@
# SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{ config, lib, ... }:
let
cfg = config.sbruder.wkd;
toFqdn = domain: "openpgpkey.${domain}";
in
{
options.sbruder.wkd = {
enable = lib.mkEnableOption "Web Key Directory";
domain = lib.mkOption {
type = lib.types.str;
description = "The main domain to listen on. The actual fqdn will be openpgpkey.<domain>.";
default = "sbruder.de";
};
domains = lib.mkOption {
type = lib.types.listOf lib.types.str;
description = "Additional domains to serve.";
default = [ ];
};
};
config = lib.mkIf cfg.enable {
sbruder.static-webserver.vhosts."${toFqdn cfg.domain}" = {
redirects = map toFqdn cfg.domains;
user.name = "wkd";
};
services.nginx.virtualHosts."${toFqdn cfg.domain}" = {
locations."^~ /.well-known/openpgpkey" =
let
# workaround for nginx dropping parent headers
# see https://github.com/yandex/gixy/blob/master/docs/en/plugins/addheaderredefinition.md
parentHeaders = lib.concatStringsSep "\n" (lib.filter
(lib.hasPrefix "add_header ")
(lib.splitString "\n" config.services.nginx.commonHttpConfig));
in
{
extraConfig = ''
${parentHeaders}
add_header Access-Control-Allow-Origin * always;
'';
};
};
};
}