From 46ac6032ae3affebc4180c2e59b2bc046efd9598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Barnouin?= Date: Tue, 24 Sep 2024 16:05:59 +0200 Subject: [PATCH] Add netbox service to curiosity --- flake.nix | 25 ++++++++++++-- services/netbox/default.nix | 66 ++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/flake.nix b/flake.nix index 6e6b27d..cde6b3a 100644 --- a/flake.nix +++ b/flake.nix @@ -88,10 +88,10 @@ { microvm = { autostart = [ - "jellyfin" + "netbox" ]; vms = { - jellyfin = { + netbox = { flake = self; updateFlake = "git+file:///etc/nixos"; }; @@ -188,6 +188,27 @@ } ]; }; + netbox = nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + microvm.nixosModules.microvm + "${inputs.self}/systems" + "${inputs.self}/services" + { + services.vm_netbox = { + enable = true; + }; + services.vm = { + enable = true; + hostname = "netbox"; + vm_ip = "192.168.1.45"; + vm_cpu = 2; + vm_mem = 2048; + macAddr = "02:00:00:00:00:45"; + }; + } + ]; + }; authentik = nixpkgs.lib.nixosSystem { inherit system; modules = [ diff --git a/services/netbox/default.nix b/services/netbox/default.nix index ca9a1f4..e4ba9bb 100644 --- a/services/netbox/default.nix +++ b/services/netbox/default.nix @@ -15,40 +15,40 @@ in enable = true; port = 8001; settings = { - ALLOWED_HOSTS = [ "*" ], - DATABASE = { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'netbox', - 'USER': 'netbox', - 'PASSWORD': 'Netbox43Zer!', - 'HOST': '192.168.1.13', - 'PORT': '5432', - 'CONN_MAX_AGE': 300, - }, + ALLOWED_HOSTS = [ "*" ]; + DATABASE = lib.mkForce { + ENGINE = "django.db.backends.postgresql"; + NAME = "netbox"; + USER = "netbox"; + PASSWORD = "Netbox43Zer!"; + HOST = "192.168.1.13"; + PORT = 5432; + CONN_MAX_AGE = 300; + }; REDIS = { - 'tasks': { - 'HOST': '192.168.1.16', - 'PORT': 6379, - 'USERNAME': '', - 'PASSWORD': '', - 'DATABASE': 0, - 'SSL': False, - }, - 'caching': { - 'HOST': '192.168.1.16', - 'PORT': 6379, - 'USERNAME': '', - 'PASSWORD': '', - 'DATABASE': 1, - 'SSL': False, - } - }, - CSRF_COOKIE_NAME = 'csrftoken', - CSRF_TRUSTED_ORIGINS = ( - 'http://192.168.1.40', - 'https://netbox.le43.eu', - ), - DEBUG = False + tasks = { + HOST = "192.168.1.16"; + PORT = 6379; + USERNAME = ""; + PASSWORD = ""; + DATABASE = 0; + SSL = false; + }; + caching = { + HOST = "192.168.1.16"; + PORT = 6379; + USERNAME = ""; + PASSWORD = ""; + DATABASE = 1; + SSL = false; + }; + }; + CSRF_COOKIE_NAME = "csrftoken"; + CSRF_TRUSTED_ORIGINS = [ + "http://192.168.1.40" + "https://netbox.le43.eu" + ]; + DEBUG = false; }; secretKeyFile = "/run/secrets/netbox/keyFile"; };