haccfiles/services/netbox.nix

69 lines
1.9 KiB
Nix
Raw Normal View History

2022-12-08 22:30:02 +00:00
{ config, lib, pkgs, evalConfig, ... }:
{
containers.netbox = {
privateNetwork = true;
hostAddress = "192.168.140.1";
localAddress = "192.168.140.10";
autoStart = true;
2022-12-09 01:53:48 +00:00
bindMounts = {
"/persist" = {
hostPath = "/persist/containers/netbox";
isReadOnly = false;
};
};
2022-12-08 22:30:02 +00:00
path = (evalConfig {
hosts = { };
groups = { };
} ({ config, lib, pkgs, profiles, modules, sources, ... }: {
boot.isContainer = true;
networking.useDHCP = false;
users.users.root.hashedPassword = "";
system.stateVersion = "21.11";
imports = [ sources.nix-hexchen.nixosModules.profiles.nopersist ];
2022-12-09 01:53:48 +00:00
2022-12-08 22:30:02 +00:00
services.netbox = {
enable = true;
listenAddress = "0.0.0.0";
2022-12-09 01:53:48 +00:00
secretKeyFile = "/persist/var/lib/netbox/secret";
# this is set by the nopersist profile
# dataDir = lib.mkForce "/persistvar/lib/netbox";
extraConfig = ''
2022-12-13 22:47:28 +00:00
MEDIA_ROOT = '/persist/var/lib/netbox/'
2022-12-09 01:53:48 +00:00
REMOTE_AUTH_BACKEND = 'social_core.backends.uffd.UffdOAuth2'
SOCIAL_AUTH_UFFD_KEY = "netbox"
SOCIAL_AUTH_UFFD_BASE_URL = "https://login.infra4future.de"
with open("/persist/var/lib/uffd-secret", "r") as file:
2022-12-09 01:53:48 +00:00
SOCIAL_AUTH_UFFD_SECRET = file.readline().replace("\n", "")
'';
};
# Enables nginx to traverse the directory to access /static
systemd.services.netbox.serviceConfig.StateDirectoryMode=lib.mkForce 0751;
2022-12-08 22:30:02 +00:00
services.coredns = {
enable = true;
config = ''
.:53 {
forward . 1.1.1.1
}
'';
};
})).config.system.build.toplevel;
};
services.nginx.virtualHosts."netbox.infra4future.de" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://${config.containers.netbox.localAddress}:8001";
};
2022-12-09 01:53:48 +00:00
locations."/static".root = "/persist/containers/netbox/var/lib/netbox";
2022-12-08 22:30:02 +00:00
};
}