All checks were successful
build configuration / build_web02 (push) Successful in 1m2s
build configuration / build_vault01 (push) Successful in 1m6s
build configuration / build_storage01 (push) Successful in 1m6s
build configuration / build_compute01 (push) Successful in 1m11s
lint / check (push) Successful in 24s
build configuration / build_web01 (push) Successful in 1m30s
build configuration / build_rescue01 (push) Successful in 56s
build configuration / push_to_cache (push) Successful in 2m13s
65 lines
1.3 KiB
Nix
65 lines
1.3 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
inherit (lib) mkOption;
|
|
|
|
inherit (lib.types) attrsOf listOf str;
|
|
|
|
mkRetired =
|
|
hosts:
|
|
builtins.listToAttrs (
|
|
builtins.map (name: {
|
|
inherit name;
|
|
value = {
|
|
enableACME = true;
|
|
forceSSL = true;
|
|
locations."/".return = "301 https://${cfg.retiredHost}/${name}";
|
|
};
|
|
}) hosts
|
|
);
|
|
|
|
mkRedirection = _: globalRedirect: {
|
|
inherit globalRedirect;
|
|
|
|
enableACME = true;
|
|
forceSSL = true;
|
|
};
|
|
|
|
cfg = config.dgn-redirections;
|
|
in
|
|
|
|
{
|
|
options.dgn-redirections = {
|
|
redirections = mkOption {
|
|
type = attrsOf str;
|
|
default = { };
|
|
description = ''
|
|
Attribute set of redirections, for:
|
|
{ a = b; },
|
|
a redirection from a to b will be made.
|
|
'';
|
|
};
|
|
|
|
retired = mkOption {
|
|
type = listOf str;
|
|
default = [ ];
|
|
description = ''
|
|
List of retired domains, they will we redirected to `retired.dgnum.eu/$host`.
|
|
'';
|
|
};
|
|
|
|
retiredHost = mkOption {
|
|
type = str;
|
|
default = "retired.dgnum.eu";
|
|
description = ''
|
|
Host used for the redirections of retired services.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = {
|
|
services.nginx.virtualHosts =
|
|
(builtins.mapAttrs mkRedirection cfg.redirections) // (mkRetired cfg.retired);
|
|
};
|
|
}
|