From 84dab162c1fec19e210d4122b9efcf38db0b286d Mon Sep 17 00:00:00 2001 From: stuebinm Date: Fri, 9 Dec 2022 14:08:17 +0100 Subject: [PATCH] don't vendor the netbox package definition (because there's a simpler but also more cursed way of doing it instead) --- pkgs/default.nix | 14 +++++- pkgs/netbox/default.nix | 99 ----------------------------------------- 2 files changed, 13 insertions(+), 100 deletions(-) delete mode 100644 pkgs/netbox/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index c1984ac..9d5ffa2 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -31,7 +31,19 @@ let uffd = callPackage ./uffd {}; - netbox = callPackage ./netbox { }; + # netbox takes a python3, then overrides stuff on it before using it. + # since overrides don't accumulate, this does both the override we want + # and the one the netbox package would otherwise do, then disables overrides + netbox = pkgs.netbox.override rec { + python3 = (pkgs.python39.override { + packageOverrides = self: super: { + django = super.django_4; + social-auth-core = super.social-auth-core.overrideAttrs ( old: { + patches = [ ./netbox/0001-add-uffd-oauth2-backend.patch ]; + } ); + }; + }) // { override = ignored: python3; }; + }; inherit (unstable) vaultwarden vaultwarden-vault; }; diff --git a/pkgs/netbox/default.nix b/pkgs/netbox/default.nix deleted file mode 100644 index 114593b..0000000 --- a/pkgs/netbox/default.nix +++ /dev/null @@ -1,99 +0,0 @@ -# note: this file has been copied out of nixpkgs 22.05, except for -# that bit where we add the patch for uffd. There does not seem to -# be a better way to do this, since successive overrides to the -# python package set revert each other, and this file does such an -# override. - -{ lib -, pkgs -, fetchFromGitHub -, nixosTests -, python3 - -, plugins ? ps: [] }: - -let - py = python3.override { - packageOverrides = self: super: { - django = super.django_4; - social-auth-core = super.social-auth-core.overrideAttrs ( old: { - patches = [ ./0001-add-uffd-oauth2-backend.patch ]; - } ); - }; - }; - - - extraBuildInputs = plugins py.pkgs; -in -py.pkgs.buildPythonApplication rec { - pname = "netbox"; - version = "3.2.1"; - - src = fetchFromGitHub { - owner = "netbox-community"; - repo = pname; - rev = "v${version}"; - sha256 = "sha256-iA0KIgaHQh0OsN/tXmTATIlvnf0aLRdjeQ6VkiR9VJ4="; - }; - - format = "other"; - - patches = pkgs.netbox.patches; - - propagatedBuildInputs = with py.pkgs; [ - 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 - mkdocs-material - netaddr - pillow - psycopg2 - pyyaml - social-auth-core - social-auth-app-django - svgwrite - tablib - jsonschema - ] ++ extraBuildInputs; - - 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; - }; - }; - - 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 ]; - }; - }