22
0
mirror of https://github.com/SuperSandro2000/nixos-modules.git synced 2024-06-11 18:54:06 +02:00

portunus: add option to create hosts entries

This commit is contained in:
Sandro - 2022-12-22 21:58:24 +01:00
parent 1f173f875c
commit 2fa64e5ee1
Signed by: sandro
GPG Key ID: 3AF5A43A3EECC2E5

32
modules/portunus.nix Normal file
View File

@ -0,0 +1,32 @@
{ config, lib, ... }:
let
cfg = config.services.portunus;
in
{
options.services.portunus = {
externalIp4 = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = lib.mdDoc "Internal IPv4 of portunus instance. This is used in the addToHosts option.";
};
externalIp6 = lib.mkOption {
type = with lib.types; nullOr str;
default = null;
description = lib.mdDoc "Internal IPv6 of portunus instance. This is used in the addToHosts option.";
};
addToHosts = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "Wether to add a hosts entry for the portunus domain pointing to externalIp";
};
};
config = lib.mkIf config.services.portunus.addToHosts {
networking.hosts = {
${cfg.externalIp4} = [ cfg.domain ];
${cfg.externalIp6} = [ cfg.domain ];
};
}