Files
nixos/hosts/common/optional/selfhosted/netbird/proxy/default.nix
T
aloslider c92b90e406 Small modules config restructure
Changed variables names in every module
2026-10-31 19:48:50 +03:00

56 lines
1.6 KiB
Nix

{ config, lib, ... }:
with lib;
let
rootCfg = config.selfhosted;
common = rootCfg.common;
moduleCfg = rootCfg.netbird;
cfg = moduleCfg.proxy;
hostDataPath = "${common.dataDir}/netbird/proxy";
in
{
imports = [ ./config.nix ];
options.selfhosted.netbird.proxy = {
name = mkOption {
type = types.str;
};
};
config = mkIf moduleCfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
image = "docker.io/netbirdio/reverse-proxy:0.81.3";
environmentFiles = [ config.sops.templates."nb-proxy.env".path ];
volumes = [
"${hostDataPath}/certs:/certs:rw"
];
ports = [
"0.0.0.0:2222:2222/tcp" # gitea
"0.0.0.0:7359:7359/udp" # jelly
"0.0.0.0:51820:51820/udp" # netbird stunt
# "0.0.0.0:9090:9090/tcp" # mihomo controller
];
dependsOn = [ moduleCfg.server.name ];
log-driver = "journald";
extraOptions = [
"--network-alias=${cfg.name}"
"--network=${common.network.name}"
];
};
systemd.services."${common.backend}-${cfg.name}" = {
serviceConfig = {
Restart = lib.mkOverride 90 "always";
};
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
requires = [ "${common.backend}-${moduleCfg.server.name}.service" ];
after = [ "${common.backend}-${moduleCfg.server.name}.service" ];
preStart = ''
mkdir -p ${hostDataPath}/certs
chown -R ${common.user.uid}:${common.group.gid} ${hostDataPath}
chmod -R 0755 ${hostDataPath}
'';
};
};
}