From ff6d89ac694100ab5350cda97e46fdbd54a54e6c Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 6 Nov 2024 16:13:18 +0100 Subject: [PATCH 1/2] nixos/netbox: clear old static files on upgrade This fixes an issue where upgrading NetBox didn't correctly clean old files, and the interface wasn't correct / didn't show object relations. --- nixos/modules/services/web-apps/netbox.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/netbox.nix b/nixos/modules/services/web-apps/netbox.nix index 01319722afa92..605948810e303 100644 --- a/nixos/modules/services/web-apps/netbox.nix +++ b/nixos/modules/services/web-apps/netbox.nix @@ -304,7 +304,7 @@ in { ${pkg}/bin/netbox migrate ${pkg}/bin/netbox trace_paths --no-input - ${pkg}/bin/netbox collectstatic --no-input + ${pkg}/bin/netbox collectstatic --clear --no-input ${pkg}/bin/netbox remove_stale_contenttypes --no-input ${pkg}/bin/netbox reindex --lazy ${pkg}/bin/netbox clearsessions From fe58368de684b85915891352ef8bc3dd6e4d8ecc Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 6 Nov 2024 16:14:56 +0100 Subject: [PATCH 2/2] nixos/netbox: switch to symlink to check for upgrades This makes it so that the upgrade script also runs when the configuration changed, or when plugins were added. This is also a hack to force everyone to run the upgrade script again, since static files might have been copied incorrectly (see parent commit) --- nixos/modules/services/web-apps/netbox.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/web-apps/netbox.nix b/nixos/modules/services/web-apps/netbox.nix index 605948810e303..6f5e1536d6164 100644 --- a/nixos/modules/services/web-apps/netbox.nix +++ b/nixos/modules/services/web-apps/netbox.nix @@ -298,7 +298,7 @@ in { # This mostly correspond to upstream NetBox's 'upgrade.sh' script. versionFile="${cfg.dataDir}/version" - if [[ -e "$versionFile" && "$(cat "$versionFile")" == "${cfg.package.version}" ]]; then + if [[ -h "$versionFile" && "$(readlink -- "$versionFile")" == "${cfg.package}" ]]; then exit 0 fi @@ -314,7 +314,7 @@ in { (lib.versionOlder cfg.package.version "3.7.0") "${pkg}/bin/netbox clearcache"} - echo "${cfg.package.version}" > "$versionFile" + ln -sfn "${cfg.package}" "$versionFile" ''; serviceConfig = defaultServiceConfig // {