From 49415e02b85d8928ecdeec92de7d07c126678f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Kobsch=C3=A4tzki?= Date: Tue, 25 Feb 2025 10:44:59 +0100 Subject: [PATCH 1/2] netbox_4_0: removal --- doc/release-notes/rl-2505.section.md | 2 + nixos/tests/all-tests.nix | 1 - .../ne/netbox_4_0/custom-static-root.patch | 13 -- pkgs/by-name/ne/netbox_4_0/django-5.1.patch | 81 ----------- pkgs/by-name/ne/netbox_4_0/package.nix | 131 ------------------ 5 files changed, 2 insertions(+), 226 deletions(-) delete mode 100644 pkgs/by-name/ne/netbox_4_0/custom-static-root.patch delete mode 100644 pkgs/by-name/ne/netbox_4_0/django-5.1.patch delete mode 100644 pkgs/by-name/ne/netbox_4_0/package.nix diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 20937069624f..0bdebe03863d 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -20,6 +20,8 @@ It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances. `rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`. +- NetBox `4.0.0` was removed. Please upgrade to `4.2`. + - Default ICU version updated from 74 to 76 diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 370d25349bd4..391db948df08 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -731,7 +731,6 @@ in { networking.networkmanager = handleTest ./networking/networkmanager.nix {}; netbox_3_6 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_6; }; netbox_3_7 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_7; }; - netbox_4_0 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_0; }; netbox_4_1 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_1; }; netbox-upgrade = handleTest ./web-apps/netbox-upgrade.nix {}; # TODO: put in networking.nix after the test becomes more complete diff --git a/pkgs/by-name/ne/netbox_4_0/custom-static-root.patch b/pkgs/by-name/ne/netbox_4_0/custom-static-root.patch deleted file mode 100644 index c9219fa2b871..000000000000 --- a/pkgs/by-name/ne/netbox_4_0/custom-static-root.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py -index 2de06dd10..00406af48 100644 ---- a/netbox/netbox/settings.py -+++ b/netbox/netbox/settings.py -@@ -410,7 +412,7 @@ USE_X_FORWARDED_HOST = True - X_FRAME_OPTIONS = 'SAMEORIGIN' - - # Static files (CSS, JavaScript, Images) --STATIC_ROOT = BASE_DIR + '/static' -+STATIC_ROOT = getattr(configuration, 'STATIC_ROOT', os.path.join(BASE_DIR, 'static')).rstrip('/') - STATIC_URL = f'/{BASE_PATH}static/' - STATICFILES_DIRS = ( - os.path.join(BASE_DIR, 'project-static', 'dist'), diff --git a/pkgs/by-name/ne/netbox_4_0/django-5.1.patch b/pkgs/by-name/ne/netbox_4_0/django-5.1.patch deleted file mode 100644 index 3976e79067a0..000000000000 --- a/pkgs/by-name/ne/netbox_4_0/django-5.1.patch +++ /dev/null @@ -1,81 +0,0 @@ -diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py -index f2cf0b721..a17b6712d 100644 ---- a/netbox/extras/forms/bulk_import.py -+++ b/netbox/extras/forms/bulk_import.py -@@ -194,7 +194,7 @@ class Meta: - model = EventRule - fields = ( - 'name', 'description', 'enabled', 'conditions', 'object_types', 'type_create', 'type_update', -- 'type_delete', 'type_job_start', 'type_job_end', 'action_type', 'action_object', 'comments', 'tags' -+ 'type_delete', 'type_job_start', 'type_job_end', 'action_type', 'comments', 'tags' - ) - - def clean(self): -diff --git a/netbox/extras/migrations/0002_squashed_0059.py b/netbox/extras/migrations/0002_squashed_0059.py -index 98bed255a..a403a0e19 100644 ---- a/netbox/extras/migrations/0002_squashed_0059.py -+++ b/netbox/extras/migrations/0002_squashed_0059.py -@@ -131,10 +131,6 @@ class Migration(migrations.Migration): - name='webhook', - unique_together={('payload_url', 'type_create', 'type_update', 'type_delete')}, - ), -- migrations.AlterIndexTogether( -- name='taggeditem', -- index_together={('content_type', 'object_id')}, -- ), - migrations.AlterUniqueTogether( - name='exporttemplate', - unique_together={('content_type', 'name')}, -diff --git a/netbox/extras/migrations/0087_squashed_0098.py b/netbox/extras/migrations/0087_squashed_0098.py -index 55f276ecd..bbe7f79f5 100644 ---- a/netbox/extras/migrations/0087_squashed_0098.py -+++ b/netbox/extras/migrations/0087_squashed_0098.py -@@ -98,10 +98,9 @@ class Migration(migrations.Migration): - name='object_types', - field=models.ManyToManyField(blank=True, related_name='+', to='contenttypes.contenttype'), - ), -- migrations.RenameIndex( -+ migrations.AddIndex( - model_name='taggeditem', -- new_name='extras_tagg_content_717743_idx', -- old_fields=('content_type', 'object_id'), -+ index=models.Index(fields=['content_type', 'object_id'], name='extras_tagg_content_717743_idx'), - ), - migrations.CreateModel( - name='Bookmark', -diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py -index f5e3bca30..4f96bac71 100644 ---- a/netbox/ipam/forms/model_forms.py -+++ b/netbox/ipam/forms/model_forms.py -@@ -588,7 +588,7 @@ class VLANGroupForm(NetBoxModelForm): - class Meta: - model = VLANGroup - fields = [ -- 'name', 'slug', 'description', 'min_vid', 'max_vid', 'scope_type', 'scope', 'tags', -+ 'name', 'slug', 'description', 'min_vid', 'max_vid', 'scope_type', 'tags', - ] - - def __init__(self, *args, **kwargs): -diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py -index a17ca9a5e..dee98afd3 100644 ---- a/netbox/vpn/forms/model_forms.py -+++ b/netbox/vpn/forms/model_forms.py -@@ -258,7 +258,7 @@ class TunnelTerminationForm(NetBoxModelForm): - class Meta: - model = TunnelTermination - fields = [ -- 'tunnel', 'role', 'termination', 'outside_ip', 'tags', -+ 'tunnel', 'role', 'outside_ip', 'tags', - ] - - def __init__(self, *args, initial=None, **kwargs): -diff --git a/requirements.txt b/requirements.txt -index 09f23871c..57f167dae 100644 ---- a/requirements.txt -+++ b/requirements.txt -@@ -1,4 +1,4 @@ --Django==5.0.9 -+Django==5.1.2 - django-cors-headers==4.4.0 - django-debug-toolbar==4.4.6 - django-filter==24.2 diff --git a/pkgs/by-name/ne/netbox_4_0/package.nix b/pkgs/by-name/ne/netbox_4_0/package.nix deleted file mode 100644 index 3a3221a3d99e..000000000000 --- a/pkgs/by-name/ne/netbox_4_0/package.nix +++ /dev/null @@ -1,131 +0,0 @@ -{ - lib, - fetchFromGitHub, - python3, - plugins ? _ps: [ ], - nixosTests, -}: -let - py = python3.override { - packageOverrides = _final: prev: { django = prev.django_5; }; - }; - - extraBuildInputs = plugins py.pkgs; -in -py.pkgs.buildPythonApplication rec { - pname = "netbox"; - version = "4.0.11"; - - format = "other"; - - src = fetchFromGitHub { - owner = "netbox-community"; - repo = "netbox"; - tag = "v${version}"; - hash = "sha256-0yEz7v5RL1+cqbGDyuyEsywFonJQfPdVIQdL0qLyc04="; - }; - - patches = [ - ./custom-static-root.patch - # From https://github.com/netbox-community/netbox/pull/17620 - ./django-5.1.patch - ]; - - propagatedBuildInputs = - ( - with py.pkgs; - [ - django - django-cors-headers - django-debug-toolbar - django-filter - django-graphiql-debug-toolbar - django-htmx - django-mptt - django-pglocks - django-prometheus - django-redis - django-rq - django-tables2 - django-taggit - django-timezone-field - djangorestframework - drf-spectacular - drf-spectacular-sidecar - feedparser - jinja2 - markdown - netaddr - nh3 - pillow - psycopg - psycopg.optional-dependencies.c - psycopg.optional-dependencies.pool - pyyaml - requests - social-auth-core - social-auth-app-django - strawberry-graphql - strawberry-django - svgwrite - tablib - - # Optional dependencies, kept here for backward compatibility - - # for the S3 data source backend - boto3 - # for Git data source backend - dulwich - # for error reporting - sentry-sdk - ] - ++ social-auth-core.passthru.optional-dependencies.openidconnect - ) - ++ extraBuildInputs; - - buildInputs = with py.pkgs; [ - mkdocs-material - mkdocs-material-extensions - mkdocstrings - mkdocstrings-python - ]; - - nativeBuildInputs = [ py.pkgs.mkdocs ]; - - postBuild = '' - PYTHONPATH=$PYTHONPATH:netbox/ - python -m mkdocs build - ''; - - installPhase = '' - mkdir -p $out/opt/netbox - cp -r . $out/opt/netbox - chmod +x $out/opt/netbox/netbox/manage.py - makeWrapper $out/opt/netbox/netbox/manage.py $out/bin/netbox \ - --prefix PYTHONPATH : "$PYTHONPATH" - ''; - - passthru = { - python = python3; - # PYTHONPATH of all dependencies used by the package - pythonPath = py.pkgs.makePythonPath propagatedBuildInputs; - inherit (py.pkgs) gunicorn; - tests = { - netbox = nixosTests.netbox_4_0; - }; - }; - - meta = { - homepage = "https://github.com/netbox-community/netbox"; - description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; - mainProgram = "netbox"; - license = lib.licenses.asl20; - maintainers = with lib.maintainers; [ - minijackson - raitobezarius - ]; - knownVulnerabilities = [ - "Netbox version ${version} is EOL; please upgrade by following the current release notes instructions." - ]; - }; -} From 3403819b4d52c8c7bd5163259e8c3711310cb6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Kobsch=C3=A4tzki?= Date: Tue, 25 Feb 2025 10:45:20 +0100 Subject: [PATCH 2/2] netbox_4_2: init Co-authored-by: SuperSandro2000 --- doc/release-notes/rl-2505.section.md | 7 +- nixos/modules/services/web-apps/netbox.nix | 4 +- nixos/tests/all-tests.nix | 1 + .../ne/netbox_4_2/custom-static-root.patch | 13 ++ pkgs/by-name/ne/netbox_4_2/package.nix | 127 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 +- 6 files changed, 151 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/ne/netbox_4_2/custom-static-root.patch create mode 100644 pkgs/by-name/ne/netbox_4_2/package.nix diff --git a/doc/release-notes/rl-2505.section.md b/doc/release-notes/rl-2505.section.md index 0bdebe03863d..88d2d59d3d92 100644 --- a/doc/release-notes/rl-2505.section.md +++ b/doc/release-notes/rl-2505.section.md @@ -20,7 +20,12 @@ It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances. `rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`. -- NetBox `4.0.0` was removed. Please upgrade to `4.2`. +- NetBox was updated to `>= 4.2.0`. Have a look at the breaking changes + of the [4.1 release](https://github.com/netbox-community/netbox/releases/tag/v4.1.0) + and the [4.2 release](https://github.com/netbox-community/netbox/releases/tag/v4.2.0), + make the required changes to your database, if needed, then upgrade by setting `services.netbox.package = pkgs.netbox_4_2;` in your configuration. + +- NetBox version 4.0.X available as `netbox_4_0` was removed. Please upgrade to `4.2`. - Default ICU version updated from 74 to 76 diff --git a/nixos/modules/services/web-apps/netbox.nix b/nixos/modules/services/web-apps/netbox.nix index e0e01026e7ad..9773db1c5e8b 100644 --- a/nixos/modules/services/web-apps/netbox.nix +++ b/nixos/modules/services/web-apps/netbox.nix @@ -91,7 +91,9 @@ in package = lib.mkOption { type = lib.types.package; default = - if lib.versionAtLeast config.system.stateVersion "24.11" then + if lib.versionAtLeast config.system.stateVersion "25.05" then + pkgs.netbox_4_2 + else if lib.versionAtLeast config.system.stateVersion "24.11" then pkgs.netbox_4_1 else if lib.versionAtLeast config.system.stateVersion "24.05" then pkgs.netbox_3_7 diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 391db948df08..0cbdd0fd8b9e 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -732,6 +732,7 @@ in { netbox_3_6 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_6; }; netbox_3_7 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_7; }; netbox_4_1 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_1; }; + netbox_4_2 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_4_2; }; netbox-upgrade = handleTest ./web-apps/netbox-upgrade.nix {}; # TODO: put in networking.nix after the test becomes more complete networkingProxy = handleTest ./networking-proxy.nix {}; diff --git a/pkgs/by-name/ne/netbox_4_2/custom-static-root.patch b/pkgs/by-name/ne/netbox_4_2/custom-static-root.patch new file mode 100644 index 000000000000..c9219fa2b871 --- /dev/null +++ b/pkgs/by-name/ne/netbox_4_2/custom-static-root.patch @@ -0,0 +1,13 @@ +diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py +index 2de06dd10..00406af48 100644 +--- a/netbox/netbox/settings.py ++++ b/netbox/netbox/settings.py +@@ -410,7 +412,7 @@ USE_X_FORWARDED_HOST = True + X_FRAME_OPTIONS = 'SAMEORIGIN' + + # Static files (CSS, JavaScript, Images) +-STATIC_ROOT = BASE_DIR + '/static' ++STATIC_ROOT = getattr(configuration, 'STATIC_ROOT', os.path.join(BASE_DIR, 'static')).rstrip('/') + STATIC_URL = f'/{BASE_PATH}static/' + STATICFILES_DIRS = ( + os.path.join(BASE_DIR, 'project-static', 'dist'), diff --git a/pkgs/by-name/ne/netbox_4_2/package.nix b/pkgs/by-name/ne/netbox_4_2/package.nix new file mode 100644 index 000000000000..b043bfd1b26f --- /dev/null +++ b/pkgs/by-name/ne/netbox_4_2/package.nix @@ -0,0 +1,127 @@ +{ + lib, + fetchFromGitHub, + python3, + plugins ? _ps: [ ], + nixosTests, +}: +let + py = python3.override { + packageOverrides = _final: prev: { django = prev.django_5; }; + }; + + extraBuildInputs = plugins py.pkgs; +in +py.pkgs.buildPythonApplication rec { + pname = "netbox"; + version = "4.2.3"; + + format = "other"; + + src = fetchFromGitHub { + owner = "netbox-community"; + repo = "netbox"; + tag = "v${version}"; + hash = "sha256-vdH/R88Vtu+xRLjETK0h+E4WoYRoseP0r+wROi8nMcM="; + }; + + patches = [ + ./custom-static-root.patch + ]; + + propagatedBuildInputs = + ( + with py.pkgs; + [ + django + django-cors-headers + django-debug-toolbar + django-filter + django-graphiql-debug-toolbar + django-htmx + django-mptt + django-pglocks + django-prometheus + django-redis + django-rq + django-tables2 + django-taggit + django-timezone-field + djangorestframework + drf-spectacular + drf-spectacular-sidecar + feedparser + jinja2 + markdown + netaddr + nh3 + pillow + psycopg + psycopg.optional-dependencies.c + psycopg.optional-dependencies.pool + pyyaml + requests + social-auth-core + social-auth-app-django + strawberry-graphql + strawberry-django + svgwrite + tablib + + # Optional dependencies, kept here for backward compatibility + + # for the S3 data source backend + boto3 + # for Git data source backend + dulwich + # for error reporting + sentry-sdk + ] + ++ social-auth-core.passthru.optional-dependencies.openidconnect + ) + ++ extraBuildInputs; + + buildInputs = with py.pkgs; [ + mkdocs-material + mkdocs-material-extensions + mkdocstrings + mkdocstrings-python + ]; + + nativeBuildInputs = [ py.pkgs.mkdocs ]; + + postBuild = '' + PYTHONPATH=$PYTHONPATH:netbox/ + python -m mkdocs build + ''; + + installPhase = '' + mkdir -p $out/opt/netbox + cp -r . $out/opt/netbox + chmod +x $out/opt/netbox/netbox/manage.py + makeWrapper $out/opt/netbox/netbox/manage.py $out/bin/netbox \ + --prefix PYTHONPATH : "$PYTHONPATH" + ''; + + passthru = { + python = python3; + # PYTHONPATH of all dependencies used by the package + pythonPath = py.pkgs.makePythonPath propagatedBuildInputs; + inherit (py.pkgs) gunicorn; + tests = { + netbox = nixosTests.netbox_4_2; + inherit (nixosTests) netbox-upgrade; + }; + }; + + meta = { + homepage = "https://github.com/netbox-community/netbox"; + description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; + mainProgram = "netbox"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ + minijackson + raitobezarius + ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 640b52bebbee..a99b535c3b8c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4265,7 +4265,7 @@ with pkgs; inherit (callPackage ../servers/web-apps/netbox { }) netbox_3_7; # Not in aliases because it wouldn't get picked up by callPackage - netbox = netbox_4_1; + netbox = netbox_4_2; netcat = libressl.nc.overrideAttrs (old: { meta = old.meta // {