2024-02-23 11:00:34 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2024-04-03 21:21:04 +02:00
|
|
|
nixpkgs,
|
2024-02-23 11:00:34 +01:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
EnvironmentFile = [ config.age.secrets."netbox-environment_file".path ];
|
|
|
|
in
|
|
|
|
|
2024-02-02 10:51:31 +01:00
|
|
|
{
|
2023-12-17 17:16:53 +01:00
|
|
|
services = {
|
|
|
|
netbox = {
|
|
|
|
enable = true;
|
2024-04-03 21:21:04 +02:00
|
|
|
package = nixpkgs.unstable.netbox_3_7;
|
2024-02-23 00:57:26 +01:00
|
|
|
secretKeyFile = "/dev/null";
|
2023-12-17 17:16:53 +01:00
|
|
|
listenAddress = "127.0.0.1";
|
2024-04-03 19:31:46 +02:00
|
|
|
plugins = p: [ p.netbox-qrcode ];
|
2023-12-17 17:16:53 +01:00
|
|
|
settings = {
|
2024-02-23 00:57:26 +01:00
|
|
|
ALLOWED_HOSTS = [ "netbox.dgnum.eu" ];
|
2024-02-02 10:51:31 +01:00
|
|
|
REMOTE_AUTH_BACKEND = "social_core.backends.open_id_connect.OpenIdConnectAuth";
|
2024-04-03 19:31:46 +02:00
|
|
|
PLUGINS = [ "netbox_qrcode" ];
|
|
|
|
PLUGINS_CONFIG = {
|
|
|
|
netbox_qrcode = {
|
|
|
|
custom_text = "DGNum. contact@dgnum.eu";
|
|
|
|
text_location = "down";
|
|
|
|
};
|
|
|
|
};
|
2023-12-17 17:16:53 +01:00
|
|
|
};
|
|
|
|
|
2024-02-23 00:57:26 +01:00
|
|
|
extraConfig = lib.mkForce ''
|
2023-12-17 17:16:53 +01:00
|
|
|
from os import environ as env
|
|
|
|
|
2024-02-23 00:57:26 +01:00
|
|
|
SECRET_KEY = env["SECRET_KEY"]
|
|
|
|
|
2023-12-17 17:16:53 +01:00
|
|
|
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;
|
2024-02-23 00:57:26 +01:00
|
|
|
virtualHosts."netbox.dgnum.eu" = {
|
2023-12-17 17:16:53 +01:00
|
|
|
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
|
|
|
};
|
|
|
|
};
|
2023-12-17 12:03:07 +01:00
|
|
|
};
|
2023-12-17 17:16:53 +01:00
|
|
|
|
2024-02-23 11:00:34 +01:00
|
|
|
systemd.services = {
|
|
|
|
netbox.serviceConfig = {
|
|
|
|
inherit EnvironmentFile;
|
2023-12-17 17:16:53 +01:00
|
|
|
|
2024-02-23 11:00:34 +01:00
|
|
|
TimeoutStartSec = 600;
|
|
|
|
};
|
|
|
|
|
|
|
|
netbox-housekeeping.serviceConfig = {
|
|
|
|
inherit EnvironmentFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
netbox-rq.serviceConfig = {
|
|
|
|
inherit EnvironmentFile;
|
|
|
|
};
|
2023-12-17 18:05:59 +01:00
|
|
|
};
|
|
|
|
|
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
|
|
|
|
];
|
2024-03-13 20:21:45 +01:00
|
|
|
|
2024-03-13 20:34:17 +01:00
|
|
|
dgn-backups.jobs.netbox.settings.paths = [ "/var/lib/netbox" ];
|
2024-03-13 20:21:45 +01:00
|
|
|
dgn-backups.postgresDatabases = [ "netbox" ];
|
2023-12-17 12:03:07 +01:00
|
|
|
}
|