2024-02-02 10:51:31 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
2023-12-17 17:16:53 +01:00
|
|
|
imports = [ ./secrets ];
|
|
|
|
|
|
|
|
services = {
|
|
|
|
netbox = {
|
|
|
|
enable = true;
|
|
|
|
secretKeyFile = config.age.secrets."netbox".path;
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
settings = {
|
|
|
|
ALLOWED_HOSTS = [ "netbox.dgnum.sinavir.fr" ];
|
2024-02-02 10:51:31 +01:00
|
|
|
REMOTE_AUTH_BACKEND = "social_core.backends.open_id_connect.OpenIdConnectAuth";
|
2023-12-17 17:16:53 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extraConfig = ''
|
|
|
|
from os import environ as env
|
|
|
|
|
|
|
|
SOCIAL_AUTH_OIDC_OIDC_ENDPOINT = env["NETBOX_OIDC_URL"]
|
|
|
|
SOCIAL_AUTH_OIDC_KEY = env["NETBOX_OIDC_KEY"]
|
|
|
|
SOCIAL_AUTH_OIDC_SECRET = env["NETBOX_OIDC_SECRET"]
|
|
|
|
'';
|
2023-12-17 12:03:07 +01:00
|
|
|
};
|
2023-12-17 17:16:53 +01:00
|
|
|
|
|
|
|
nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."netbox.dgnum.sinavir.fr" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
locations."/".proxyPass = "http://${config.services.netbox.listenAddress}:${builtins.toString config.services.netbox.port}";
|
|
|
|
locations."/static/".alias = "${config.services.netbox.dataDir}/static/";
|
2023-12-17 17:16:53 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
postgresql.package = pkgs.postgresql_14;
|
2023-12-17 12:03:07 +01:00
|
|
|
};
|
2023-12-17 17:16:53 +01:00
|
|
|
|
2023-12-17 12:03:07 +01:00
|
|
|
# my server is slow sorry
|
2023-12-17 17:16:53 +01:00
|
|
|
systemd.services.netbox.serviceConfig = {
|
|
|
|
TimeoutStartSec = 600;
|
|
|
|
EnvironmentFile = config.age.secrets."netbox_env".path;
|
2023-12-17 12:03:07 +01:00
|
|
|
};
|
2023-12-17 17:16:53 +01:00
|
|
|
|
2023-12-17 18:05:59 +01:00
|
|
|
systemd.services.netbox-housekeeping.serviceConfig = {
|
|
|
|
EnvironmentFile = config.age.secrets."netbox_env".path;
|
|
|
|
};
|
|
|
|
|
2023-12-17 17:16:53 +01:00
|
|
|
users.users.nginx.extraGroups = [ "netbox" ];
|
2024-02-02 10:51:31 +01:00
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
|
|
443
|
|
|
|
80
|
|
|
|
];
|
2023-12-17 12:03:07 +01:00
|
|
|
}
|