nixos-config/modules/infovhost.nix

39 lines
1,004 B
Nix
Raw Permalink Normal View History

# SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{ config, lib, pkgs, ... }:
let
cfg = config.sbruder.infovhost;
in
{
options.sbruder.infovhost = {
enable = lib.mkEnableOption "a vhost displaying legal and/or technical information on the domain of the machine";
domain = lib.mkOption {
type = lib.types.str;
default =
if (!(isNull config.networking.domain))
then config.networking.domain
else "sbruder.de";
description = "The domain part of the fqdn.";
};
fqdn = lib.mkOption {
type = lib.types.str;
default = "${config.networking.hostName}.${cfg.domain}";
description = "The fqdn the vhost should listen on.";
};
};
config = lib.mkIf cfg.enable {
services.nginx.enable = true;
services.nginx.virtualHosts."${cfg.fqdn}" = {
enableACME = true;
forceSSL = true;
default = true;
root = pkgs.sbruder.imprint;
};
};
}