From 03497d4ab4c6dc383130d83ba5a469f58379692b Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Tue, 4 Apr 2023 11:43:03 +0200 Subject: [PATCH] netbox: introduce common function for generic packages, mark 3.3.9 EOL --- pkgs/servers/web-apps/netbox/3.3.nix | 114 -------------------- pkgs/servers/web-apps/netbox/default.nix | 128 +++++------------------ pkgs/servers/web-apps/netbox/generic.nix | 110 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +- 4 files changed, 141 insertions(+), 216 deletions(-) delete mode 100644 pkgs/servers/web-apps/netbox/3.3.nix create mode 100644 pkgs/servers/web-apps/netbox/generic.nix diff --git a/pkgs/servers/web-apps/netbox/3.3.nix b/pkgs/servers/web-apps/netbox/3.3.nix deleted file mode 100644 index 5420bbc22c89..000000000000 --- a/pkgs/servers/web-apps/netbox/3.3.nix +++ /dev/null @@ -1,114 +0,0 @@ -{ lib -, pkgs -, fetchFromGitHub -, fetchpatch -, nixosTests -, python3 - -, plugins ? ps: [] }: - -let - py = python3.override { - packageOverrides = self: super: { - django = super.django_4; - }; - }; - - extraBuildInputs = plugins py.pkgs; -in -py.pkgs.buildPythonApplication rec { - pname = "netbox"; - version = "3.3.9"; - - format = "other"; - - src = fetchFromGitHub { - owner = "netbox-community"; - repo = pname; - rev = "refs/tags/v${version}"; - sha256 = "sha256-KhnxD5pjlEIgISl4RMbhLCDwgUDfGFRi88ZcP1ndMhI="; - }; - - patches = [ - # Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL - ./config_3_3.patch - ./graphql-3_2_0.patch - # fix compatibility ith django 4.1 - (fetchpatch { - url = "https://github.com/netbox-community/netbox/pull/10341/commits/ce6bf9e5c1bc08edc80f6ea1e55cf1318ae6e14b.patch"; - sha256 = "sha256-aCPQp6k7Zwga29euASAd+f13hIcZnIUu3RPAzNPqgxc="; - }) - ]; - - propagatedBuildInputs = with py.pkgs; [ - bleach - django_4 - django-cors-headers - django-debug-toolbar - django-filter - django-graphiql-debug-toolbar - django-mptt - django-pglocks - django-prometheus - django-redis - django-rq - django-tables2 - django-taggit - django-timezone-field - djangorestframework - drf-yasg - swagger-spec-validator # from drf-yasg[validation] - graphene-django - jinja2 - markdown - markdown-include - netaddr - pillow - psycopg2 - pyyaml - sentry-sdk - social-auth-core - social-auth-app-django - svgwrite - tablib - jsonschema - ] ++ 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 = { - # PYTHONPATH of all dependencies used by the package - pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs; - - tests.netbox = nixosTests.netbox_3_3; - }; - - meta = with lib; { - homepage = "https://github.com/netbox-community/netbox"; - description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; - license = licenses.asl20; - maintainers = with maintainers; [ n0emis raitobezarius ]; - }; - } diff --git a/pkgs/servers/web-apps/netbox/default.nix b/pkgs/servers/web-apps/netbox/default.nix index 8f19be44a6c3..a73ab9b186b8 100644 --- a/pkgs/servers/web-apps/netbox/default.nix +++ b/pkgs/servers/web-apps/netbox/default.nix @@ -1,108 +1,38 @@ -{ lib -, fetchFromGitHub -, nixosTests -, python3 - -, plugins ? ps: [] }: - +{ lib, nixosTests, callPackage, fetchpatch }: let - py = python3 // { - pkgs = python3.pkgs.overrideScope (self: super: { - django = super.django_4; - }); + generic = import ./generic.nix; +in +{ + netbox_3_3 = callPackage generic { + version = "3.3.9"; + hash = "sha256-KhnxD5pjlEIgISl4RMbhLCDwgUDfGFRi88ZcP1ndMhI="; + extraPatches = [ + # Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL + ./config_3_3.patch + ./graphql-3_2_0.patch + # fix compatibility ith django 4.1 + (fetchpatch { + url = "https://github.com/netbox-community/netbox/pull/10341/commits/ce6bf9e5c1bc08edc80f6ea1e55cf1318ae6e14b.patch"; + sha256 = "sha256-aCPQp6k7Zwga29euASAd+f13hIcZnIUu3RPAzNPqgxc="; + }) + ]; + + tests.netbox = nixosTests.netbox_3_3; + maintainers = with lib.maintainers; [ n0emis raitobezarius ]; + eol = true; }; - extraBuildInputs = plugins py.pkgs; -in -py.pkgs.buildPythonApplication rec { - pname = "netbox"; + netbox = callPackage generic { version = "3.4.7"; - - format = "other"; - - src = fetchFromGitHub { - owner = "netbox-community"; - repo = pname; - rev = "refs/tags/v${version}"; - hash = "sha256-pWHGyzLc0tqfehWbCMF1l96L1pewb5FXBUkw9EqPtP8="; - }; - - patches = [ + hash = "sha256-pWHGyzLc0tqfehWbCMF1l96L1pewb5FXBUkw9EqPtP8="; + extraPatches = [ # Allow setting the STATIC_ROOT from within the configuration and setting a custom redis URL ./config.patch ]; - - propagatedBuildInputs = with py.pkgs; [ - bleach - django_4 - django-cors-headers - django-debug-toolbar - django-filter - django-graphiql-debug-toolbar - django-mptt - django-pglocks - django-prometheus - django-redis - django-rq - django-tables2 - django-taggit - django-timezone-field - djangorestframework - drf-yasg - swagger-spec-validator # from drf-yasg[validation] - graphene-django - jinja2 - markdown - markdown-include - netaddr - pillow - psycopg2 - pyyaml - sentry-sdk - social-auth-core - social-auth-app-django - svgwrite - tablib - jsonschema - ] ++ 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 = { - # PYTHONPATH of all dependencies used by the package - pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs; - - tests = { - inherit (nixosTests) netbox; - }; + tests = { + inherit (nixosTests) netbox; }; - meta = with lib; { - homepage = "https://github.com/netbox-community/netbox"; - description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; - license = licenses.asl20; - maintainers = with maintainers; [ minijackson n0emis raitobezarius ]; - }; - } + maintainers = with lib.maintainers; [ minijackson n0emis raitobezarius ]; + }; +} diff --git a/pkgs/servers/web-apps/netbox/generic.nix b/pkgs/servers/web-apps/netbox/generic.nix new file mode 100644 index 000000000000..ace3e4f011f0 --- /dev/null +++ b/pkgs/servers/web-apps/netbox/generic.nix @@ -0,0 +1,110 @@ +{ lib +, fetchFromGitHub +, python3 +, version +, hash +, plugins ? ps: [] +, extraPatches ? [] +, tests ? {} +, maintainers ? [] +, eol ? false +}: + let + py = python3 // { + pkgs = python3.pkgs.overrideScope (self: super: { + django = super.django_4; + }); + }; + + extraBuildInputs = plugins py.pkgs; + in + py.pkgs.buildPythonApplication rec { + pname = "netbox"; + inherit version; + + format = "other"; + + src = fetchFromGitHub { + owner = "netbox-community"; + repo = pname; + rev = "refs/tags/v${version}"; + inherit hash; + }; + + patches = extraPatches; + + propagatedBuildInputs = with py.pkgs; [ + bleach + django_4 + django-cors-headers + django-debug-toolbar + django-filter + django-graphiql-debug-toolbar + django-mptt + django-pglocks + django-prometheus + django-redis + django-rq + django-tables2 + django-taggit + django-timezone-field + djangorestframework + drf-yasg + swagger-spec-validator # from drf-yasg[validation] + graphene-django + jinja2 + markdown + markdown-include + netaddr + pillow + psycopg2 + pyyaml + sentry-sdk + social-auth-core + social-auth-app-django + svgwrite + tablib + jsonschema + ] ++ 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 = { + # PYTHONPATH of all dependencies used by the package + pythonPath = python3.pkgs.makePythonPath propagatedBuildInputs; + inherit tests; + }; + + meta = { + homepage = "https://github.com/netbox-community/netbox"; + description = "IP address management (IPAM) and data center infrastructure management (DCIM) tool"; + license = lib.licenses.asl20; + knownVulnerabilities = (lib.optional eol "Netbox version ${version} is EOL; please upgrade by following the current release notes instructions."); + # Warning: + # Notice the missing `lib` in the inherit: it is using this function argument rather than a `with lib;` argument. + # If you replace this by `with lib;`, pay attention it does not inherit all maintainers in nixpkgs. + inherit maintainers; + }; + } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fcb5c50128f2..77d5064a2d06 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10200,9 +10200,8 @@ with pkgs; netbootxyz-efi = callPackage ../tools/misc/netbootxyz-efi { }; - netbox = callPackage ../servers/web-apps/netbox { }; - - netbox_3_3 = callPackage ../servers/web-apps/netbox/3.3.nix { }; + inherit (callPackage ../servers/web-apps/netbox { }) + netbox_3_3 netbox; netcat = libressl.nc;