Commit 03497d4a authored by Raito Bezarius's avatar Raito Bezarius
Browse files

netbox: introduce common function for generic packages, mark 3.3.9 EOL

parent c1081bf2
Loading
Loading
Loading
Loading
+0 −114
Original line number Diff line number Diff line
{ 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 ];
    };
  }
+29 −99
Original line number Diff line number Diff line
{ lib
, fetchFromGitHub
, nixosTests
, python3

, plugins ? ps: [] }:

{ lib, nixosTests, callPackage, fetchpatch }:
let
  py = python3 // {
    pkgs = python3.pkgs.overrideScope (self: super: {
      django = super.django_4;
    });
  };

  extraBuildInputs = plugins py.pkgs;
  generic = import ./generic.nix;
in
py.pkgs.buildPythonApplication rec {
    pname = "netbox";
    version = "3.4.7";

    format = "other";
{
  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=";
      })
    ];

    src = fetchFromGitHub {
      owner = "netbox-community";
      repo = pname;
      rev = "refs/tags/v${version}";
      hash = "sha256-pWHGyzLc0tqfehWbCMF1l96L1pewb5FXBUkw9EqPtP8=";
    tests.netbox = nixosTests.netbox_3_3;
    maintainers = with lib.maintainers; [ n0emis raitobezarius ];
    eol = true;
  };

    patches = [
  netbox = callPackage generic {
    version = "3.4.7";
    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;
    };
    };

    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 ];
  };
}
+110 −0
Original line number Diff line number Diff line
{ 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;
      };
    }
+2 −3
Original line number Diff line number Diff line
@@ -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;