nixos/netbox: merge bind options into one
They are all passed to gunicorn's --bind flag, so let the user pass whatever they want.
This commit is contained in:
@@ -10,6 +10,7 @@ let
|
||||
any
|
||||
attrValues
|
||||
mkChangedOptionModule
|
||||
mkOption
|
||||
mkRemovedOptionModule
|
||||
optionalString
|
||||
;
|
||||
@@ -86,10 +87,18 @@ in
|
||||
"1" = config.services.netbox.apiTokenPeppersFile;
|
||||
})
|
||||
)
|
||||
(mkRemovedOptionModule
|
||||
[ "services" "netbox" "keycloakClientSecret" ] ''
|
||||
Too much granularity hurts maintainability. Please configure secret key loading via `services.netbox.extraConfig` instead.
|
||||
'')
|
||||
(mkRemovedOptionModule [ "services" "netbox" "listenAddress" ] ''
|
||||
Use `services.netbox.bind` with <ip>:<port> format instead.
|
||||
'')
|
||||
(mkRemovedOptionModule [ "services" "netbox" "port" ] ''
|
||||
Use `services.netbox.bind` with <ip>:<port> format instead.
|
||||
'')
|
||||
(mkRemovedOptionModule [ "services" "netbox" "unixSocket" ] ''
|
||||
Use `services.netbox.bind` with unix:<path> format instead.
|
||||
'')
|
||||
(mkRemovedOptionModule [ "services" "netbox" "keycloakClientSecret" ] ''
|
||||
Too much granularity hurts maintainability. Please configure secret key loading via `services.netbox.extraConfig` instead.
|
||||
'')
|
||||
];
|
||||
|
||||
options.services.netbox = {
|
||||
@@ -128,23 +137,19 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
listenAddress = lib.mkOption {
|
||||
bind = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "[::1]";
|
||||
default = "unix:/run/netbox/netbox.sock";
|
||||
example = "[::1]:8001";
|
||||
description = ''
|
||||
Address the server will listen on.
|
||||
Ignored if `unixSocket` is set.
|
||||
'';
|
||||
};
|
||||
IP and port or Unix domain socket path to bind the HTTP socket to.
|
||||
|
||||
unixSocket = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Enable Unix Socket for the server to listen on.
|
||||
`listenAddress` and `port` will be ignored.
|
||||
::: {.tip}
|
||||
This setting will be passed to gunicorn's [--bind] flag.
|
||||
:::
|
||||
|
||||
[--bind]: https://gunicorn.org/reference/settings/#bind
|
||||
'';
|
||||
example = "/run/netbox/netbox.sock";
|
||||
};
|
||||
|
||||
gunicornArgs = lib.mkOption {
|
||||
@@ -171,15 +176,6 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8001;
|
||||
description = ''
|
||||
Port the server will listen on.
|
||||
Ignored if `unixSocket` is set.
|
||||
'';
|
||||
};
|
||||
|
||||
plugins = lib.mkOption {
|
||||
type = with lib.types; functionTo (listOf package);
|
||||
default = _: [ ];
|
||||
@@ -457,16 +453,12 @@ in
|
||||
serviceConfig = defaultServiceConfig // {
|
||||
ExecStart = ''
|
||||
${pkg.gunicorn}/bin/gunicorn netbox.wsgi \
|
||||
--bind ${
|
||||
if (cfg.unixSocket != null) then
|
||||
"unix:${cfg.unixSocket}"
|
||||
else
|
||||
"${cfg.listenAddress}:${toString cfg.port}"
|
||||
} \
|
||||
--bind ${cfg.bind} \
|
||||
--pythonpath ${pkg}/opt/netbox/netbox \
|
||||
${lib.concatStringsSep " " cfg.gunicornArgs}
|
||||
'';
|
||||
PrivateTmp = true;
|
||||
RuntimeDirectory = "netbox";
|
||||
TimeoutStartSec = lib.mkDefault "10min";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@ in
|
||||
|
||||
virtualHosts.netbox = {
|
||||
default = true;
|
||||
locations."/".proxyPass = "http://localhost:${toString config.services.netbox.port}";
|
||||
locations."/".proxyPass = "http://${config.services.netbox.bind}";
|
||||
locations."/static/".alias = "/var/lib/netbox/static/";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -70,7 +70,7 @@ import ../../make-test-python.nix (
|
||||
|
||||
virtualHosts.netbox = {
|
||||
default = true;
|
||||
locations."/".proxyPass = "http://localhost:${toString config.services.netbox.port}";
|
||||
locations."/".proxyPass = "http://${toString config.services.netbox.bind}";
|
||||
locations."/static/".alias = "/var/lib/netbox/static/";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -62,7 +62,7 @@ def compare(a: str, b: str):
|
||||
|
||||
with subtest("Home screen loads"):
|
||||
machine.wait_until_succeeds(
|
||||
"curl -sSfL http://[::1]:8001 | grep '<title>Home | NetBox</title>'"
|
||||
"curl -sSfL http://[::1]:80 | grep '<title>Home | NetBox</title>'"
|
||||
)
|
||||
|
||||
with subtest("Staticfiles are generated"):
|
||||
|
||||
Reference in New Issue
Block a user