From e27365cf4b25b2c2917c7726ee87c8e80316544b Mon Sep 17 00:00:00 2001 From: Raymond Douglas Date: Thu, 6 Feb 2025 13:39:52 -0800 Subject: [PATCH] netbox: add option to listen on Unix socket --- nixos/modules/services/web-apps/netbox.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/web-apps/netbox.nix b/nixos/modules/services/web-apps/netbox.nix index e0e01026e7ad..3e207673954c 100644 --- a/nixos/modules/services/web-apps/netbox.nix +++ b/nixos/modules/services/web-apps/netbox.nix @@ -85,9 +85,20 @@ in default = "[::1]"; description = '' Address the server will listen on. + Ignored if `unixSocket` is set. ''; }; + 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. + ''; + example = "/run/netbox/netbox.sock"; + }; + package = lib.mkOption { type = lib.types.package; default = @@ -114,6 +125,7 @@ in default = 8001; description = '' Port the server will listen on. + Ignored if `unixSocket` is set. ''; }; @@ -345,7 +357,12 @@ in serviceConfig = defaultServiceConfig // { ExecStart = '' ${pkg.gunicorn}/bin/gunicorn netbox.wsgi \ - --bind ${cfg.listenAddress}:${toString cfg.port} \ + --bind ${ + if (cfg.unixSocket != null) then + "unix:${cfg.unixSocket}" + else + "${cfg.listenAddress}:${toString cfg.port}" + } \ --pythonpath ${pkg}/opt/netbox/netbox ''; PrivateTmp = true;