nixos/peering-manager: remove global 'with lib;'

This commit is contained in:
Yureka 2023-07-12 18:37:49 +02:00
parent 041e9a8e7a
commit 5934231542

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, buildEnv, ... }: { config, lib, pkgs, buildEnv, ... }:
with lib;
let let
cfg = config.services.peering-manager; cfg = config.services.peering-manager;
configFile = pkgs.writeTextFile { configFile = pkgs.writeTextFile {
@ -41,24 +39,24 @@ let
pkg = (pkgs.peering-manager.overrideAttrs (old: { pkg = (pkgs.peering-manager.overrideAttrs (old: {
postInstall = '' postInstall = ''
ln -s ${configFile} $out/opt/peering-manager/peering_manager/configuration.py ln -s ${configFile} $out/opt/peering-manager/peering_manager/configuration.py
'' + optionalString cfg.enableLdap '' '' + lib.optionalString cfg.enableLdap ''
ln -s ${cfg.ldapConfigPath} $out/opt/peering-manager/peering_manager/ldap_config.py ln -s ${cfg.ldapConfigPath} $out/opt/peering-manager/peering_manager/ldap_config.py
''; '';
})).override { })).override {
inherit (cfg) plugins; inherit (cfg) plugins;
}; };
peeringManagerManageScript = with pkgs; (writeScriptBin "peering-manager-manage" '' peeringManagerManageScript = pkgs.writeScriptBin "peering-manager-manage" ''
#!${stdenv.shell} #!${pkgs.stdenv.shell}
export PYTHONPATH=${pkg.pythonPath} export PYTHONPATH=${pkg.pythonPath}
sudo -u peering-manager ${pkg}/bin/peering-manager "$@" sudo -u peering-manager ${pkg}/bin/peering-manager "$@"
''); '';
in { in {
options.services.peering-manager = { options.services.peering-manager = with lib; {
enable = mkOption { enable = mkOption {
type = lib.types.bool; type = types.bool;
default = false; default = false;
description = lib.mdDoc '' description = mdDoc ''
Enable Peering Manager. Enable Peering Manager.
This module requires a reverse proxy that serves `/static` separately. This module requires a reverse proxy that serves `/static` separately.
@ -69,7 +67,7 @@ in {
listenAddress = mkOption { listenAddress = mkOption {
type = types.str; type = types.str;
default = "[::1]"; default = "[::1]";
description = lib.mdDoc '' description = mdDoc ''
Address the server will listen on. Address the server will listen on.
''; '';
}; };
@ -77,7 +75,7 @@ in {
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = 8001; default = 8001;
description = lib.mdDoc '' description = mdDoc ''
Port the server will listen on. Port the server will listen on.
''; '';
}; };
@ -88,14 +86,14 @@ in {
defaultText = literalExpression '' defaultText = literalExpression ''
python3Packages: with python3Packages; []; python3Packages: with python3Packages; [];
''; '';
description = lib.mdDoc '' description = mdDoc ''
List of plugin packages to install. List of plugin packages to install.
''; '';
}; };
secretKeyFile = mkOption { secretKeyFile = mkOption {
type = types.path; type = types.path;
description = lib.mdDoc '' description = mdDoc ''
Path to a file containing the secret key. Path to a file containing the secret key.
''; '';
}; };
@ -103,7 +101,7 @@ in {
peeringdbApiKeyFile = mkOption { peeringdbApiKeyFile = mkOption {
type = with types; nullOr path; type = with types; nullOr path;
default = null; default = null;
description = lib.mdDoc '' description = mdDoc ''
Path to a file containing the PeeringDB API key. Path to a file containing the PeeringDB API key.
''; '';
}; };
@ -111,7 +109,7 @@ in {
extraConfig = mkOption { extraConfig = mkOption {
type = types.lines; type = types.lines;
default = ""; default = "";
description = lib.mdDoc '' description = mdDoc ''
Additional lines of configuration appended to the `configuration.py`. Additional lines of configuration appended to the `configuration.py`.
See the [documentation](https://peering-manager.readthedocs.io/en/stable/configuration/optional-settings/) for more possible options. See the [documentation](https://peering-manager.readthedocs.io/en/stable/configuration/optional-settings/) for more possible options.
''; '';
@ -120,7 +118,7 @@ in {
enableLdap = mkOption { enableLdap = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
description = lib.mdDoc '' description = mdDoc ''
Enable LDAP-Authentication for Peering Manager. Enable LDAP-Authentication for Peering Manager.
This requires a configuration file being pass through `ldapConfigPath`. This requires a configuration file being pass through `ldapConfigPath`.
@ -129,15 +127,15 @@ in {
ldapConfigPath = mkOption { ldapConfigPath = mkOption {
type = types.path; type = types.path;
description = lib.mdDoc '' description = 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`.
See the [documentation](https://peering-manager.readthedocs.io/en/stable/setup/6-ldap/#configuration) for possible options. See the [documentation](https://peering-manager.readthedocs.io/en/stable/setup/6-ldap/#configuration) for possible options.
''; '';
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.peering-manager.plugins = mkIf cfg.enableLdap (ps: [ ps.django-auth-ldap ]); services.peering-manager.plugins = lib.mkIf cfg.enableLdap (ps: [ ps.django-auth-ldap ]);
system.build.peeringManagerPkg = pkg; system.build.peeringManagerPkg = pkg;