mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-01 15:11:25 +00:00
netbox_3_3: init
reintroduce previous version, use in NixOS module if stateVersion < 23.05
This commit is contained in:
parent
6e054138b0
commit
78eb4d64e7
@ -14,7 +14,7 @@ let
|
||||
};
|
||||
configFile = pkgs.concatText "configuration.py" [ settingsFile extraConfigFile ];
|
||||
|
||||
pkg = (pkgs.netbox.overrideAttrs (old: {
|
||||
pkg = (cfg.package.overrideAttrs (old: {
|
||||
installPhase = old.installPhase + ''
|
||||
ln -s ${configFile} $out/opt/netbox/netbox/netbox/configuration.py
|
||||
'' + optionalString cfg.enableLdap ''
|
||||
@ -74,6 +74,17 @@ in {
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = if versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3;
|
||||
defaultText = literalExpression ''
|
||||
if versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3;
|
||||
'';
|
||||
description = lib.mdDoc ''
|
||||
NetBox package to use.
|
||||
'';
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 8001;
|
||||
|
@ -460,7 +460,8 @@ in {
|
||||
netdata = handleTest ./netdata.nix {};
|
||||
networking.networkd = handleTest ./networking.nix { networkd = true; };
|
||||
networking.scripted = handleTest ./networking.nix { networkd = false; };
|
||||
netbox = handleTest ./web-apps/netbox.nix {};
|
||||
netbox = handleTest ./web-apps/netbox.nix { inherit (pkgs) netbox; };
|
||||
netbox_3_3 = handleTest ./web-apps/netbox.nix { netbox = pkgs.netbox_3_3; };
|
||||
# TODO: put in networking.nix after the test becomes more complete
|
||||
networkingProxy = handleTest ./networking-proxy.nix {};
|
||||
nextcloud = handleTest ./nextcloud {};
|
||||
|
@ -8,7 +8,7 @@ let
|
||||
testUser = "alice";
|
||||
testPassword = "verySecure";
|
||||
testGroup = "netbox-users";
|
||||
in import ../make-test-python.nix ({ lib, pkgs, ... }: {
|
||||
in import ../make-test-python.nix ({ lib, pkgs, netbox, ... }: {
|
||||
name = "netbox";
|
||||
|
||||
meta = with lib.maintainers; {
|
||||
@ -18,6 +18,7 @@ in import ../make-test-python.nix ({ lib, pkgs, ... }: {
|
||||
nodes.machine = { config, ... }: {
|
||||
services.netbox = {
|
||||
enable = true;
|
||||
package = netbox;
|
||||
secretKeyFile = pkgs.writeText "secret" ''
|
||||
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
|
||||
'';
|
||||
|
114
pkgs/servers/web-apps/netbox/3.3.nix
Normal file
114
pkgs/servers/web-apps/netbox/3.3.nix
Normal file
@ -0,0 +1,114 @@
|
||||
{ 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 ];
|
||||
};
|
||||
}
|
50
pkgs/servers/web-apps/netbox/config_3_3.patch
Normal file
50
pkgs/servers/web-apps/netbox/config_3_3.patch
Normal file
@ -0,0 +1,50 @@
|
||||
diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py
|
||||
index d5a7bfaec..68754a8c5 100644
|
||||
--- a/netbox/netbox/settings.py
|
||||
+++ b/netbox/netbox/settings.py
|
||||
@@ -222,6 +222,7 @@ TASKS_REDIS_PASSWORD = TASKS_REDIS.get('PASSWORD', '')
|
||||
TASKS_REDIS_DATABASE = TASKS_REDIS.get('DATABASE', 0)
|
||||
TASKS_REDIS_SSL = TASKS_REDIS.get('SSL', False)
|
||||
TASKS_REDIS_SKIP_TLS_VERIFY = TASKS_REDIS.get('INSECURE_SKIP_TLS_VERIFY', False)
|
||||
+TASKS_REDIS_URL = TASKS_REDIS.get('URL')
|
||||
|
||||
# Caching
|
||||
if 'caching' not in REDIS:
|
||||
@@ -236,11 +237,12 @@ CACHING_REDIS_SENTINELS = REDIS['caching'].get('SENTINELS', [])
|
||||
CACHING_REDIS_SENTINEL_SERVICE = REDIS['caching'].get('SENTINEL_SERVICE', 'default')
|
||||
CACHING_REDIS_PROTO = 'rediss' if REDIS['caching'].get('SSL', False) else 'redis'
|
||||
CACHING_REDIS_SKIP_TLS_VERIFY = REDIS['caching'].get('INSECURE_SKIP_TLS_VERIFY', False)
|
||||
+CACHING_REDIS_URL = REDIS['caching'].get('URL', f'{CACHING_REDIS_PROTO}://{CACHING_REDIS_HOST}:{CACHING_REDIS_PORT}/{CACHING_REDIS_DATABASE}')
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django_redis.cache.RedisCache',
|
||||
- 'LOCATION': f'{CACHING_REDIS_PROTO}://{CACHING_REDIS_HOST}:{CACHING_REDIS_PORT}/{CACHING_REDIS_DATABASE}',
|
||||
+ 'LOCATION': CACHING_REDIS_URL,
|
||||
'OPTIONS': {
|
||||
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
|
||||
'PASSWORD': CACHING_REDIS_PASSWORD,
|
||||
@@ -383,7 +385,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'),
|
||||
@@ -562,6 +564,14 @@ if TASKS_REDIS_USING_SENTINEL:
|
||||
'socket_connect_timeout': TASKS_REDIS_SENTINEL_TIMEOUT
|
||||
},
|
||||
}
|
||||
+elif TASKS_REDIS_URL:
|
||||
+ RQ_PARAMS = {
|
||||
+ 'URL': TASKS_REDIS_URL,
|
||||
+ 'PASSWORD': TASKS_REDIS_PASSWORD,
|
||||
+ 'SSL': TASKS_REDIS_SSL,
|
||||
+ 'SSL_CERT_REQS': None if TASKS_REDIS_SKIP_TLS_VERIFY else 'required',
|
||||
+ 'DEFAULT_TIMEOUT': RQ_DEFAULT_TIMEOUT,
|
||||
+ }
|
||||
else:
|
||||
RQ_PARAMS = {
|
||||
'HOST': TASKS_REDIS_HOST,
|
21
pkgs/servers/web-apps/netbox/graphql-3_2_0.patch
Normal file
21
pkgs/servers/web-apps/netbox/graphql-3_2_0.patch
Normal file
@ -0,0 +1,21 @@
|
||||
diff --git a/netbox/netbox/graphql/scalars.py b/netbox/netbox/graphql/scalars.py
|
||||
index 7d14189dd..0a18e79d2 100644
|
||||
--- a/netbox/netbox/graphql/scalars.py
|
||||
+++ b/netbox/netbox/graphql/scalars.py
|
||||
@@ -1,6 +1,6 @@
|
||||
from graphene import Scalar
|
||||
from graphql.language import ast
|
||||
-from graphql.type.scalars import MAX_INT, MIN_INT
|
||||
+from graphql.type.scalars import GRAPHQL_MAX_INT, GRAPHQL_MIN_INT
|
||||
|
||||
|
||||
class BigInt(Scalar):
|
||||
@@ -10,7 +10,7 @@ class BigInt(Scalar):
|
||||
@staticmethod
|
||||
def to_float(value):
|
||||
num = int(value)
|
||||
- if num > MAX_INT or num < MIN_INT:
|
||||
+ if num > GRAPHQL_MAX_INT or num < GRAPHQL_MIN_INT:
|
||||
return float(num)
|
||||
return num
|
||||
|
@ -10202,6 +10202,8 @@ with pkgs;
|
||||
|
||||
netbox = callPackage ../servers/web-apps/netbox { };
|
||||
|
||||
netbox_3_3 = callPackage ../servers/web-apps/netbox/3.3.nix { };
|
||||
|
||||
netcat = libressl.nc;
|
||||
|
||||
netcat-gnu = callPackage ../tools/networking/netcat { };
|
||||
|
Loading…
Reference in New Issue
Block a user