nixos/netbox: remove "with lib;"

This commit is contained in:
Minijackson 2023-07-31 14:38:26 +02:00
parent e27829d076
commit bcdc4d976c
No known key found for this signature in database
GPG key ID: FEA888C9F5D64F62

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.netbox; cfg = config.services.netbox;
pythonFmt = pkgs.formats.pythonVars {}; pythonFmt = pkgs.formats.pythonVars {};
@ -17,7 +15,7 @@ let
pkg = (cfg.package.overrideAttrs (old: { pkg = (cfg.package.overrideAttrs (old: {
installPhase = old.installPhase + '' installPhase = old.installPhase + ''
ln -s ${configFile} $out/opt/netbox/netbox/netbox/configuration.py ln -s ${configFile} $out/opt/netbox/netbox/netbox/configuration.py
'' + optionalString cfg.enableLdap '' '' + lib.optionalString cfg.enableLdap ''
ln -s ${cfg.ldapConfigPath} $out/opt/netbox/netbox/netbox/ldap_config.py ln -s ${cfg.ldapConfigPath} $out/opt/netbox/netbox/netbox/ldap_config.py
''; '';
})).override { })).override {
@ -31,7 +29,7 @@ let
in { in {
options.services.netbox = { options.services.netbox = {
enable = mkOption { enable = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = lib.mdDoc '' description = lib.mdDoc ''
@ -66,18 +64,18 @@ in {
}; };
}; };
listenAddress = mkOption { listenAddress = lib.mkOption {
type = types.str; type = lib.types.str;
default = "[::1]"; default = "[::1]";
description = lib.mdDoc '' description = lib.mdDoc ''
Address the server will listen on. Address the server will listen on.
''; '';
}; };
package = mkOption { package = lib.mkOption {
type = types.package; type = lib.types.package;
default = if versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3; default = if lib.versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3;
defaultText = literalExpression '' defaultText = lib.literalExpression ''
if versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3; if versionAtLeast config.system.stateVersion "23.05" then pkgs.netbox else pkgs.netbox_3_3;
''; '';
description = lib.mdDoc '' description = lib.mdDoc ''
@ -85,18 +83,18 @@ in {
''; '';
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
default = 8001; default = 8001;
description = lib.mdDoc '' description = lib.mdDoc ''
Port the server will listen on. Port the server will listen on.
''; '';
}; };
plugins = mkOption { plugins = lib.mkOption {
type = types.functionTo (types.listOf types.package); type = with lib.types; functionTo (listOf package);
default = _: []; default = _: [];
defaultText = literalExpression '' defaultText = lib.literalExpression ''
python3Packages: with python3Packages; []; python3Packages: with python3Packages; [];
''; '';
description = lib.mdDoc '' description = lib.mdDoc ''
@ -104,23 +102,23 @@ in {
''; '';
}; };
dataDir = mkOption { dataDir = lib.mkOption {
type = types.str; type = lib.types.str;
default = "/var/lib/netbox"; default = "/var/lib/netbox";
description = lib.mdDoc '' description = lib.mdDoc ''
Storage path of netbox. Storage path of netbox.
''; '';
}; };
secretKeyFile = mkOption { secretKeyFile = lib.mkOption {
type = types.path; type = lib.types.path;
description = lib.mdDoc '' description = lib.mdDoc ''
Path to a file containing the secret key. Path to a file containing the secret key.
''; '';
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = lib.mdDoc '' description = lib.mdDoc ''
Additional lines of configuration appended to the `configuration.py`. Additional lines of configuration appended to the `configuration.py`.
@ -128,8 +126,8 @@ in {
''; '';
}; };
enableLdap = mkOption { enableLdap = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = lib.mdDoc '' description = lib.mdDoc ''
Enable LDAP-Authentication for Netbox. Enable LDAP-Authentication for Netbox.
@ -138,8 +136,8 @@ in {
''; '';
}; };
ldapConfigPath = mkOption { ldapConfigPath = lib.mkOption {
type = types.path; type = lib.types.path;
default = ""; default = "";
description = lib.mdDoc '' description = lib.mdDoc ''
Path to the Configuration-File for LDAP-Authentication, will be loaded as `ldap_config.py`. Path to the Configuration-File for LDAP-Authentication, will be loaded as `ldap_config.py`.
@ -173,9 +171,9 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.netbox = { services.netbox = {
plugins = mkIf cfg.enableLdap (ps: [ ps.django-auth-ldap ]); plugins = lib.mkIf cfg.enableLdap (ps: [ ps.django-auth-ldap ]);
settings = { settings = {
STATIC_ROOT = staticDir; STATIC_ROOT = staticDir;
MEDIA_ROOT = "${cfg.dataDir}/media"; MEDIA_ROOT = "${cfg.dataDir}/media";