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