From 624f590fbaf8df6fb107f0a84ad14811a0096657 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:46 +0200 Subject: [PATCH 001/139] nixos/appstream: remove `with lib;` --- nixos/modules/config/appstream.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nixos/modules/config/appstream.nix b/nixos/modules/config/appstream.nix index 1712273eff7d..edac18b9ba36 100644 --- a/nixos/modules/config/appstream.nix +++ b/nixos/modules/config/appstream.nix @@ -1,10 +1,8 @@ { config, lib, ... }: - -with lib; { options = { - appstream.enable = mkOption { - type = types.bool; + appstream.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -13,7 +11,7 @@ with lib; }; }; - config = mkIf config.appstream.enable { + config = lib.mkIf config.appstream.enable { environment.pathsToLink = [ # per component metadata "/share/metainfo" From 9da369764a13d8cc3d200ae91b6e191ebf411e3d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:46 +0200 Subject: [PATCH 002/139] nixos/console: remove `with lib;` --- nixos/modules/config/console.nix | 78 +++++++++++++++----------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/nixos/modules/config/console.nix b/nixos/modules/config/console.nix index 5aadc0836fe7..9beb7dc58703 100644 --- a/nixos/modules/config/console.nix +++ b/nixos/modules/config/console.nix @@ -1,27 +1,23 @@ - { config, lib, pkgs, ... }: - -with lib; - let cfg = config.console; - makeColor = i: concatMapStringsSep "," (x: "0x" + substring (2*i) 2 x); + makeColor = i: lib.concatMapStringsSep "," (x: "0x" + lib.substring (2*i) 2 x); - isUnicode = hasSuffix "UTF-8" (toUpper config.i18n.defaultLocale); + isUnicode = lib.hasSuffix "UTF-8" (lib.toUpper config.i18n.defaultLocale); optimizedKeymap = pkgs.runCommand "keymap" { nativeBuildInputs = [ pkgs.buildPackages.kbd ]; LOADKEYS_KEYMAP_PATH = "${consoleEnv pkgs.kbd}/share/keymaps/**"; preferLocalBuild = true; } '' - loadkeys -b ${optionalString isUnicode "-u"} "${cfg.keyMap}" > $out + loadkeys -b ${lib.optionalString isUnicode "-u"} "${cfg.keyMap}" > $out ''; # Sadly, systemd-vconsole-setup doesn't support binary keymaps. vconsoleConf = pkgs.writeText "vconsole.conf" '' KEYMAP=${cfg.keyMap} - ${optionalString (cfg.font != null) "FONT=${cfg.font}"} + ${lib.optionalString (cfg.font != null) "FONT=${cfg.font}"} ''; consoleEnv = kbd: pkgs.buildEnv { @@ -40,12 +36,12 @@ in ###### interface options.console = { - enable = mkEnableOption "virtual console" // { + enable = lib.mkEnableOption "virtual console" // { default = true; }; - font = mkOption { - type = with types; nullOr (either str path); + font = lib.mkOption { + type = with lib.types; nullOr (either str path); default = null; example = "LatArCyrHeb-16"; description = '' @@ -61,8 +57,8 @@ in ''; }; - keyMap = mkOption { - type = with types; either str path; + keyMap = lib.mkOption { + type = with lib.types; either str path; default = "us"; example = "fr"; description = '' @@ -70,8 +66,8 @@ in ''; }; - colors = mkOption { - type = with types; listOf (strMatching "[[:xdigit:]]{6}"); + colors = lib.mkOption { + type = with lib.types; listOf (strMatching "[[:xdigit:]]{6}"); default = [ ]; example = [ "002b36" "dc322f" "859900" "b58900" @@ -88,8 +84,8 @@ in }; - packages = mkOption { - type = types.listOf types.package; + packages = lib.mkOption { + type = lib.types.listOf lib.types.package; default = [ ]; description = '' List of additional packages that provide console fonts, keymaps and @@ -97,8 +93,8 @@ in ''; }; - useXkbConfig = mkOption { - type = types.bool; + useXkbConfig = lib.mkOption { + type = lib.types.bool; default = false; description = '' If set, configure the virtual console keymap from the xserver @@ -106,9 +102,9 @@ in ''; }; - earlySetup = mkOption { + earlySetup = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Enable setting virtual console options as early as possible (in initrd). ''; @@ -119,12 +115,12 @@ in ###### implementation - config = mkMerge [ + config = lib.mkMerge [ { console.keyMap = with config.services.xserver; - mkIf cfg.useXkbConfig + lib.mkIf cfg.useXkbConfig (pkgs.runCommand "xkb-console-keymap" { preferLocalBuild = true; } '' '${pkgs.buildPackages.ckbcomp}/bin/ckbcomp' \ - ${optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT) + ${lib.optionalString (config.environment.sessionVariables ? XKB_CONFIG_ROOT) "-I${config.environment.sessionVariables.XKB_CONFIG_ROOT}" } \ -model '${xkb.model}' -layout '${xkb.layout}' \ @@ -132,7 +128,7 @@ in ''); } - (mkIf (!cfg.enable) { + (lib.mkIf (!cfg.enable) { systemd.services = { "serial-getty@ttyS0".enable = false; "serial-getty@hvc0".enable = false; @@ -142,7 +138,7 @@ in }; }) - (mkIf cfg.enable (mkMerge [ + (lib.mkIf cfg.enable (lib.mkMerge [ { environment.systemPackages = [ pkgs.kbd ]; # Let systemd-vconsole-setup.service do the work of setting up the @@ -151,12 +147,12 @@ in # Provide kbd with additional packages. environment.etc.kbd.source = "${consoleEnv pkgs.kbd}/share"; - boot.initrd.preLVMCommands = mkIf (!config.boot.initrd.systemd.enable) (mkBefore '' + boot.initrd.preLVMCommands = lib.mkIf (!config.boot.initrd.systemd.enable) (lib.mkBefore '' kbd_mode ${if isUnicode then "-u" else "-a"} -C /dev/console printf "\033%%${if isUnicode then "G" else "@"}" >> /dev/console loadkmap < ${optimizedKeymap} - ${optionalString (cfg.earlySetup && cfg.font != null) '' + ${lib.optionalString (cfg.earlySetup && cfg.font != null) '' setfont -C /dev/console $extraUtils/share/consolefonts/font.psf ''} ''); @@ -176,9 +172,9 @@ in "${config.boot.initrd.systemd.package.kbd}/bin/setfont" "${config.boot.initrd.systemd.package.kbd}/bin/loadkeys" "${config.boot.initrd.systemd.package.kbd.gzip}/bin/gzip" # Fonts and keyboard layouts are compressed - ] ++ optionals (cfg.font != null && hasPrefix builtins.storeDir cfg.font) [ + ] ++ lib.optionals (cfg.font != null && lib.hasPrefix builtins.storeDir cfg.font) [ "${cfg.font}" - ] ++ optionals (hasPrefix builtins.storeDir cfg.keyMap) [ + ] ++ lib.optionals (lib.hasPrefix builtins.storeDir cfg.keyMap) [ "${cfg.keyMap}" ]; @@ -195,7 +191,7 @@ in }; } - (mkIf (cfg.colors != []) { + (lib.mkIf (cfg.colors != []) { boot.kernelParams = [ "vt.default_red=${makeColor 0 cfg.colors}" "vt.default_grn=${makeColor 1 cfg.colors}" @@ -203,10 +199,10 @@ in ]; }) - (mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) { + (lib.mkIf (cfg.earlySetup && cfg.font != null && !config.boot.initrd.systemd.enable) { boot.initrd.extraUtilsCommands = '' mkdir -p $out/share/consolefonts - ${if substring 0 1 cfg.font == "/" then '' + ${if lib.substring 0 1 cfg.font == "/" then '' font="${cfg.font}" '' else '' font="$(echo ${consoleEnv pkgs.kbd}/share/consolefonts/${cfg.font}.*)" @@ -222,14 +218,14 @@ in ]; imports = [ - (mkRenamedOptionModule [ "i18n" "consoleFont" ] [ "console" "font" ]) - (mkRenamedOptionModule [ "i18n" "consoleKeyMap" ] [ "console" "keyMap" ]) - (mkRenamedOptionModule [ "i18n" "consoleColors" ] [ "console" "colors" ]) - (mkRenamedOptionModule [ "i18n" "consolePackages" ] [ "console" "packages" ]) - (mkRenamedOptionModule [ "i18n" "consoleUseXkbConfig" ] [ "console" "useXkbConfig" ]) - (mkRenamedOptionModule [ "boot" "earlyVconsoleSetup" ] [ "console" "earlySetup" ]) - (mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ]) - (mkRemovedOptionModule [ "console" "extraTTYs" ] '' + (lib.mkRenamedOptionModule [ "i18n" "consoleFont" ] [ "console" "font" ]) + (lib.mkRenamedOptionModule [ "i18n" "consoleKeyMap" ] [ "console" "keyMap" ]) + (lib.mkRenamedOptionModule [ "i18n" "consoleColors" ] [ "console" "colors" ]) + (lib.mkRenamedOptionModule [ "i18n" "consolePackages" ] [ "console" "packages" ]) + (lib.mkRenamedOptionModule [ "i18n" "consoleUseXkbConfig" ] [ "console" "useXkbConfig" ]) + (lib.mkRenamedOptionModule [ "boot" "earlyVconsoleSetup" ] [ "console" "earlySetup" ]) + (lib.mkRenamedOptionModule [ "boot" "extraTTYs" ] [ "console" "extraTTYs" ]) + (lib.mkRemovedOptionModule [ "console" "extraTTYs" ] '' Since NixOS switched to systemd (circa 2012), TTYs have been spawned on demand, so there is no need to configure them manually. '') From 3ad0220687cd9b4abd6c8ffba461d84740253b8d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 003/139] debug-info: remove `with lib;` --- nixos/modules/config/debug-info.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/debug-info.nix b/nixos/modules/config/debug-info.nix index 05a2fd2ceeea..9bf3d82ace2a 100644 --- a/nixos/modules/config/debug-info.nix +++ b/nixos/modules/config/debug-info.nix @@ -1,13 +1,10 @@ { config, lib, ... }: - -with lib; - { options = { - environment.enableDebugInfo = mkOption { - type = types.bool; + environment.enableDebugInfo = lib.mkOption { + type = lib.types.bool; default = false; description = '' Some NixOS packages provide debug symbols. However, these are @@ -29,7 +26,7 @@ with lib; }; - config = mkIf config.environment.enableDebugInfo { + config = lib.mkIf config.environment.enableDebugInfo { # FIXME: currently disabled because /lib is already in # environment.pathsToLink, and we can't have both. From 58baef7c2cf84d0ced45947a49b2d985cfd1e67f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 004/139] nixos/fonts.fontDir: remove `with lib;` --- nixos/modules/config/fonts/fontdir.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/config/fonts/fontdir.nix b/nixos/modules/config/fonts/fontdir.nix index 7b21fe30f607..0181883d6c5c 100644 --- a/nixos/modules/config/fonts/fontdir.nix +++ b/nixos/modules/config/fonts/fontdir.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.fonts.fontDir; @@ -12,7 +9,7 @@ let find ${toString config.fonts.packages} -regex "$font_regexp" \ -exec ln -sf -t "$out/share/X11/fonts" '{}' \; cd "$out/share/X11/fonts" - ${optionalString cfg.decompressFonts '' + ${lib.optionalString cfg.decompressFonts '' ${pkgs.gzip}/bin/gunzip -f *.gz ''} ${pkgs.xorg.mkfontscale}/bin/mkfontscale @@ -27,8 +24,8 @@ in options = { fonts.fontDir = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to create a directory with links to all fonts in @@ -36,10 +33,10 @@ in ''; }; - decompressFonts = mkOption { - type = types.bool; + decompressFonts = lib.mkOption { + type = lib.types.bool; default = config.programs.xwayland.enable; - defaultText = literalExpression "config.programs.xwayland.enable"; + defaultText = lib.literalExpression "config.programs.xwayland.enable"; description = '' Whether to decompress fonts in {file}`/run/current-system/sw/share/X11/fonts`. @@ -49,7 +46,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ x11Fonts ]; environment.pathsToLink = [ "/share/X11/fonts" ]; @@ -61,7 +58,7 @@ in }; imports = [ - (mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ]) + (lib.mkRenamedOptionModule [ "fonts" "enableFontDir" ] [ "fonts" "fontDir" "enable" ]) ]; } From 7fece7e8ca26b5f5170d4b2c2ce91cd8205488f8 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 005/139] nixos/fonts.enableGhostscriptFonts: remove `with lib;` --- nixos/modules/config/fonts/ghostscript.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/fonts/ghostscript.nix b/nixos/modules/config/fonts/ghostscript.nix index 5db7c0ac7179..dd28c72bba76 100644 --- a/nixos/modules/config/fonts/ghostscript.nix +++ b/nixos/modules/config/fonts/ghostscript.nix @@ -1,11 +1,8 @@ { config, lib, pkgs, ... }: - -with lib; - { options = { - fonts.enableGhostscriptFonts = mkOption { - type = types.bool; + fonts.enableGhostscriptFonts = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to add the fonts provided by Ghostscript (such as @@ -17,7 +14,7 @@ with lib; }; - config = mkIf config.fonts.enableGhostscriptFonts { + config = lib.mkIf config.fonts.enableGhostscriptFonts { fonts.packages = [ pkgs.ghostscript.fonts ]; }; } From 6b9c5be4a6931c7065d4c921a84af1776e627c81 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 006/139] nixos/gtk.iconCache: remove `with lib;` --- nixos/modules/config/gtk/gtk-icon-cache.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/gtk/gtk-icon-cache.nix b/nixos/modules/config/gtk/gtk-icon-cache.nix index 0898260d4a59..d9d6031956a6 100644 --- a/nixos/modules/config/gtk/gtk-icon-cache.nix +++ b/nixos/modules/config/gtk/gtk-icon-cache.nix @@ -1,19 +1,17 @@ { config, lib, pkgs, ... }: - -with lib; { options = { - gtk.iconCache.enable = mkOption { - type = types.bool; + gtk.iconCache.enable = lib.mkOption { + type = lib.types.bool; default = config.services.xserver.enable; - defaultText = literalExpression "config.services.xserver.enable"; + defaultText = lib.literalExpression "config.services.xserver.enable"; description = '' Whether to build icon theme caches for GTK applications. ''; }; }; - config = mkIf config.gtk.iconCache.enable { + config = lib.mkIf config.gtk.iconCache.enable { # (Re)build icon theme caches # --------------------------- From e514851c46e48e1b1b1d65f4ae430c909ea2e8fa Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 007/139] nixos/networking.iproute2: remove `with lib;` --- nixos/modules/config/iproute2.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nixos/modules/config/iproute2.nix b/nixos/modules/config/iproute2.nix index 90f53c0eab69..1fa28a7a4c64 100644 --- a/nixos/modules/config/iproute2.nix +++ b/nixos/modules/config/iproute2.nix @@ -1,15 +1,12 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.networking.iproute2; in { options.networking.iproute2 = { - enable = mkEnableOption "copying IP route configuration files"; - rttablesExtraConfig = mkOption { - type = types.lines; + enable = lib.mkEnableOption "copying IP route configuration files"; + rttablesExtraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Verbatim lines to add to /etc/iproute2/rt_tables @@ -17,7 +14,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.etc."iproute2/rt_tables.d/nixos.conf" = { mode = "0644"; text = cfg.rttablesExtraConfig; From 88e6e9d4ac3dbaecb4349018584c518009f823a8 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:47 +0200 Subject: [PATCH 008/139] nixos/time: remove `with lib;` --- nixos/modules/config/locale.nix | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/config/locale.nix b/nixos/modules/config/locale.nix index 486246081ec6..2d64f1bce4bc 100644 --- a/nixos/modules/config/locale.nix +++ b/nixos/modules/config/locale.nix @@ -1,12 +1,9 @@ { config, lib, pkgs, ... }: - -with lib; - let tzdir = "${pkgs.tzdata}/share/zoneinfo"; - nospace = str: filter (c: c == " ") (stringToCharacters str) == []; - timezone = types.nullOr (types.addCheck types.str nospace) + nospace = str: lib.filter (c: c == " ") (lib.stringToCharacters str) == []; + timezone = lib.types.nullOr (lib.types.addCheck lib.types.str nospace) // { description = "null or string without spaces"; }; lcfg = config.location; @@ -18,7 +15,7 @@ in time = { - timeZone = mkOption { + timeZone = lib.mkOption { default = null; type = timezone; example = "America/New_York"; @@ -31,9 +28,9 @@ in ''; }; - hardwareClockInLocalTime = mkOption { + hardwareClockInLocalTime = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = "If set, keep the hardware clock in local time instead of UTC."; }; @@ -41,8 +38,8 @@ in location = { - latitude = mkOption { - type = types.float; + latitude = lib.mkOption { + type = lib.types.float; description = '' Your current latitude, between `-90.0` and `90.0`. Must be provided @@ -50,8 +47,8 @@ in ''; }; - longitude = mkOption { - type = types.float; + longitude = lib.mkOption { + type = lib.types.float; description = '' Your current longitude, between between `-180.0` and `180.0`. Must be @@ -59,8 +56,8 @@ in ''; }; - provider = mkOption { - type = types.enum [ "manual" "geoclue2" ]; + provider = lib.mkOption { + type = lib.types.enum [ "manual" "geoclue2" ]; default = "manual"; description = '' The location provider to use for determining your location. If set to @@ -75,7 +72,7 @@ in environment.sessionVariables.TZDIR = "/etc/zoneinfo"; - services.geoclue2.enable = mkIf (lcfg.provider == "geoclue2") true; + services.geoclue2.enable = lib.mkIf (lcfg.provider == "geoclue2") true; # This way services are restarted when tzdata changes. systemd.globalEnvironment.TZDIR = tzdir; From dd7e20e16ae12ea45d7c1a9a3eacf5e818aabbd3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 009/139] nixos/environment.memoryAllocator: remove `with lib;` --- nixos/modules/config/malloc.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nixos/modules/config/malloc.nix b/nixos/modules/config/malloc.nix index e414970b0be5..665cbdd27874 100644 --- a/nixos/modules/config/malloc.nix +++ b/nixos/modules/config/malloc.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: -with lib; - let cfg = config.environment.memoryAllocator; @@ -85,12 +83,12 @@ in { meta = { - maintainers = [ maintainers.joachifm ]; + maintainers = [ lib.maintainers.joachifm ]; }; options = { - environment.memoryAllocator.provider = mkOption { - type = types.enum ([ "libc" ] ++ attrNames providers); + environment.memoryAllocator.provider = lib.mkOption { + type = lib.types.enum ([ "libc" ] ++ lib.attrNames providers); default = "libc"; description = '' The system-wide memory allocator. @@ -98,8 +96,8 @@ in Briefly, the system-wide memory allocator providers are: - `libc`: the standard allocator provided by libc - ${concatStringsSep "\n" (mapAttrsToList - (name: value: "- `${name}`: ${replaceStrings [ "\n" ] [ " " ] value.description}") + ${lib.concatStringsSep "\n" (lib.mapAttrsToList + (name: value: "- `${name}`: ${lib.replaceStrings [ "\n" ] [ " " ] value.description}") providers)} ::: {.warning} @@ -111,7 +109,7 @@ in }; }; - config = mkIf (cfg.provider != "libc") { + config = lib.mkIf (cfg.provider != "libc") { environment.etc."ld-nix.so.preload".text = '' ${providerLibPath} ''; From b5b0edaf37e12ee2b6aef7e12317b85609804ea3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 010/139] nixos/networking: remove `with lib;` --- nixos/modules/config/networking.nix | 84 ++++++++++++++--------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index 72242b263ce0..8665a611e575 100644 --- a/nixos/modules/config/networking.nix +++ b/nixos/modules/config/networking.nix @@ -1,28 +1,24 @@ # /etc files related to networking, such as /etc/services. - { config, lib, options, pkgs, ... }: - -with lib; - let cfg = config.networking; opt = options.networking; - localhostMultiple = any (elem "localhost") (attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ])); + localhostMultiple = lib.any (lib.elem "localhost") (lib.attrValues (removeAttrs cfg.hosts [ "127.0.0.1" "::1" ])); in { imports = [ - (mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.") + (lib.mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.") ]; options = { networking.hosts = lib.mkOption { - type = types.attrsOf (types.listOf types.str); - example = literalExpression '' + type = lib.types.attrsOf (lib.types.listOf lib.types.str); + example = lib.literalExpression '' { "127.0.0.1" = [ "foo.bar.baz" ]; "192.168.0.2" = [ "fileserver.local" "nameserver.local" ]; @@ -34,16 +30,16 @@ in }; networking.hostFiles = lib.mkOption { - type = types.listOf types.path; - defaultText = literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`"; - example = literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]''; + type = lib.types.listOf lib.types.path; + defaultText = lib.literalMD "Hosts from {option}`networking.hosts` and {option}`networking.extraHosts`"; + example = lib.literalExpression ''[ "''${pkgs.my-blocklist-package}/share/my-blocklist/hosts" ]''; description = '' Files that should be concatenated together to form {file}`/etc/hosts`. ''; }; networking.extraHosts = lib.mkOption { - type = types.lines; + type = lib.types.lines; default = ""; example = "192.168.0.1 lanlocalhost"; description = '' @@ -52,14 +48,14 @@ in ''; }; - networking.timeServers = mkOption { + networking.timeServers = lib.mkOption { default = [ "0.nixos.pool.ntp.org" "1.nixos.pool.ntp.org" "2.nixos.pool.ntp.org" "3.nixos.pool.ntp.org" ]; - type = types.listOf types.str; + type = lib.types.listOf lib.types.str; description = '' The set of NTP servers from which to synchronise. ''; @@ -68,7 +64,7 @@ in networking.proxy = { default = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = null; description = '' This option specifies the default value for httpProxy, httpsProxy, ftpProxy and rsyncProxy. @@ -77,9 +73,9 @@ in }; httpProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = cfg.proxy.default; - defaultText = literalExpression "config.${opt.proxy.default}"; + defaultText = lib.literalExpression "config.${opt.proxy.default}"; description = '' This option specifies the http_proxy environment variable. ''; @@ -87,9 +83,9 @@ in }; httpsProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = cfg.proxy.default; - defaultText = literalExpression "config.${opt.proxy.default}"; + defaultText = lib.literalExpression "config.${opt.proxy.default}"; description = '' This option specifies the https_proxy environment variable. ''; @@ -97,9 +93,9 @@ in }; ftpProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = cfg.proxy.default; - defaultText = literalExpression "config.${opt.proxy.default}"; + defaultText = lib.literalExpression "config.${opt.proxy.default}"; description = '' This option specifies the ftp_proxy environment variable. ''; @@ -107,9 +103,9 @@ in }; rsyncProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = cfg.proxy.default; - defaultText = literalExpression "config.${opt.proxy.default}"; + defaultText = lib.literalExpression "config.${opt.proxy.default}"; description = '' This option specifies the rsync_proxy environment variable. ''; @@ -117,9 +113,9 @@ in }; allProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = cfg.proxy.default; - defaultText = literalExpression "config.${opt.proxy.default}"; + defaultText = lib.literalExpression "config.${opt.proxy.default}"; description = '' This option specifies the all_proxy environment variable. ''; @@ -127,7 +123,7 @@ in }; noProxy = lib.mkOption { - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; default = null; description = '' This option specifies the no_proxy environment variable. @@ -138,7 +134,7 @@ in }; envVars = lib.mkOption { - type = types.attrs; + type = lib.types.attrs; internal = true; default = {}; description = '' @@ -163,11 +159,11 @@ in # hostname and FQDN correctly: networking.hosts = let hostnames = # Note: The FQDN (canonical hostname) has to come first: - optional (cfg.hostName != "" && cfg.domain != null) "${cfg.hostName}.${cfg.domain}" - ++ optional (cfg.hostName != "") cfg.hostName; # Then the hostname (without the domain) + lib.optional (cfg.hostName != "" && cfg.domain != null) "${cfg.hostName}.${cfg.domain}" + ++ lib.optional (cfg.hostName != "") cfg.hostName; # Then the hostname (without the domain) in { "127.0.0.2" = hostnames; - } // optionalAttrs cfg.enableIPv6 { + } // lib.optionalAttrs cfg.enableIPv6 { "::1" = hostnames; }; @@ -178,15 +174,15 @@ in # FQDN so that e.g. "hostname -f" works correctly. localhostHosts = pkgs.writeText "localhost-hosts" '' 127.0.0.1 localhost - ${optionalString cfg.enableIPv6 "::1 localhost"} + ${lib.optionalString cfg.enableIPv6 "::1 localhost"} ''; stringHosts = let - oneToString = set: ip: ip + " " + concatStringsSep " " set.${ip} + "\n"; - allToString = set: concatMapStrings (oneToString set) (attrNames set); - in pkgs.writeText "string-hosts" (allToString (filterAttrs (_: v: v != []) cfg.hosts)); + oneToString = set: ip: ip + " " + lib.concatStringsSep " " set.${ip} + "\n"; + allToString = set: lib.concatMapStrings (oneToString set) (lib.attrNames set); + in pkgs.writeText "string-hosts" (allToString (lib.filterAttrs (_: v: v != []) cfg.hosts)); extraHosts = pkgs.writeText "extra-hosts" cfg.extraHosts; - in mkBefore [ localhostHosts stringHosts extraHosts ]; + in lib.mkBefore [ localhostHosts stringHosts extraHosts ]; environment.etc = { # /etc/services: TCP/UDP port assignments. @@ -199,33 +195,33 @@ in hosts.source = pkgs.concatText "hosts" cfg.hostFiles; # /etc/netgroup: Network-wide groups. - netgroup.text = mkDefault ""; + netgroup.text = lib.mkDefault ""; # /etc/host.conf: resolver configuration file "host.conf".text = '' multi on ''; - } // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") { + } // lib.optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") { # /etc/rpc: RPC program numbers. rpc.source = pkgs.stdenv.cc.libc.out + "/etc/rpc"; }; networking.proxy.envVars = - optionalAttrs (cfg.proxy.default != null) { + lib.optionalAttrs (cfg.proxy.default != null) { # other options already fallback to proxy.default no_proxy = "127.0.0.1,localhost"; - } // optionalAttrs (cfg.proxy.httpProxy != null) { + } // lib.optionalAttrs (cfg.proxy.httpProxy != null) { http_proxy = cfg.proxy.httpProxy; - } // optionalAttrs (cfg.proxy.httpsProxy != null) { + } // lib.optionalAttrs (cfg.proxy.httpsProxy != null) { https_proxy = cfg.proxy.httpsProxy; - } // optionalAttrs (cfg.proxy.rsyncProxy != null) { + } // lib.optionalAttrs (cfg.proxy.rsyncProxy != null) { rsync_proxy = cfg.proxy.rsyncProxy; - } // optionalAttrs (cfg.proxy.ftpProxy != null) { + } // lib.optionalAttrs (cfg.proxy.ftpProxy != null) { ftp_proxy = cfg.proxy.ftpProxy; - } // optionalAttrs (cfg.proxy.allProxy != null) { + } // lib.optionalAttrs (cfg.proxy.allProxy != null) { all_proxy = cfg.proxy.allProxy; - } // optionalAttrs (cfg.proxy.noProxy != null) { + } // lib.optionalAttrs (cfg.proxy.noProxy != null) { no_proxy = cfg.proxy.noProxy; }; From 87c8da00faf61e1751545eb98fd48c249f92820b Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 011/139] nixos/environment.noXlibs: remove `with lib;` --- nixos/modules/config/no-x-libs.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nixos/modules/config/no-x-libs.nix b/nixos/modules/config/no-x-libs.nix index 2448d08a2399..e3fd0b34ddf4 100644 --- a/nixos/modules/config/no-x-libs.nix +++ b/nixos/modules/config/no-x-libs.nix @@ -1,14 +1,10 @@ # This module gets rid of all dependencies on X11 client libraries # (including fontconfig). - { config, lib, ... }: - -with lib; - { options = { - environment.noXlibs = mkOption { - type = types.bool; + environment.noXlibs = lib.mkOption { + type = lib.types.bool; default = false; description = '' Switch off the options in the default configuration that @@ -20,13 +16,13 @@ with lib; }; }; - config = mkIf config.environment.noXlibs { + config = lib.mkIf config.environment.noXlibs { programs.ssh.setXAuthLocation = false; security.pam.services.su.forwardXAuth = lib.mkForce false; fonts.fontconfig.enable = false; - nixpkgs.overlays = singleton (const (super: { + nixpkgs.overlays = lib.singleton (lib.const (super: { beam = super.beam_nox; cairo = super.cairo.override { x11Support = false; }; dbus = super.dbus.override { x11Support = false; }; @@ -81,7 +77,7 @@ with lib; ]; qemu = super.qemu.override { gtkSupport = false; spiceSupport = false; sdlSupport = false; }; qrencode = super.qrencode.overrideAttrs (_: { doCheck = false; }); - qt5 = super.qt5.overrideScope (const (super': { + qt5 = super.qt5.overrideScope (lib.const (super': { qtbase = super'.qtbase.override { withGtk3 = false; withQttranslation = false; }; })); stoken = super.stoken.override { withGTK3 = false; }; From d65b7dbb293741840ebf1e2c5b29a1eee1763e2f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 012/139] nixos/system.nss*: remove `with lib;` --- nixos/modules/config/nsswitch.nix | 64 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix index fe0402ee9e66..71c79eafeb09 100644 --- a/nixos/modules/config/nsswitch.nix +++ b/nixos/modules/config/nsswitch.nix @@ -1,16 +1,12 @@ # Configuration for the Name Service Switch (/etc/nsswitch.conf). - { config, lib, pkgs, ... }: - -with lib; - { options = { # NSS modules. Hacky! # Only works with nscd! - system.nssModules = mkOption { - type = types.listOf types.path; + system.nssModules = lib.mkOption { + type = lib.types.listOf lib.types.path; internal = true; default = [ ]; description = '' @@ -21,13 +17,13 @@ with lib; apply = list: { inherit list; - path = makeLibraryPath list; + path = lib.makeLibraryPath list; }; }; system.nssDatabases = { - passwd = mkOption { - type = types.listOf types.str; + passwd = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of passwd entries to configure in {file}`/etc/nsswitch.conf`. @@ -38,8 +34,8 @@ with lib; default = [ ]; }; - group = mkOption { - type = types.listOf types.str; + group = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of group entries to configure in {file}`/etc/nsswitch.conf`. @@ -50,8 +46,8 @@ with lib; default = [ ]; }; - shadow = mkOption { - type = types.listOf types.str; + shadow = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of shadow entries to configure in {file}`/etc/nsswitch.conf`. @@ -62,8 +58,8 @@ with lib; default = [ ]; }; - sudoers = mkOption { - type = types.listOf types.str; + sudoers = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of sudoers entries to configure in {file}`/etc/nsswitch.conf`. @@ -74,8 +70,8 @@ with lib; default = [ ]; }; - hosts = mkOption { - type = types.listOf types.str; + hosts = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of hosts entries to configure in {file}`/etc/nsswitch.conf`. @@ -86,8 +82,8 @@ with lib; default = [ ]; }; - services = mkOption { - type = types.listOf types.str; + services = lib.mkOption { + type = lib.types.listOf lib.types.str; description = '' List of services entries to configure in {file}`/etc/nsswitch.conf`. @@ -101,7 +97,7 @@ with lib; }; imports = [ - (mkRenamedOptionModule [ "system" "nssHosts" ] [ "system" "nssDatabases" "hosts" ]) + (lib.mkRenamedOptionModule [ "system" "nssHosts" ] [ "system" "nssDatabases" "hosts" ]) ]; config = { @@ -121,30 +117,30 @@ with lib; # Name Service Switch configuration file. Required by the C # library. environment.etc."nsswitch.conf".text = '' - passwd: ${concatStringsSep " " config.system.nssDatabases.passwd} - group: ${concatStringsSep " " config.system.nssDatabases.group} - shadow: ${concatStringsSep " " config.system.nssDatabases.shadow} - sudoers: ${concatStringsSep " " config.system.nssDatabases.sudoers} + passwd: ${lib.concatStringsSep " " config.system.nssDatabases.passwd} + group: ${lib.concatStringsSep " " config.system.nssDatabases.group} + shadow: ${lib.concatStringsSep " " config.system.nssDatabases.shadow} + sudoers: ${lib.concatStringsSep " " config.system.nssDatabases.sudoers} - hosts: ${concatStringsSep " " config.system.nssDatabases.hosts} + hosts: ${lib.concatStringsSep " " config.system.nssDatabases.hosts} networks: files ethers: files - services: ${concatStringsSep " " config.system.nssDatabases.services} + services: ${lib.concatStringsSep " " config.system.nssDatabases.services} protocols: files rpc: files ''; system.nssDatabases = { - passwd = mkBefore [ "files" ]; - group = mkBefore [ "files" ]; - shadow = mkBefore [ "files" ]; - sudoers = mkBefore [ "files" ]; - hosts = mkMerge [ - (mkOrder 998 [ "files" ]) - (mkOrder 1499 [ "dns" ]) + passwd = lib.mkBefore [ "files" ]; + group = lib.mkBefore [ "files" ]; + shadow = lib.mkBefore [ "files" ]; + sudoers = lib.mkBefore [ "files" ]; + hosts = lib.mkMerge [ + (lib.mkOrder 998 [ "files" ]) + (lib.mkOrder 1499 [ "dns" ]) ]; - services = mkBefore [ "files" ]; + services = lib.mkBefore [ "files" ]; }; }; } From 58258bd1709649730216709642aaabcf23caea05 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:48 +0200 Subject: [PATCH 013/139] nixos/powerManagement: remove `with lib;` --- nixos/modules/config/power-management.nix | 25 ++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/config/power-management.nix b/nixos/modules/config/power-management.nix index 70f2d199df10..524a23edab64 100644 --- a/nixos/modules/config/power-management.nix +++ b/nixos/modules/config/power-management.nix @@ -1,7 +1,4 @@ { config, lib, ... }: - -with lib; - let cfg = config.powerManagement; @@ -16,8 +13,8 @@ in powerManagement = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to enable power management. This includes support @@ -25,16 +22,16 @@ in ''; }; - resumeCommands = mkOption { - type = types.lines; + resumeCommands = lib.mkOption { + type = lib.types.lines; default = ""; description = "Commands executed after the system resumes from suspend-to-RAM."; }; - powerUpCommands = mkOption { - type = types.lines; + powerUpCommands = lib.mkOption { + type = lib.types.lines; default = ""; - example = literalExpression '' + example = lib.literalExpression '' "''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda" ''; description = '' @@ -44,10 +41,10 @@ in ''; }; - powerDownCommands = mkOption { - type = types.lines; + powerDownCommands = lib.mkOption { + type = lib.types.lines; default = ""; - example = literalExpression '' + example = lib.literalExpression '' "''${pkgs.hdparm}/sbin/hdparm -B 255 /dev/sda" ''; description = '' @@ -64,7 +61,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.targets.post-resume = { description = "Post-Resume Actions"; From c39ad4446245f73593a3a3e4a6153a588c298ee7 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 014/139] nixos/networking.resolvconf: remove `with lib;` --- nixos/modules/config/resolvconf.nix | 64 ++++++++++++++--------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/nixos/modules/config/resolvconf.nix b/nixos/modules/config/resolvconf.nix index 002a06be39a3..9fee272410dc 100644 --- a/nixos/modules/config/resolvconf.nix +++ b/nixos/modules/config/resolvconf.nix @@ -1,17 +1,13 @@ # /etc files related to networking, such as /etc/services. - { config, lib, pkgs, ... }: - -with lib; - let cfg = config.networking.resolvconf; resolvconfOptions = cfg.extraOptions - ++ optional cfg.dnsSingleRequest "single-request" - ++ optional cfg.dnsExtensionMechanism "edns0" - ++ optional cfg.useLocalResolver "trust-ad"; + ++ lib.optional cfg.dnsSingleRequest "single-request" + ++ lib.optional cfg.dnsExtensionMechanism "edns0" + ++ lib.optional cfg.useLocalResolver "trust-ad"; configText = '' @@ -19,46 +15,46 @@ let # a collision with an apparently unrelated environment # variable with the same name exported by dhcpcd. interface_order='lo lo[0-9]*' - '' + optionalString config.services.nscd.enable '' + '' + lib.optionalString config.services.nscd.enable '' # Invalidate the nscd cache whenever resolv.conf is # regenerated. libc_restart='/run/current-system/systemd/bin/systemctl try-restart --no-block nscd.service 2> /dev/null' - '' + optionalString (length resolvconfOptions > 0) '' + '' + lib.optionalString (lib.length resolvconfOptions > 0) '' # Options as described in resolv.conf(5) - resolv_conf_options='${concatStringsSep " " resolvconfOptions}' - '' + optionalString cfg.useLocalResolver '' + resolv_conf_options='${lib.concatStringsSep " " resolvconfOptions}' + '' + lib.optionalString cfg.useLocalResolver '' # This hosts runs a full-blown DNS resolver. - name_servers='127.0.0.1${optionalString config.networking.enableIPv6 " ::1"}' + name_servers='127.0.0.1${lib.optionalString config.networking.enableIPv6 " ::1"}' '' + cfg.extraConfig; in { imports = [ - (mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ]) - (mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ]) - (mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ]) - (mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ]) - (mkRemovedOptionModule [ "networking" "resolvconf" "useHostResolvConf" ] "This option was never used for anything anyways") + (lib.mkRenamedOptionModule [ "networking" "dnsSingleRequest" ] [ "networking" "resolvconf" "dnsSingleRequest" ]) + (lib.mkRenamedOptionModule [ "networking" "dnsExtensionMechanism" ] [ "networking" "resolvconf" "dnsExtensionMechanism" ]) + (lib.mkRenamedOptionModule [ "networking" "extraResolvconfConf" ] [ "networking" "resolvconf" "extraConfig" ]) + (lib.mkRenamedOptionModule [ "networking" "resolvconfOptions" ] [ "networking" "resolvconf" "extraOptions" ]) + (lib.mkRemovedOptionModule [ "networking" "resolvconf" "useHostResolvConf" ] "This option was never used for lib.anything lib.anyways") ]; options = { networking.resolvconf = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = !(config.environment.etc ? "resolv.conf"); - defaultText = literalExpression ''!(config.environment.etc ? "resolv.conf")''; + defaultText = lib.literalExpression ''!(config.environment.etc ? "resolv.conf")''; description = '' Whether DNS configuration is managed by resolvconf. ''; }; - package = mkOption { - type = types.package; + package = lib.mkOption { + type = lib.types.package; default = pkgs.openresolv; - defaultText = literalExpression "pkgs.openresolv"; + defaultText = lib.literalExpression "pkgs.openresolv"; description = '' The package that provides the system-wide resolvconf command. Defaults to `openresolv` if this module is enabled. Otherwise, can be used by other modules (for example {option}`services.resolved`) to @@ -69,7 +65,7 @@ in }; dnsSingleRequest = lib.mkOption { - type = types.bool; + type = lib.types.bool; default = false; description = '' Recent versions of glibc will issue both ipv4 (A) and ipv6 (AAAA) @@ -81,8 +77,8 @@ in ''; }; - dnsExtensionMechanism = mkOption { - type = types.bool; + dnsExtensionMechanism = lib.mkOption { + type = lib.types.bool; default = true; description = '' Enable the `edns0` option in {file}`resolv.conf`. With @@ -92,8 +88,8 @@ in ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = "libc=NO"; description = '' @@ -101,8 +97,8 @@ in ''; }; - extraOptions = mkOption { - type = types.listOf types.str; + extraOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "ndots:1" "rotate" ]; description = '' @@ -110,8 +106,8 @@ in ''; }; - useLocalResolver = mkOption { - type = types.bool; + useLocalResolver = lib.mkOption { + type = lib.types.bool; default = false; description = '' Use local DNS server for resolving. @@ -122,7 +118,7 @@ in }; - config = mkMerge [ + config = lib.mkMerge [ { environment.etc."resolvconf.conf".text = if !cfg.enable then @@ -135,7 +131,7 @@ in else configText; } - (mkIf cfg.enable { + (lib.mkIf cfg.enable { networking.resolvconf.package = pkgs.openresolv; environment.systemPackages = [ cfg.package ]; From 21d7a61b1ad02a75f382486f64d5a06562626eff Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 015/139] nixos/environment: remove `with lib;` --- nixos/modules/config/system-environment.nix | 25 +++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/config/system-environment.nix b/nixos/modules/config/system-environment.nix index 3fd4ac730ab9..ef49701fb492 100644 --- a/nixos/modules/config/system-environment.nix +++ b/nixos/modules/config/system-environment.nix @@ -1,9 +1,6 @@ # This module defines a system-wide environment that will be # initialised by pam_env (that is, not only in shells). { config, lib, options, pkgs, ... }: - -with lib; - let cfg = config.environment; @@ -14,7 +11,7 @@ in options = { - environment.sessionVariables = mkOption { + environment.sessionVariables = lib.mkOption { default = {}; description = '' A set of environment variables used in the global environment. @@ -35,8 +32,8 @@ in inherit (options.environment.variables) type apply; }; - environment.profileRelativeSessionVariables = mkOption { - type = types.attrsOf (types.listOf types.str); + environment.profileRelativeSessionVariables = lib.mkOption { + type = lib.types.attrsOf (lib.types.listOf lib.types.str); example = { PATH = [ "/bin" ]; MANPATH = [ "/man" "/share/man" ]; }; description = '' Attribute set of environment variable used in the global @@ -63,8 +60,8 @@ in config = { environment.etc."pam/environment".text = let suffixedVariables = - flip mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes: - flip concatMap cfg.profiles (profile: + lib.flip lib.mapAttrs cfg.profileRelativeSessionVariables (envVar: suffixes: + lib.flip lib.concatMap cfg.profiles (profile: map (suffix: "${profile}${suffix}") suffixes ) ); @@ -72,15 +69,15 @@ in # We're trying to use the same syntax for PAM variables and env variables. # That means we need to map the env variables that people might use to their # equivalent PAM variable. - replaceEnvVars = replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"]; + replaceEnvVars = lib.replaceStrings ["$HOME" "$USER"] ["@{HOME}" "@{PAM_USER}"]; pamVariable = n: v: - ''${n} DEFAULT="${concatStringsSep ":" (map replaceEnvVars (toList v))}"''; + ''${n} DEFAULT="${lib.concatStringsSep ":" (map replaceEnvVars (lib.toList v))}"''; pamVariables = - concatStringsSep "\n" - (mapAttrsToList pamVariable - (zipAttrsWith (n: concatLists) + lib.concatStringsSep "\n" + (lib.mapAttrsToList pamVariable + (lib.zipAttrsWith (n: lib.concatLists) [ # Make sure security wrappers are prioritized without polluting # shell environments with an extra entry. Sessions which depend on @@ -89,7 +86,7 @@ in # environment from a shell. { PATH = [ config.security.wrapperDir ]; } - (mapAttrs (n: toList) cfg.sessionVariables) + (lib.mapAttrs (n: lib.toList) cfg.sessionVariables) suffixedVariables ])); in '' From d6666338463e9c33c741b93d076dc6d915a2cecf Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 016/139] nixos/environment.paths: remove `with lib;` --- nixos/modules/config/system-path.nix | 36 +++++++++++++--------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index 83353761b7b8..6757078dbd9f 100644 --- a/nixos/modules/config/system-path.nix +++ b/nixos/modules/config/system-path.nix @@ -1,13 +1,9 @@ # This module defines the packages that appear in # /run/current-system/sw. - { config, lib, pkgs, ... }: - -with lib; - let - requiredPackages = map (pkg: setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg) + requiredPackages = map (pkg: lib.setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg) [ pkgs.acl pkgs.attr pkgs.bashInteractive # bash with ncurses support @@ -48,9 +44,9 @@ let ]; defaultPackages = map - (n: let pkg = pkgs.${n}; in setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg) + (n: let pkg = pkgs.${n};in lib.setPrio ((pkg.meta.priority or lib.meta.defaultPriority) + 3) pkg) defaultPackageNames; - defaultPackagesText = "[ ${concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]"; + defaultPackagesText = "[ ${lib.concatMapStringsSep " " (n: "pkgs.${n}") defaultPackageNames } ]"; in @@ -59,10 +55,10 @@ in environment = { - systemPackages = mkOption { - type = types.listOf types.package; + systemPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; default = []; - example = literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; + example = lib.literalExpression "[ pkgs.firefox pkgs.thunderbird ]"; description = '' The set of packages that appear in /run/current-system/sw. These packages are @@ -74,10 +70,10 @@ in ''; }; - defaultPackages = mkOption { - type = types.listOf types.package; + defaultPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; default = defaultPackages; - defaultText = literalMD '' + defaultText = lib.literalMD '' these packages, with their `meta.priority` numerically increased (thus lowering their installation priority): @@ -97,8 +93,8 @@ in ''; }; - pathsToLink = mkOption { - type = types.listOf types.str; + pathsToLink = lib.mkOption { + type = lib.types.listOf lib.types.str; # Note: We need `/lib' to be among `pathsToLink' for NSS modules # to work. default = []; @@ -106,8 +102,8 @@ in description = "List of directories to be symlinked in {file}`/run/current-system/sw`."; }; - extraOutputsToInstall = mkOption { - type = types.listOf types.str; + extraOutputsToInstall = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "dev" "info" ]; description = '' @@ -119,8 +115,8 @@ in ''; }; - extraSetup = mkOption { - type = types.lines; + extraSetup = lib.mkOption { + type = lib.types.lines; default = ""; description = "Shell fragments to be run after the system environment has been created. This should only be used for things that need to modify the internals of the environment, e.g. generating MIME caches. The environment being built can be accessed at $out."; }; @@ -129,7 +125,7 @@ in system = { - path = mkOption { + path = lib.mkOption { internal = true; description = '' The packages you want in the boot environment. From 6232911ef50fa5372ab2515a4d6b8a1ce67c1900 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 017/139] nixos/environment.terminfo: remove `with lib;` --- nixos/modules/config/terminfo.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix index b538d749ffcb..bf8bc43d6bb5 100644 --- a/nixos/modules/config/terminfo.nix +++ b/nixos/modules/config/terminfo.nix @@ -1,23 +1,20 @@ # This module manages the terminfo database # and its integration in the system. { config, lib, pkgs, ... }: - -with lib; - { options = with lib; { - environment.enableAllTerminfo = mkOption { + environment.enableAllTerminfo = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Whether to install all terminfo outputs ''; }; - security.sudo.keepTerminfo = mkOption { + security.sudo.keepTerminfo = lib.mkOption { default = true; - type = types.bool; + type = lib.types.bool; description = '' Whether to preserve the `TERMINFO` and `TERMINFO_DIRS` environment variables, for `root` and the `wheel` group. @@ -28,10 +25,10 @@ with lib; config = { # can be generated with: - # attrNames (filterAttrs - # (_: drv: (builtins.tryEval (isDerivation drv && drv ? terminfo)).value) + # lib.attrNames (lib.filterAttrs + # (_: drv: (builtins.tryEval (lib.isDerivation drv && drv ? terminfo)).value) # pkgs) - environment.systemPackages = mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs.pkgsBuildBuild; [ + environment.systemPackages = lib.mkIf config.environment.enableAllTerminfo (map (x: x.terminfo) (with pkgs.pkgsBuildBuild; [ alacritty contour foot @@ -65,7 +62,7 @@ with lib; export TERM=$TERM ''; - security.sudo.extraConfig = mkIf config.security.sudo.keepTerminfo '' + security.sudo.extraConfig = lib.mkIf config.security.sudo.keepTerminfo '' # Keep terminfo database for root and %wheel. Defaults:root,%wheel env_keep+=TERMINFO_DIRS From a39c4671d8e48d214323560d6c195acbff5fd9f8 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 018/139] nixos/environment.unix-odbc-drivers.nix: remove `with lib;` --- nixos/modules/config/unix-odbc-drivers.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/modules/config/unix-odbc-drivers.nix b/nixos/modules/config/unix-odbc-drivers.nix index 28cf7e84b7bc..8bf7f3b28af6 100644 --- a/nixos/modules/config/unix-odbc-drivers.nix +++ b/nixos/modules/config/unix-odbc-drivers.nix @@ -1,7 +1,4 @@ { config, lib, ... }: - -with lib; - # unixODBC drivers (this solution is not perfect.. Because the user has to # ask the admin to add a driver.. but it's simple and works @@ -16,10 +13,10 @@ in { ###### interface options = { - environment.unixODBCDrivers = mkOption { - type = types.listOf types.package; + environment.unixODBCDrivers = lib.mkOption { + type = lib.types.listOf lib.types.package; default = []; - example = literalExpression "with pkgs.unixODBCDrivers; [ sqlite psql ]"; + example = lib.literalExpression "with pkgs.unixODBCDrivers; [ sqlite psql ]"; description = '' Specifies Unix ODBC drivers to be registered in {file}`/etc/odbcinst.ini`. You may also want to @@ -31,8 +28,8 @@ in { ###### implementation - config = mkIf (config.environment.unixODBCDrivers != []) { - environment.etc."odbcinst.ini".text = concatMapStringsSep "\n" iniDescription config.environment.unixODBCDrivers; + config = lib.mkIf (config.environment.unixODBCDrivers != []) { + environment.etc."odbcinst.ini".text = lib.concatMapStringsSep "\n" iniDescription config.environment.unixODBCDrivers; }; } From e50a74b6f9d8e13404ca0abd0ea5b14a0c894da2 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 019/139] nixos/vte: remove `with lib;` --- nixos/modules/config/vte.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nixos/modules/config/vte.nix b/nixos/modules/config/vte.nix index e0b48c3fb4a8..a86a148b54f9 100644 --- a/nixos/modules/config/vte.nix +++ b/nixos/modules/config/vte.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let vteInitSnippet = '' @@ -15,14 +12,14 @@ in { meta = { - maintainers = teams.gnome.members; + maintainers = lib.teams.gnome.members; }; options = { - programs.bash.vteIntegration = mkOption { + programs.bash.vteIntegration = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Whether to enable Bash integration for VTE terminals. This allows it to preserve the current directory of the shell @@ -30,9 +27,9 @@ in ''; }; - programs.zsh.vteIntegration = mkOption { + programs.zsh.vteIntegration = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Whether to enable Zsh integration for VTE terminals. This allows it to preserve the current directory of the shell @@ -42,12 +39,12 @@ in }; - config = mkMerge [ - (mkIf config.programs.bash.vteIntegration { - programs.bash.interactiveShellInit = mkBefore vteInitSnippet; + config = lib.mkMerge [ + (lib.mkIf config.programs.bash.vteIntegration { + programs.bash.interactiveShellInit = lib.mkBefore vteInitSnippet; }) - (mkIf config.programs.zsh.vteIntegration { + (lib.mkIf config.programs.zsh.vteIntegration { programs.zsh.interactiveShellInit = vteInitSnippet; }) ]; From 7f5a38f10004ff44b494fc433835e0563c5c1172 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:49 +0200 Subject: [PATCH 020/139] nixos/xdg.autostart: remove `with lib;` --- nixos/modules/config/xdg/autostart.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/xdg/autostart.nix b/nixos/modules/config/xdg/autostart.nix index acdb7cd3adc6..6f33f592cf57 100644 --- a/nixos/modules/config/xdg/autostart.nix +++ b/nixos/modules/config/xdg/autostart.nix @@ -1,14 +1,12 @@ { config, lib, ... }: - -with lib; { meta = { - maintainers = teams.freedesktop.members; + maintainers = lib.teams.freedesktop.members; }; options = { - xdg.autostart.enable = mkOption { - type = types.bool; + xdg.autostart.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -17,7 +15,7 @@ with lib; }; }; - config = mkIf config.xdg.autostart.enable { + config = lib.mkIf config.xdg.autostart.enable { environment.pathsToLink = [ "/etc/xdg/autostart" ]; From 1da2c432542927b7f013ded954d620e364b70287 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 021/139] nixos/xdg.icons: remove `with lib;` --- nixos/modules/config/xdg/icons.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/xdg/icons.nix b/nixos/modules/config/xdg/icons.nix index 3f198101d306..9e2b3c2e46e0 100644 --- a/nixos/modules/config/xdg/icons.nix +++ b/nixos/modules/config/xdg/icons.nix @@ -1,14 +1,12 @@ { config, lib, pkgs, ... }: - -with lib; { meta = { - maintainers = teams.freedesktop.members; + maintainers = lib.teams.freedesktop.members; }; options = { - xdg.icons.enable = mkOption { - type = types.bool; + xdg.icons.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -17,7 +15,7 @@ with lib; }; }; - config = mkIf config.xdg.icons.enable { + config = lib.mkIf config.xdg.icons.enable { environment.pathsToLink = [ "/share/icons" "/share/pixmaps" From 56adb6a6b233c9b1de0022586da1c88226e3b10a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 022/139] nixos/xdg.menus: remove `with lib;` --- nixos/modules/config/xdg/menus.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/xdg/menus.nix b/nixos/modules/config/xdg/menus.nix index 8510c2db654e..a71a46dd36cc 100644 --- a/nixos/modules/config/xdg/menus.nix +++ b/nixos/modules/config/xdg/menus.nix @@ -1,14 +1,12 @@ { config, lib, ... }: - -with lib; { meta = { - maintainers = teams.freedesktop.members; + maintainers = lib.teams.freedesktop.members; }; options = { - xdg.menus.enable = mkOption { - type = types.bool; + xdg.menus.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -17,7 +15,7 @@ with lib; }; }; - config = mkIf config.xdg.menus.enable { + config = lib.mkIf config.xdg.menus.enable { environment.pathsToLink = [ "/share/applications" "/share/desktop-directories" From 62782850ea60d8b97f066d28660e8e5288f4992e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 023/139] nixos/xdg.mime: remove `with lib;` --- nixos/modules/config/xdg/mime.nix | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/config/xdg/mime.nix b/nixos/modules/config/xdg/mime.nix index 2cd88be5b023..9bd1af397002 100644 --- a/nixos/modules/config/xdg/mime.nix +++ b/nixos/modules/config/xdg/mime.nix @@ -1,22 +1,19 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.xdg.mime; - associationOptions = with types; attrsOf ( - coercedTo (either (listOf str) str) (x: concatStringsSep ";" (toList x)) str + associationOptions = with lib.types; attrsOf ( + coercedTo (either (listOf str) str) (x: lib.concatStringsSep ";" (lib.toList x)) str ); in { meta = { - maintainers = teams.freedesktop.members ++ (with maintainers; [ figsoda ]); + maintainers = lib.teams.freedesktop.members ++ (with lib.maintainers; [ figsoda ]); }; options = { - xdg.mime.enable = mkOption { - type = types.bool; + xdg.mime.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -25,7 +22,7 @@ in ''; }; - xdg.mime.addedAssociations = mkOption { + xdg.mime.addedAssociations = lib.mkOption { type = associationOptions; default = {}; example = { @@ -39,7 +36,7 @@ in ''; }; - xdg.mime.defaultApplications = mkOption { + xdg.mime.defaultApplications = lib.mkOption { type = associationOptions; default = {}; example = { @@ -53,7 +50,7 @@ in ''; }; - xdg.mime.removedAssociations = mkOption { + xdg.mime.removedAssociations = lib.mkOption { type = associationOptions; default = {}; example = { @@ -68,13 +65,13 @@ in }; }; - config = mkIf cfg.enable { - environment.etc."xdg/mimeapps.list" = mkIf ( + config = lib.mkIf cfg.enable { + environment.etc."xdg/mimeapps.list" = lib.mkIf ( cfg.addedAssociations != {} || cfg.defaultApplications != {} || cfg.removedAssociations != {} ) { - text = generators.toINI { } { + text = lib.generators.toINI { } { "Added Associations" = cfg.addedAssociations; "Default Applications" = cfg.defaultApplications; "Removed Associations" = cfg.removedAssociations; From f3fff00d96fadd6d2fcb1b59ad20bddad8100da9 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 024/139] nixos/xdg.portal.lxqt: remove `with lib;` --- nixos/modules/config/xdg/portals/lxqt.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nixos/modules/config/xdg/portals/lxqt.nix b/nixos/modules/config/xdg/portals/lxqt.nix index 23a1622308bd..846c9b199437 100644 --- a/nixos/modules/config/xdg/portals/lxqt.nix +++ b/nixos/modules/config/xdg/portals/lxqt.nix @@ -1,18 +1,15 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.xdg.portal.lxqt; in { meta = { - maintainers = teams.lxqt.members; + maintainers = lib.teams.lxqt.members; }; options.xdg.portal.lxqt = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' the desktop portal for the LXQt desktop environment. This will add the `lxqt.xdg-desktop-portal-lxqt` @@ -20,10 +17,10 @@ in {option}`xdg.portal.extraPortals` option ''; - styles = mkOption { - type = types.listOf types.package; + styles = lib.mkOption { + type = lib.types.listOf lib.types.package; default = []; - example = literalExpression ''[ + example = lib.literalExpression ''[ pkgs.libsForQt5.qtstyleplugin-kvantum pkgs.breeze-qt5 pkgs.qtcurve @@ -36,7 +33,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { xdg.portal = { enable = true; extraPortals = [ From 352763b4406e16453fbc66e30b8b65e8fc9d2cee Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 025/139] nixos/xdg.portal.wlr: remove `with lib;` --- nixos/modules/config/xdg/portals/wlr.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nixos/modules/config/xdg/portals/wlr.nix b/nixos/modules/config/xdg/portals/wlr.nix index 954830eff2d3..ed09a31a86d7 100644 --- a/nixos/modules/config/xdg/portals/wlr.nix +++ b/nixos/modules/config/xdg/portals/wlr.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.xdg.portal.wlr; package = pkgs.xdg-desktop-portal-wlr; @@ -10,11 +7,11 @@ let in { meta = { - maintainers = with maintainers; [ minijackson ]; + maintainers = with lib.maintainers; [ minijackson ]; }; options.xdg.portal.wlr = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' desktop portal for wlroots-based desktops. This will add the `xdg-desktop-portal-wlr` package into @@ -22,7 +19,7 @@ in configuration file ''; - settings = mkOption { + settings = lib.mkOption { description = '' Configuration for `xdg-desktop-portal-wlr`. @@ -30,14 +27,14 @@ in values. ''; - type = types.submodule { + type = lib.types.submodule { freeformType = settingsFormat.type; }; default = { }; # Example taken from the manpage - example = literalExpression '' + example = lib.literalExpression '' { screencast = { output_name = "HDMI-A-1"; @@ -52,7 +49,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { xdg.portal = { enable = true; extraPortals = [ package ]; From 413bd7cb81286476e6ec63d8363d997dc59452cf Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:50 +0200 Subject: [PATCH 026/139] nixos/xdg.sounds: remove `with lib;` --- nixos/modules/config/xdg/sounds.nix | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nixos/modules/config/xdg/sounds.nix b/nixos/modules/config/xdg/sounds.nix index 0aae77fe0107..e19e23d72a47 100644 --- a/nixos/modules/config/xdg/sounds.nix +++ b/nixos/modules/config/xdg/sounds.nix @@ -1,14 +1,12 @@ { config, lib, pkgs, ... }: - -with lib; { meta = { - maintainers = teams.freedesktop.members; + maintainers = lib.teams.freedesktop.members; }; options = { - xdg.sounds.enable = mkOption { - type = types.bool; + xdg.sounds.enable = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to install files to support the @@ -17,7 +15,7 @@ with lib; }; }; - config = mkIf config.xdg.sounds.enable { + config = lib.mkIf config.xdg.sounds.enable { environment.systemPackages = [ pkgs.sound-theme-freedesktop ]; From be8d4ec87e4dff57d3fc26eae69e31ed5d8f9f58 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 027/139] nixos/hardware.acpilight: remove `with lib;` --- nixos/modules/hardware/acpilight.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nixos/modules/hardware/acpilight.nix b/nixos/modules/hardware/acpilight.nix index 2de448a265c7..211d18ceb11a 100644 --- a/nixos/modules/hardware/acpilight.nix +++ b/nixos/modules/hardware/acpilight.nix @@ -1,15 +1,13 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.hardware.acpilight; in { options = { hardware.acpilight = { - enable = mkOption { + enable = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Enable acpilight. This will allow brightness control via xbacklight from users in the video group @@ -18,7 +16,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ acpilight ]; services.udev.packages = with pkgs; [ acpilight ]; }; From 930af3e5333cf8aaae290851b43527a2f734719e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 028/139] nixos/hardware.enableAllFirmware: remove `with lib;` --- nixos/modules/hardware/all-firmware.nix | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/nixos/modules/hardware/all-firmware.nix b/nixos/modules/hardware/all-firmware.nix index abad6e08611f..6475cfc843d2 100644 --- a/nixos/modules/hardware/all-firmware.nix +++ b/nixos/modules/hardware/all-firmware.nix @@ -1,33 +1,30 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware; in { imports = [ - (mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ]) - (mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) - (mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) - (mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) - (mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) + (lib.mkRenamedOptionModule [ "networking" "enableRT73Firmware" ] [ "hardware" "enableRedistributableFirmware" ]) + (lib.mkRenamedOptionModule [ "networking" "enableIntel3945ABGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) + (lib.mkRenamedOptionModule [ "networking" "enableIntel2100BGFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) + (lib.mkRenamedOptionModule [ "networking" "enableRalinkFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) + (lib.mkRenamedOptionModule [ "networking" "enableRTL8192cFirmware" ] [ "hardware" "enableRedistributableFirmware" ]) ]; ###### interface options = { - hardware.enableAllFirmware = mkEnableOption "all firmware regardless of license"; + hardware.enableAllFirmware = lib.mkEnableOption "all firmware regardless of license"; - hardware.enableRedistributableFirmware = mkEnableOption "firmware with a license allowing redistribution" // { + hardware.enableRedistributableFirmware = lib.mkEnableOption "firmware with a license allowing redistribution" // { default = config.hardware.enableAllFirmware; defaultText = lib.literalExpression "config.hardware.enableAllFirmware"; }; - hardware.wirelessRegulatoryDatabase = mkEnableOption "loading the wireless regulatory database at boot" // { + hardware.wirelessRegulatoryDatabase = lib.mkEnableOption "loading the wireless regulatory database at boot" // { default = cfg.enableRedistributableFirmware || cfg.enableAllFirmware; - defaultText = literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`."; + defaultText = lib.literalMD "Enabled if proprietary firmware is allowed via {option}`enableRedistributableFirmware` or {option}`enableAllFirmware`."; }; }; @@ -35,8 +32,8 @@ in { ###### implementation - config = mkMerge [ - (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) { + config = lib.mkMerge [ + (lib.mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) { hardware.firmware = with pkgs; [ linux-firmware intel2200BGFirmware @@ -47,9 +44,9 @@ in { alsa-firmware sof-firmware libreelec-dvb-firmware - ] ++ optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware; + ] ++ lib.optional pkgs.stdenv.hostPlatform.isAarch raspberrypiWirelessFirmware; }) - (mkIf cfg.enableAllFirmware { + (lib.mkIf cfg.enableAllFirmware { assertions = [{ assertion = !cfg.enableAllFirmware || pkgs.config.allowUnfree; message = '' @@ -63,12 +60,12 @@ in { b43Firmware_5_1_138 b43Firmware_6_30_163_46 xow_dongle-firmware - ] ++ optionals pkgs.stdenv.hostPlatform.isx86 [ + ] ++ lib.optionals pkgs.stdenv.hostPlatform.isx86 [ facetimehd-calibration facetimehd-firmware ]; }) - (mkIf cfg.wirelessRegulatoryDatabase { + (lib.mkIf cfg.wirelessRegulatoryDatabase { hardware.firmware = [ pkgs.wireless-regdb ]; }) ]; From 6c0e1c7a9d4dfb82d37bcdd833a15365b704116d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 029/139] nixos/hardware.bladeRF: remove `with lib;` --- nixos/modules/hardware/bladeRF.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/hardware/bladeRF.nix b/nixos/modules/hardware/bladeRF.nix index 35b74b8382e3..877acbbf598c 100644 --- a/nixos/modules/hardware/bladeRF.nix +++ b/nixos/modules/hardware/bladeRF.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.bladeRF; @@ -9,8 +6,8 @@ in { options.hardware.bladeRF = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enables udev rules for BladeRF devices. By default grants access @@ -21,7 +18,7 @@ in }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.udev.packages = [ pkgs.libbladeRF ]; users.groups.bladerf = {}; }; From 374ad8d316efba9d6a78a02e5e45f9744743f759 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 030/139] nixos/hardware.brillo: remove `with lib;` --- nixos/modules/hardware/brillo.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nixos/modules/hardware/brillo.nix b/nixos/modules/hardware/brillo.nix index 8e36022a9a30..915801c137be 100644 --- a/nixos/modules/hardware/brillo.nix +++ b/nixos/modules/hardware/brillo.nix @@ -1,20 +1,18 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.hardware.brillo; in { options = { hardware.brillo = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' brillo in userspace. This will allow brightness control from users in the video group ''; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.udev.packages = [ pkgs.brillo ]; environment.systemPackages = [ pkgs.brillo ]; }; From dd9302597298f0ac56399b8d3e781612b8737f96 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 031/139] nixos/hardware.ckb-next: remove `with lib;` --- nixos/modules/hardware/ckb-next.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/hardware/ckb-next.nix b/nixos/modules/hardware/ckb-next.nix index 1fb97c16d75f..5de5666d20c9 100644 --- a/nixos/modules/hardware/ckb-next.nix +++ b/nixos/modules/hardware/ckb-next.nix @@ -1,22 +1,19 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.ckb-next; in { imports = [ - (mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ]) - (mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ]) + (lib.mkRenamedOptionModule [ "hardware" "ckb" "enable" ] [ "hardware" "ckb-next" "enable" ]) + (lib.mkRenamedOptionModule [ "hardware" "ckb" "package" ] [ "hardware" "ckb-next" "package" ]) ]; options.hardware.ckb-next = { - enable = mkEnableOption "the Corsair keyboard/mouse driver"; + enable = lib.mkEnableOption "the Corsair keyboard/mouse driver"; - gid = mkOption { - type = types.nullOr types.int; + gid = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; example = 100; description = '' @@ -24,17 +21,17 @@ in ''; }; - package = mkPackageOption pkgs "ckb-next" { }; + package = lib.mkPackageOption pkgs "ckb-next" { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; systemd.services.ckb-next = { description = "Corsair Keyboards and Mice Daemon"; wantedBy = ["multi-user.target"]; serviceConfig = { - ExecStart = "${cfg.package}/bin/ckb-next-daemon ${optionalString (cfg.gid != null) "--gid=${builtins.toString cfg.gid}"}"; + ExecStart = "${cfg.package}/bin/ckb-next-daemon ${lib.optionalString (cfg.gid != null) "--gid=${builtins.toString cfg.gid}"}"; Restart = "on-failure"; }; }; From f41312d75139b832d1684f39632cdd0c57509540 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:51 +0200 Subject: [PATCH 032/139] nixos/hardware.corectrl: remove `with lib;` --- nixos/modules/hardware/corectrl.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nixos/modules/hardware/corectrl.nix b/nixos/modules/hardware/corectrl.nix index 9e8b69cf6277..88b94e12f6b6 100644 --- a/nixos/modules/hardware/corectrl.nix +++ b/nixos/modules/hardware/corectrl.nix @@ -1,27 +1,24 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.programs.corectrl; in { options.programs.corectrl = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' CoreCtrl, a tool to overclock amd graphics cards and processors. Add your user to the corectrl group to run corectrl without needing to enter your password ''; - package = mkPackageOption pkgs "corectrl" { + package = lib.mkPackageOption pkgs "corectrl" { extraDescription = "Useful for overriding the configuration options used for the package."; }; gpuOverclock = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' GPU overclocking ''; - ppfeaturemask = mkOption { - type = types.str; + ppfeaturemask = lib.mkOption { + type = lib.types.str; default = "0xfffd7fff"; example = "0xffffffff"; description = '' @@ -34,7 +31,7 @@ in }; }; - config = mkIf cfg.enable (lib.mkMerge [ + config = lib.mkIf cfg.enable (lib.mkMerge [ { environment.systemPackages = [ cfg.package ]; From 0dac464dc87885c2abac56618172389a30c32053 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 033/139] nixos/hardware/deviceTree: remove `with lib;` --- nixos/modules/hardware/device-tree.nix | 83 +++++++++++++------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/nixos/modules/hardware/device-tree.nix b/nixos/modules/hardware/device-tree.nix index a29cc76ea8f9..b3feedf1edad 100644 --- a/nixos/modules/hardware/device-tree.nix +++ b/nixos/modules/hardware/device-tree.nix @@ -1,21 +1,18 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.deviceTree; - overlayType = types.submodule { + overlayType = lib.types.submodule { options = { - name = mkOption { - type = types.str; + name = lib.mkOption { + type = lib.types.str; description = '' Name of this overlay ''; }; - filter = mkOption { - type = types.nullOr types.str; + filter = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "*rpi*.dtb"; description = '' @@ -23,18 +20,18 @@ let ''; }; - dtsFile = mkOption { - type = types.nullOr types.path; + dtsFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; description = '' Path to .dts overlay file, overlay is applied to each .dtb file matching "compatible" of the overlay. ''; default = null; - example = literalExpression "./dts/overlays.dts"; + example = lib.literalExpression "./dts/overlays.dts"; }; - dtsText = mkOption { - type = types.nullOr types.str; + dtsText = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Literal DTS contents, overlay is applied to @@ -55,8 +52,8 @@ let ''; }; - dtboFile = mkOption { - type = types.nullOr types.path; + dtboFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Path to .dtbo compiled overlay file. @@ -79,9 +76,9 @@ let # Fill in `dtboFile` for each overlay if not set already. # Existence of one of these is guarded by assertion below - withDTBOs = xs: flip map xs (o: o // { dtboFile = + withDTBOs = xs: lib.flip map xs (o: o // { dtboFile = let - includePaths = ["${getDev cfg.kernelPackage}/lib/modules/${cfg.kernelPackage.modDirVersion}/source/scripts/dtc/include-prefixes"] ++ cfg.dtboBuildExtraIncludePaths; + includePaths = ["${lib.getDev cfg.kernelPackage}/lib/modules/${cfg.kernelPackage.modDirVersion}/source/scripts/dtc/include-prefixes"] ++ cfg.dtboBuildExtraIncludePaths; extraPreprocessorFlags = cfg.dtboBuildExtraPreprocessorFlags; in if o.dtboFile == null then @@ -97,67 +94,67 @@ let in { imports = [ - (mkRemovedOptionModule [ "hardware" "deviceTree" "base" ] "Use hardware.deviceTree.kernelPackage instead") + (lib.mkRemovedOptionModule [ "hardware" "deviceTree" "base" ] "Use hardware.deviceTree.kernelPackage instead") ]; options = { hardware.deviceTree = { - enable = mkOption { + enable = lib.mkOption { default = pkgs.stdenv.hostPlatform.linux-kernel.DTB or false; - type = types.bool; + type = lib.types.bool; description = '' Build device tree files. These are used to describe the non-discoverable hardware of a system. ''; }; - kernelPackage = mkOption { + kernelPackage = lib.mkOption { default = config.boot.kernelPackages.kernel; - defaultText = literalExpression "config.boot.kernelPackages.kernel"; - example = literalExpression "pkgs.linux_latest"; - type = types.path; + defaultText = lib.literalExpression "config.boot.kernelPackages.kernel"; + example = lib.literalExpression "pkgs.linux_latest"; + type = lib.types.path; description = '' Kernel package where device tree include directory is from. Also used as default source of dtb package to apply overlays to ''; }; - dtboBuildExtraPreprocessorFlags = mkOption { + dtboBuildExtraPreprocessorFlags = lib.mkOption { default = []; - example = literalExpression "[ \"-DMY_DTB_DEFINE\" ]"; - type = types.listOf types.str; + example = lib.literalExpression "[ \"-DMY_DTB_DEFINE\" ]"; + type = lib.types.listOf lib.types.str; description = '' Additional flags to pass to the preprocessor during dtbo compilations ''; }; - dtboBuildExtraIncludePaths = mkOption { + dtboBuildExtraIncludePaths = lib.mkOption { default = []; - example = literalExpression '' + example = lib.literalExpression '' [ ./my_custom_include_dir_1 ./custom_include_dir_2 ] ''; - type = types.listOf types.path; + type = lib.types.listOf lib.types.path; description = '' Additional include paths that will be passed to the preprocessor when creating the final .dts to compile into .dtbo ''; }; - dtbSource = mkOption { + dtbSource = lib.mkOption { default = "${cfg.kernelPackage}/dtbs"; - defaultText = literalExpression "\${cfg.kernelPackage}/dtbs"; - type = types.path; + defaultText = lib.literalExpression "\${cfg.kernelPackage}/dtbs"; + type = lib.types.path; description = '' Path to dtb directory that overlays and other processing will be applied to. Uses device trees bundled with the Linux kernel by default. ''; }; - name = mkOption { + name = lib.mkOption { default = null; example = "some-dtb.dtb"; - type = types.nullOr types.str; + type = lib.types.nullOr lib.types.str; description = '' The name of an explicit dtb to be loaded, relative to the dtb base. Useful in extlinux scenarios if the bootloader doesn't pick the @@ -165,8 +162,8 @@ in ''; }; - filter = mkOption { - type = types.nullOr types.str; + filter = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "*rpi*.dtb"; description = '' @@ -174,9 +171,9 @@ in ''; }; - overlays = mkOption { + overlays = lib.mkOption { default = []; - example = literalExpression '' + example = lib.literalExpression '' [ { name = "pps"; dtsFile = ./dts/pps.dts; } { name = "spi"; @@ -185,7 +182,7 @@ in { name = "precompiled"; dtboFile = ./dtbos/example.dtbo; } ] ''; - type = types.listOf (types.coercedTo types.path (path: { + type = lib.types.listOf (lib.types.coercedTo lib.types.path (path: { name = baseNameOf path; filter = null; dtboFile = path; @@ -195,9 +192,9 @@ in ''; }; - package = mkOption { + package = lib.mkOption { default = null; - type = types.nullOr types.path; + type = lib.types.nullOr lib.types.path; internal = true; description = '' A path containing the result of applying `overlays` to `kernelPackage`. @@ -206,7 +203,7 @@ in }; }; - config = mkIf (cfg.enable) { + config = lib.mkIf (cfg.enable) { assertions = let invalidOverlay = o: (o.dtsFile == null) && (o.dtsText == null) && (o.dtboFile == null); From 6f3aef9bde9cb88209c90f5a138c48ce25242c86 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 034/139] nixos/hardware.flipperzero: remove `with lib;` --- nixos/modules/hardware/flipperzero.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/hardware/flipperzero.nix b/nixos/modules/hardware/flipperzero.nix index 3a6d29d0f9eb..bda2e2c8e0a5 100644 --- a/nixos/modules/hardware/flipperzero.nix +++ b/nixos/modules/hardware/flipperzero.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.flipperzero; @@ -9,9 +6,9 @@ let in { - options.hardware.flipperzero.enable = mkEnableOption "udev rules and software for Flipper Zero devices"; + options.hardware.flipperzero.enable = lib.mkEnableOption "udev rules and software for Flipper Zero devices"; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.qFlipper ]; services.udev.packages = [ pkgs.qFlipper ]; }; From 166d20fb4623c0b92189456ee43b610dc37c0988 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 035/139] nixos/hardware.gkraken: remove `with lib;` --- nixos/modules/hardware/gkraken.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/hardware/gkraken.nix b/nixos/modules/hardware/gkraken.nix index 97d15369db0a..90b0069e80c8 100644 --- a/nixos/modules/hardware/gkraken.nix +++ b/nixos/modules/hardware/gkraken.nix @@ -1,16 +1,13 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.gkraken; in { options.hardware.gkraken = { - enable = mkEnableOption "gkraken's udev rules for NZXT AIO liquid coolers"; + enable = lib.mkEnableOption "gkraken's udev rules for NZXT AIO liquid coolers"; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.udev.packages = with pkgs; [ gkraken ]; From 6d731ad2dfa45a38c56391c8b4e3777727336692 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 036/139] nixos/hardware.gpgSmartcards: remove `with lib;` --- nixos/modules/hardware/gpgsmartcards.nix | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/nixos/modules/hardware/gpgsmartcards.nix b/nixos/modules/hardware/gpgsmartcards.nix index cc3f4c769976..3940efd09e22 100644 --- a/nixos/modules/hardware/gpgsmartcards.nix +++ b/nixos/modules/hardware/gpgsmartcards.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; let # gnupg's manual describes how to setup ccid udev rules: # https://www.gnupg.org/howtos/card-howto/en/ch02s03.html @@ -28,10 +26,10 @@ let cfg = config.hardware.gpgSmartcards; in { options.hardware.gpgSmartcards = { - enable = mkEnableOption "udev rules for gnupg smart cards"; + enable = lib.mkEnableOption "udev rules for gnupg smart cards"; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.udev.packages = [ scdaemonUdevRulesPkg ]; }; } From 58e31e0c2600557702885dac2789def907f9d4b1 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 037/139] nixos/hardware.i2c: remove `with lib;` --- nixos/modules/hardware/i2c.nix | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/nixos/modules/hardware/i2c.nix b/nixos/modules/hardware/i2c.nix index b1e5cfd9e025..4dd7a8ccc531 100644 --- a/nixos/modules/hardware/i2c.nix +++ b/nixos/modules/hardware/i2c.nix @@ -1,21 +1,18 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.i2c; in { options.hardware.i2c = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' i2c devices support. By default access is granted to users in the "i2c" group (will be created if non-existent) and any user with a seat, meaning logged on the computer locally ''; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "i2c"; description = '' Grant access to i2c devices (/dev/i2c-*) to users in this group. @@ -23,11 +20,11 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { boot.kernelModules = [ "i2c-dev" ]; - users.groups = mkIf (cfg.group == "i2c") { + users.groups = lib.mkIf (cfg.group == "i2c") { i2c = { }; }; @@ -42,6 +39,6 @@ in }; - meta.maintainers = [ maintainers.rnhmjoj ]; + meta.maintainers = [ lib.maintainers.rnhmjoj ]; } From e880cd15493165069b438e95513614ff0652952f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 038/139] nixos/hardware.infiniband: remove `with lib;` --- nixos/modules/hardware/infiniband.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nixos/modules/hardware/infiniband.nix b/nixos/modules/hardware/infiniband.nix index 6780aee9f36b..b09453116cf9 100644 --- a/nixos/modules/hardware/infiniband.nix +++ b/nixos/modules/hardware/infiniband.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.infiniband; @@ -31,9 +28,9 @@ in { options.hardware.infiniband = { - enable = mkEnableOption "Infiniband support"; - guids = mkOption { - type = with types; listOf str; + enable = lib.mkEnableOption "Infiniband support"; + guids = lib.mkOption { + type = with lib.types; listOf str; default = []; example = [ "0xe8ebd30000eee2e1" ]; description = '' @@ -42,7 +39,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { boot.initrd.kernelModules = [ "mlx5_core" "mlx5_ib" "ib_cm" "rdma_cm" "rdma_ucm" "rpcrdma" From 9856183d59264a4f000b147aa019f72cdfc3ed57 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:52 +0200 Subject: [PATCH 039/139] nixos/security.polkit: remove `with lib;` --- nixos/modules/security/polkit.nix | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nixos/modules/security/polkit.nix b/nixos/modules/security/polkit.nix index 76f623096fb7..eb783179af55 100644 --- a/nixos/modules/security/polkit.nix +++ b/nixos/modules/security/polkit.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.security.polkit; @@ -12,14 +9,14 @@ in options = { - security.polkit.enable = mkEnableOption "polkit"; + security.polkit.enable = lib.mkEnableOption "polkit"; - security.polkit.package = mkPackageOption pkgs "polkit" { }; + security.polkit.package = lib.mkPackageOption pkgs "polkit" { }; - security.polkit.debug = mkEnableOption "debug logs from polkit. This is required in order to see log messages from rule definitions"; + security.polkit.debug = lib.mkEnableOption "debug logs from polkit. This is required in order to see log messages from rule definitions"; - security.polkit.extraConfig = mkOption { - type = types.lines; + security.polkit.extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = '' @@ -41,8 +38,8 @@ in ''; }; - security.polkit.adminIdentities = mkOption { - type = types.listOf types.str; + security.polkit.adminIdentities = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "unix-group:wheel" ]; example = [ "unix-user:alice" "unix-group:admin" ]; description = @@ -57,7 +54,7 @@ in }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package.bin cfg.package.out ]; @@ -65,7 +62,7 @@ in systemd.services.polkit.serviceConfig.ExecStart = [ "" - "${cfg.package.out}/lib/polkit-1/polkitd ${optionalString (!cfg.debug) "--no-debug"}" + "${cfg.package.out}/lib/polkit-1/polkitd ${lib.optionalString (!cfg.debug) "--no-debug"}" ]; systemd.services.polkit.restartTriggers = [ config.system.path ]; @@ -78,7 +75,7 @@ in environment.etc."polkit-1/rules.d/10-nixos.rules".text = '' polkit.addAdminRule(function(action, subject) { - return [${concatStringsSep ", " (map (i: "\"${i}\"") cfg.adminIdentities)}]; + return [${lib.concatStringsSep ", " (map (i: "\"${i}\"") cfg.adminIdentities)}]; }); ${cfg.extraConfig} From 3e47355b3fdce34611c9d7ea64fd661f52110cd2 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:53 +0200 Subject: [PATCH 040/139] nixos/services.salt.master: remove `with lib;` --- nixos/modules/services/admin/salt/master.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/admin/salt/master.nix b/nixos/modules/services/admin/salt/master.nix index c447540da1f8..1ffe6b6cb27a 100644 --- a/nixos/modules/services/admin/salt/master.nix +++ b/nixos/modules/services/admin/salt/master.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.salt.master; @@ -20,16 +17,16 @@ in { options = { services.salt.master = { - enable = mkEnableOption "Salt configuration management system master service"; - configuration = mkOption { - type = types.attrs; + enable = lib.mkEnableOption "Salt configuration management system master service"; + configuration = lib.mkOption { + type = lib.types.attrs; default = {}; description = "Salt master configuration as Nix attribute set."; }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment = { # Set this up in /etc/salt/master so `salt`, `salt-key`, etc. work. # The alternatives are From 2d4f871b1a9532b71fc8e926de3e9cd22148b5f9 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:53 +0200 Subject: [PATCH 041/139] nixos/services.rabbitmq: remove `with lib;` --- nixos/modules/services/amqp/rabbitmq.nix | 67 +++++++++++------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/amqp/rabbitmq.nix b/nixos/modules/services/amqp/rabbitmq.nix index b5aebaaf1275..fba26591e0ba 100644 --- a/nixos/modules/services/amqp/rabbitmq.nix +++ b/nixos/modules/services/amqp/rabbitmq.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.rabbitmq; @@ -16,7 +13,7 @@ in { imports = [ - (mkRemovedOptionModule [ "services" "rabbitmq" "cookie" ] '' + (lib.mkRemovedOptionModule [ "services" "rabbitmq" "cookie" ] '' This option wrote the Erlang cookie to the store, while it should be kept secret. Please remove it from your NixOS configuration and deploy a cookie securely instead. The renamed `unsafeCookie` must ONLY be used in isolated non-production environments such as NixOS VM tests. @@ -26,8 +23,8 @@ in ###### interface options = { services.rabbitmq = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable the RabbitMQ server, an Advanced Message @@ -35,9 +32,9 @@ in ''; }; - package = mkPackageOption pkgs "rabbitmq-server" { }; + package = lib.mkPackageOption pkgs "rabbitmq-server" { }; - listenAddress = mkOption { + listenAddress = lib.mkOption { default = "127.0.0.1"; example = ""; description = '' @@ -52,28 +49,28 @@ in configItems."listeners.tcp.1" and it's left for backwards compatibility with previous version of this module. ''; - type = types.str; + type = lib.types.str; }; - port = mkOption { + port = lib.mkOption { default = 5672; description = '' Port on which RabbitMQ will listen for AMQP connections. ''; - type = types.port; + type = lib.types.port; }; - dataDir = mkOption { - type = types.path; + dataDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/rabbitmq"; description = '' Data directory for rabbitmq. ''; }; - unsafeCookie = mkOption { + unsafeCookie = lib.mkOption { default = ""; - type = types.str; + type = lib.types.str; description = '' Erlang cookie is a string of arbitrary length which must be the same for several nodes to be allowed to communicate. @@ -86,10 +83,10 @@ in ''; }; - configItems = mkOption { + configItems = lib.mkOption { default = { }; - type = types.attrsOf types.str; - example = literalExpression '' + type = lib.types.attrsOf lib.types.str; + example = lib.literalExpression '' { "auth_backends.1.authn" = "rabbit_auth_backend_ldap"; "auth_backends.1.authz" = "rabbit_auth_backend_internal"; @@ -112,9 +109,9 @@ in ''; }; - config = mkOption { + config = lib.mkOption { default = ""; - type = types.str; + type = lib.types.str; description = '' Verbatim advanced configuration file contents using the Erlang syntax. This is also known as the `advanced.config` file or the old config format. @@ -130,23 +127,23 @@ in ''; }; - plugins = mkOption { + plugins = lib.mkOption { default = [ ]; - type = types.listOf types.str; + type = lib.types.listOf lib.types.str; description = "The names of plugins to enable"; }; - pluginDirs = mkOption { + pluginDirs = lib.mkOption { default = [ ]; - type = types.listOf types.path; + type = lib.types.listOf lib.types.path; description = "The list of directories containing external plugins"; }; managementPlugin = { - enable = mkEnableOption "the management plugin"; - port = mkOption { + enable = lib.mkEnableOption "the management plugin"; + port = lib.mkOption { default = 15672; - type = types.port; + type = lib.types.port; description = '' On which port to run the management plugin ''; @@ -157,7 +154,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # This is needed so we will have 'rabbitmqctl' in our PATH environment.systemPackages = [ cfg.package ]; @@ -175,13 +172,13 @@ in users.groups.rabbitmq.gid = config.ids.gids.rabbitmq; services.rabbitmq.configItems = { - "listeners.tcp.1" = mkDefault "${cfg.listenAddress}:${toString cfg.port}"; - } // optionalAttrs cfg.managementPlugin.enable { + "listeners.tcp.1" = lib.mkDefault "${cfg.listenAddress}:${toString cfg.port}"; + } // lib.optionalAttrs cfg.managementPlugin.enable { "management.tcp.port" = toString cfg.managementPlugin.port; "management.tcp.ip" = cfg.listenAddress; }; - services.rabbitmq.plugins = optional cfg.managementPlugin.enable "rabbitmq_management"; + services.rabbitmq.plugins = lib.optional cfg.managementPlugin.enable "rabbitmq_management"; systemd.services.rabbitmq = { description = "RabbitMQ Server"; @@ -200,11 +197,11 @@ in RABBITMQ_LOGS = "-"; SYS_PREFIX = ""; RABBITMQ_CONFIG_FILE = config_file; - RABBITMQ_PLUGINS_DIR = concatStringsSep ":" cfg.pluginDirs; + RABBITMQ_PLUGINS_DIR = lib.concatStringsSep ":" cfg.pluginDirs; RABBITMQ_ENABLED_PLUGINS_FILE = pkgs.writeText "enabled_plugins" '' - [ ${concatStringsSep "," cfg.plugins} ]. + [ ${lib.concatStringsSep "," cfg.plugins} ]. ''; - } // optionalAttrs (cfg.config != "") { RABBITMQ_ADVANCED_CONFIG_FILE = advanced_config_file; }; + } // lib.optionalAttrs (cfg.config != "") { RABBITMQ_ADVANCED_CONFIG_FILE = advanced_config_file; }; serviceConfig = { ExecStart = "${cfg.package}/sbin/rabbitmq-server"; @@ -223,7 +220,7 @@ in }; preStart = '' - ${optionalString (cfg.unsafeCookie != "") '' + ${lib.optionalString (cfg.unsafeCookie != "") '' install -m 600 <(echo -n ${cfg.unsafeCookie}) ${cfg.dataDir}/.erlang.cookie ''} ''; From bff67892a738630a3fd6aecb02f66b11fa2927a8 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:53 +0200 Subject: [PATCH 042/139] nixos/services.kubernetes.flannel: remove `with lib;` --- .../services/cluster/kubernetes/flannel.nix | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/cluster/kubernetes/flannel.nix b/nixos/modules/services/cluster/kubernetes/flannel.nix index 93a460971055..f0269cd0bc21 100644 --- a/nixos/modules/services/cluster/kubernetes/flannel.nix +++ b/nixos/modules/services/cluster/kubernetes/flannel.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let top = config.services.kubernetes; cfg = top.flannel; @@ -12,28 +9,28 @@ in { ###### interface options.services.kubernetes.flannel = { - enable = mkEnableOption "flannel networking"; + enable = lib.mkEnableOption "flannel networking"; - openFirewallPorts = mkOption { + openFirewallPorts = lib.mkOption { description = '' Whether to open the Flannel UDP ports in the firewall on all interfaces.''; - type = types.bool; + type = lib.types.bool; default = true; }; }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.flannel = { - enable = mkDefault true; - network = mkDefault top.clusterCidr; + enable = lib.mkDefault true; + network = lib.mkDefault top.clusterCidr; inherit storageBackend; nodeName = config.services.kubernetes.kubelet.hostname; }; services.kubernetes.kubelet = { - cni.config = mkDefault [{ + cni.config = lib.mkDefault [{ name = "mynet"; type = "flannel"; cniVersion = "0.3.1"; @@ -45,7 +42,7 @@ in }; networking = { - firewall.allowedUDPPorts = mkIf cfg.openFirewallPorts [ + firewall.allowedUDPPorts = lib.mkIf cfg.openFirewallPorts [ 8285 # flannel udp 8472 # flannel vxlan ]; @@ -61,7 +58,7 @@ in }; # give flannel some kubernetes rbac permissions if applicable - services.kubernetes.addonManager.bootstrapAddons = mkIf ((storageBackend == "kubernetes") && (elem "RBAC" top.apiserver.authorizationMode)) { + services.kubernetes.addonManager.bootstrapAddons = lib.mkIf ((storageBackend == "kubernetes") && (lib.elem "RBAC" top.apiserver.authorizationMode)) { flannel-cr = { apiVersion = "rbac.authorization.k8s.io/v1"; From 4b3987ab25f5a1ac8fe3e2230e750184e50c2f36 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:54 +0200 Subject: [PATCH 043/139] nixos/services.jenkins: remove `with lib;` --- .../jenkins/default.nix | 85 +++++++++---------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixos/modules/services/continuous-integration/jenkins/default.nix index a23120739b7f..95372ec2bbf8 100644 --- a/nixos/modules/services/continuous-integration/jenkins/default.nix +++ b/nixos/modules/services/continuous-integration/jenkins/default.nix @@ -1,38 +1,37 @@ { config, lib, pkgs, ... }: -with lib; let cfg = config.services.jenkins; jenkinsUrl = "http://${cfg.listenAddress}:${toString cfg.port}${cfg.prefix}"; in { options = { services.jenkins = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable the jenkins continuous integration server. ''; }; - user = mkOption { + user = lib.mkOption { default = "jenkins"; - type = types.str; + type = lib.types.str; description = '' User the jenkins server should execute under. ''; }; - group = mkOption { + group = lib.mkOption { default = "jenkins"; - type = types.str; + type = lib.types.str; description = '' If the default user "jenkins" is configured then this is the primary group of that user. ''; }; - extraGroups = mkOption { - type = types.listOf types.str; + extraGroups = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "wheel" "dialout" ]; description = '' @@ -40,38 +39,38 @@ in { ''; }; - home = mkOption { + home = lib.mkOption { default = "/var/lib/jenkins"; - type = types.path; + type = lib.types.path; description = '' The path to use as JENKINS_HOME. If the default user "jenkins" is configured then this is the home of the "jenkins" user. ''; }; - listenAddress = mkOption { + listenAddress = lib.mkOption { default = "0.0.0.0"; example = "localhost"; - type = types.str; + type = lib.types.str; description = '' Specifies the bind address on which the jenkins HTTP interface listens. The default is the wildcard address. ''; }; - port = mkOption { + port = lib.mkOption { default = 8080; - type = types.port; + type = lib.types.port; description = '' Specifies port number on which the jenkins HTTP interface listens. The default is 8080. ''; }; - prefix = mkOption { + prefix = lib.mkOption { default = ""; example = "/jenkins"; - type = types.str; + type = lib.types.str; description = '' Specifies a urlPrefix to use with jenkins. If the example /jenkins is given, the jenkins server will be @@ -79,20 +78,20 @@ in { ''; }; - package = mkPackageOption pkgs "jenkins" { }; + package = lib.mkPackageOption pkgs "jenkins" { }; - packages = mkOption { + packages = lib.mkOption { default = [ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ]; - defaultText = literalExpression "[ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ]"; - type = types.listOf types.package; + defaultText = lib.literalExpression "[ pkgs.stdenv pkgs.git pkgs.jdk17 config.programs.ssh.package pkgs.nix ]"; + type = lib.types.listOf lib.types.package; description = '' Packages to add to PATH for the jenkins process. ''; }; - environment = mkOption { + environment = lib.mkOption { default = { }; - type = with types; attrsOf str; + type = with lib.types; attrsOf str; description = '' Additional environment variables to be passed to the jenkins process. As a base environment, jenkins receives NIX_PATH from @@ -104,9 +103,9 @@ in { ''; }; - plugins = mkOption { + plugins = lib.mkOption { default = null; - type = types.nullOr (types.attrsOf types.package); + type = lib.types.nullOr (lib.types.attrsOf lib.types.package); description = '' A set of plugins to activate. Note that this will completely remove and replace any previously installed plugins. If you @@ -115,13 +114,13 @@ in { `null`. You can generate this set with a tool such as `jenkinsPlugins2nix`. ''; - example = literalExpression '' + example = lib.literalExpression '' import path/to/jenkinsPlugins2nix-generated-plugins.nix { inherit (pkgs) fetchurl stdenv; } ''; }; - extraOptions = mkOption { - type = types.listOf types.str; + extraOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "--debug=9" ]; description = '' @@ -129,8 +128,8 @@ in { ''; }; - extraJavaOptions = mkOption { - type = types.listOf types.str; + extraJavaOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "-Xmx80m" ]; description = '' @@ -138,8 +137,8 @@ in { ''; }; - withCLI = mkOption { - type = types.bool; + withCLI = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to make the CLI available. @@ -152,25 +151,25 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment = { # server references the dejavu fonts systemPackages = [ pkgs.dejavu_fonts - ] ++ optional cfg.withCLI cfg.package; + ] ++ lib.optional cfg.withCLI cfg.package; variables = {} - // optionalAttrs cfg.withCLI { + // lib.optionalAttrs cfg.withCLI { # Make it more convenient to use the `jenkins-cli`. JENKINS_URL = jenkinsUrl; }; }; - users.groups = optionalAttrs (cfg.group == "jenkins") { + users.groups = lib.optionalAttrs (cfg.group == "jenkins") { jenkins.gid = config.ids.gids.jenkins; }; - users.users = optionalAttrs (cfg.user == "jenkins") { + users.users = lib.optionalAttrs (cfg.user == "jenkins") { jenkins = { description = "jenkins user"; createHome = true; @@ -205,14 +204,14 @@ in { preStart = let replacePlugins = - optionalString (cfg.plugins != null) ( - let pluginCmds = lib.attrsets.mapAttrsToList + lib.optionalString (cfg.plugins != null) ( + let pluginCmds = lib.attrsets.lib.mapAttrsToList (n: v: "cp ${v} ${cfg.home}/plugins/${n}.jpi") cfg.plugins; in '' rm -r ${cfg.home}/plugins || true mkdir -p ${cfg.home}/plugins - ${lib.strings.concatStringsSep "\n" pluginCmds} + ${lib.strings.lib.concatStringsSep "\n" pluginCmds} ''); in '' rm -rf ${cfg.home}/war @@ -221,11 +220,11 @@ in { # For reference: https://wiki.jenkins.io/display/JENKINS/JenkinsLinuxStartupScript script = '' - ${pkgs.jdk17}/bin/java ${concatStringsSep " " cfg.extraJavaOptions} -jar ${cfg.package}/webapps/jenkins.war --httpListenAddress=${cfg.listenAddress} \ + ${pkgs.jdk17}/bin/java ${lib.concatStringsSep " " cfg.extraJavaOptions} -jar ${cfg.package}/webapps/jenkins.war --httpListenAddress=${cfg.listenAddress} \ --httpPort=${toString cfg.port} \ --prefix=${cfg.prefix} \ -Djava.awt.headless=true \ - ${concatStringsSep " " cfg.extraOptions} + ${lib.concatStringsSep " " cfg.extraOptions} ''; postStart = '' @@ -236,7 +235,7 @@ in { serviceConfig = { User = cfg.user; - StateDirectory = mkIf (hasPrefix "/var/lib/jenkins" cfg.home) "jenkins"; + StateDirectory = lib.mkIf (lib.hasPrefix "/var/lib/jenkins" cfg.home) "jenkins"; # For (possible) socket use RuntimeDirectory = "jenkins"; }; From 5fb90466e8785cbaa006e309a472092eb11c71b1 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:55 +0200 Subject: [PATCH 044/139] nixos/services.jenkins.jobBuilder: remove `with lib;` --- .../jenkins/job-builder.nix | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/continuous-integration/jenkins/job-builder.nix b/nixos/modules/services/continuous-integration/jenkins/job-builder.nix index 6400da13d3a8..ccad25cb92a7 100644 --- a/nixos/modules/services/continuous-integration/jenkins/job-builder.nix +++ b/nixos/modules/services/continuous-integration/jenkins/job-builder.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let jenkinsCfg = config.services.jenkins; cfg = config.services.jenkins.jobBuilder; @@ -9,7 +6,7 @@ let in { options = { services.jenkins.jobBuilder = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' the Jenkins Job Builder (JJB) service. It allows defining jobs for Jenkins in a declarative manner. @@ -24,17 +21,17 @@ in { ''; - accessUser = mkOption { + accessUser = lib.mkOption { default = "admin"; - type = types.str; + type = lib.types.str; description = '' User id in Jenkins used to reload config. ''; }; - accessToken = mkOption { + accessToken = lib.mkOption { default = ""; - type = types.str; + type = lib.types.str; description = '' User token in Jenkins used to reload config. WARNING: This token will be world readable in the Nix store. To keep @@ -42,10 +39,10 @@ in { ''; }; - accessTokenFile = mkOption { + accessTokenFile = lib.mkOption { default = "${config.services.jenkins.home}/secrets/initialAdminPassword"; - defaultText = literalExpression ''"''${config.services.jenkins.home}/secrets/initialAdminPassword"''; - type = types.str; + defaultText = lib.literalExpression ''"''${config.services.jenkins.home}/secrets/initialAdminPassword"''; + type = lib.types.str; example = "/run/keys/jenkins-job-builder-access-token"; description = '' File containing the API token for the {option}`accessUser` @@ -53,9 +50,9 @@ in { ''; }; - yamlJobs = mkOption { + yamlJobs = lib.mkOption { default = ""; - type = types.lines; + type = lib.types.lines; example = '' - job: name: jenkins-job-test-1 @@ -67,10 +64,10 @@ in { ''; }; - jsonJobs = mkOption { + jsonJobs = lib.mkOption { default = [ ]; - type = types.listOf types.str; - example = literalExpression '' + type = lib.types.listOf lib.types.str; + example = lib.literalExpression '' [ ''' [ { "job": @@ -87,10 +84,10 @@ in { ''; }; - nixJobs = mkOption { + nixJobs = lib.mkOption { default = [ ]; - type = types.listOf types.attrs; - example = literalExpression '' + type = lib.types.listOf lib.types.attrs; + example = lib.literalExpression '' [ { job = { name = "jenkins-job-test-3"; builders = [ @@ -110,7 +107,7 @@ in { }; }; - config = mkIf (jenkinsCfg.enable && cfg.enable) { + config = lib.mkIf (jenkinsCfg.enable && cfg.enable) { assertions = [ { assertion = if cfg.accessUser != "" @@ -213,7 +210,7 @@ in { # Create / update jobs mkdir -p ${jobBuilderOutputDir} - for inputFile in ${yamlJobsFile} ${concatStringsSep " " jsonJobsFiles}; do + for inputFile in ${yamlJobsFile} ${lib.concatStringsSep " " jsonJobsFiles}; do HOME="${jenkinsCfg.home}" "${pkgs.jenkins-job-builder}/bin/jenkins-jobs" --ignore-cache test --config-xml -o "${jobBuilderOutputDir}" "$inputFile" done @@ -237,7 +234,7 @@ in { jobdir="${jenkinsCfg.home}/$jenkinsjobname" rm -rf "$jobdir" done - '' + (optionalString (cfg.accessUser != "") reloadScript); + '' + (lib.optionalString (cfg.accessUser != "") reloadScript); serviceConfig = { Type = "oneshot"; User = jenkinsCfg.user; From 75d565a3b05711f9c0609106b612fc47346925b9 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:55 +0200 Subject: [PATCH 045/139] nixos/services.couchdb: remove `with lib;` --- nixos/modules/services/databases/couchdb.nix | 67 ++++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/databases/couchdb.nix b/nixos/modules/services/databases/couchdb.nix index e007bfce77ab..22c9cfd91823 100644 --- a/nixos/modules/services/databases/couchdb.nix +++ b/nixos/modules/services/databases/couchdb.nix @@ -1,7 +1,4 @@ { config, options, lib, pkgs, ... }: - -with lib; - let cfg = config.services.couchdb; opt = options.services.couchdb; @@ -11,7 +8,7 @@ let database_dir = ${cfg.databaseDir} uri_file = ${cfg.uriFile} view_index_dir = ${cfg.viewIndexDir} - '' + (optionalString (cfg.adminPass != null) '' + '' + (lib.optionalString (cfg.adminPass != null) '' [admins] ${cfg.adminUser} = ${cfg.adminPass} '' + '' @@ -34,12 +31,12 @@ in { services.couchdb = { - enable = mkEnableOption "CouchDB Server"; + enable = lib.mkEnableOption "CouchDB Server"; - package = mkPackageOption pkgs "couchdb3" { }; + package = lib.mkPackageOption pkgs "couchdb3" { }; - adminUser = mkOption { - type = types.str; + adminUser = lib.mkOption { + type = lib.types.str; default = "admin"; description = '' Couchdb (i.e. fauxton) account with permission for all dbs and @@ -47,8 +44,8 @@ in { ''; }; - adminPass = mkOption { - type = types.nullOr types.str; + adminPass = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Couchdb (i.e. fauxton) account with permission for all dbs and @@ -56,16 +53,16 @@ in { ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "couchdb"; description = '' User account under which couchdb runs. ''; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "couchdb"; description = '' Group account under which couchdb runs. @@ -74,8 +71,8 @@ in { # couchdb options: https://docs.couchdb.org/en/latest/config/index.html - databaseDir = mkOption { - type = types.path; + databaseDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/couchdb"; description = '' Specifies location of CouchDB database files (*.couch named). This @@ -84,8 +81,8 @@ in { ''; }; - uriFile = mkOption { - type = types.path; + uriFile = lib.mkOption { + type = lib.types.path; default = "/run/couchdb/couchdb.uri"; description = '' This file contains the full URI that can be used to access this @@ -96,8 +93,8 @@ in { ''; }; - viewIndexDir = mkOption { - type = types.path; + viewIndexDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/couchdb"; description = '' Specifies location of CouchDB view index files. This location should @@ -106,49 +103,49 @@ in { ''; }; - bindAddress = mkOption { - type = types.str; + bindAddress = lib.mkOption { + type = lib.types.str; default = "127.0.0.1"; description = '' Defines the IP address by which CouchDB will be accessible. ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 5984; description = '' Defined the port number to listen. ''; }; - logFile = mkOption { - type = types.path; + logFile = lib.mkOption { + type = lib.types.path; default = "/var/log/couchdb.log"; description = '' Specifies the location of file for logging output. ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Extra configuration. Overrides any other configuration. ''; }; - argsFile = mkOption { - type = types.path; + argsFile = lib.mkOption { + type = lib.types.path; default = "${cfg.package}/etc/vm.args"; - defaultText = literalExpression ''"config.${opt.package}/etc/vm.args"''; + defaultText = lib.literalExpression ''"config.${opt.package}/etc/vm.args"''; description = '' vm.args configuration. Overrides Couchdb's Erlang VM parameters file. ''; }; - configFile = mkOption { - type = types.path; + configFile = lib.mkOption { + type = lib.types.path; description = '' Configuration file for persisting runtime changes. File needs to be readable and writable from couchdb user/group. @@ -161,11 +158,11 @@ in { ###### implementation - config = mkIf config.services.couchdb.enable { + config = lib.mkIf config.services.couchdb.enable { environment.systemPackages = [ cfg.package ]; - services.couchdb.configFile = mkDefault "/var/lib/couchdb/local.ini"; + services.couchdb.configFile = lib.mkDefault "/var/lib/couchdb/local.ini"; systemd.tmpfiles.rules = [ "d '${dirOf cfg.uriFile}' - ${cfg.user} ${cfg.group} - -" From 626c4c1a219297f974b81b890dfc62b36815473e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:56 +0200 Subject: [PATCH 046/139] nixos/services.dgraph: remove `with lib;` --- nixos/modules/services/databases/dgraph.nix | 27 +++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/databases/dgraph.nix b/nixos/modules/services/databases/dgraph.nix index 00a11d6b686e..20bc56df85a4 100644 --- a/nixos/modules/services/databases/dgraph.nix +++ b/nixos/modules/services/databases/dgraph.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.dgraph; settingsFormat = pkgs.formats.json {}; @@ -53,11 +50,11 @@ in { options = { services.dgraph = { - enable = mkEnableOption "Dgraph native GraphQL database with a graph backend"; + enable = lib.mkEnableOption "Dgraph native GraphQL database with a graph backend"; package = lib.mkPackageOption pkgs "dgraph" { }; - settings = mkOption { + settings = lib.mkOption { type = settingsFormat.type; default = {}; description = '' @@ -66,15 +63,15 @@ in }; alpha = { - host = mkOption { - type = types.str; + host = lib.mkOption { + type = lib.types.str; default = "localhost"; description = '' The host which dgraph alpha will be run on. ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 7080; description = '' The port which to run dgraph alpha on. @@ -84,15 +81,15 @@ in }; zero = { - host = mkOption { - type = types.str; + host = lib.mkOption { + type = lib.types.str; default = "localhost"; description = '' The host which dgraph zero will be run on. ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 5080; description = '' The port which to run dgraph zero on. @@ -103,9 +100,9 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.dgraph.settings = { - badger.compression = mkDefault "zstd:3"; + badger.compression = lib.mkDefault "zstd:3"; }; systemd.services.dgraph-zero = { From f06f3a7973bd9196e4296afd08c19a99e23c9a76 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:56 +0200 Subject: [PATCH 047/139] nixos/services.dragonflydb: remove `with lib;` --- .../services/databases/dragonflydb.nix | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/nixos/modules/services/databases/dragonflydb.nix b/nixos/modules/services/databases/dragonflydb.nix index 220605c8b475..9024b584abc3 100644 --- a/nixos/modules/services/databases/dragonflydb.nix +++ b/nixos/modules/services/databases/dragonflydb.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.dragonflydb; dragonflydb = pkgs.dragonflydb; @@ -25,22 +22,22 @@ in options = { services.dragonflydb = { - enable = mkEnableOption "DragonflyDB"; + enable = lib.mkEnableOption "DragonflyDB"; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "dragonfly"; description = "The user to run DragonflyDB as"; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 6379; description = "The TCP port to accept connections."; }; - bind = mkOption { - type = with types; nullOr str; + bind = lib.mkOption { + type = with lib.types; nullOr str; default = "127.0.0.1"; description = '' The IP interface to bind to. @@ -48,15 +45,15 @@ in ''; }; - requirePass = mkOption { - type = with types; nullOr str; + requirePass = lib.mkOption { + type = with lib.types; nullOr str; default = null; description = "Password for database"; example = "letmein!"; }; - maxMemory = mkOption { - type = with types; nullOr ints.unsigned; + maxMemory = lib.mkOption { + type = with lib.types; nullOr ints.unsigned; default = null; description = '' The maximum amount of memory to use for storage (in bytes). @@ -64,8 +61,8 @@ in ''; }; - memcachePort = mkOption { - type = with types; nullOr port; + memcachePort = lib.mkOption { + type = with lib.types; nullOr port; default = null; description = '' To enable memcached compatible API on this port. @@ -73,8 +70,8 @@ in ''; }; - keysOutputLimit = mkOption { - type = types.ints.unsigned; + keysOutputLimit = lib.mkOption { + type = lib.types.ints.unsigned; default = 8192; description = '' Maximum number of returned keys in keys command. @@ -83,14 +80,14 @@ in ''; }; - dbNum = mkOption { - type = with types; nullOr ints.unsigned; + dbNum = lib.mkOption { + type = with lib.types; nullOr ints.unsigned; default = null; description = "Maximum number of supported databases for `select`"; }; - cacheMode = mkOption { - type = with types; nullOr bool; + cacheMode = lib.mkOption { + type = with lib.types; nullOr bool; default = null; description = '' Once this mode is on, Dragonfly will evict items least likely to be stumbled @@ -102,14 +99,14 @@ in ###### implementation - config = mkIf config.services.dragonflydb.enable { + config = lib.mkIf config.services.dragonflydb.enable { - users.users = optionalAttrs (cfg.user == "dragonfly") { + users.users = lib.optionalAttrs (cfg.user == "dragonfly") { dragonfly.description = "DragonflyDB server user"; dragonfly.isSystemUser = true; dragonfly.group = "dragonfly"; }; - users.groups = optionalAttrs (cfg.user == "dragonfly") { dragonfly = { }; }; + users.groups = lib.optionalAttrs (cfg.user == "dragonfly") { dragonfly = { }; }; environment.systemPackages = [ dragonflydb ]; @@ -120,7 +117,7 @@ in after = [ "network.target" ]; serviceConfig = { - ExecStart = "${dragonflydb}/bin/dragonfly --alsologtostderr ${builtins.concatStringsSep " " (attrsets.mapAttrsToList (n: v: "--${n} ${strings.escapeShellArg v}") settings)}"; + ExecStart = "${dragonflydb}/bin/dragonfly --alsologtostderr ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "--${n} ${lib.escapeShellArg v}") settings)}"; User = cfg.user; From 17003eacc98b10cca0c3a01346c987b1d6d1da7d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:57 +0200 Subject: [PATCH 048/139] nixos/services.ferretdb: remove `with lib;` --- nixos/modules/services/databases/ferretdb.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/databases/ferretdb.nix b/nixos/modules/services/databases/ferretdb.nix index ab55e22bf214..a7e3fa81c48f 100644 --- a/nixos/modules/services/databases/ferretdb.nix +++ b/nixos/modules/services/databases/ferretdb.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.ferretdb; in @@ -11,11 +8,11 @@ in options = { services.ferretdb = { - enable = mkEnableOption "FerretDB, an Open Source MongoDB alternative"; + enable = lib.mkEnableOption "FerretDB, an Open Source MongoDB alternative"; - package = mkOption { - type = types.package; - example = literalExpression "pkgs.ferretdb"; + package = lib.mkOption { + type = lib.types.package; + example = lib.literalExpression "pkgs.ferretdb"; default = pkgs.ferretdb; defaultText = "pkgs.ferretdb"; description = "FerretDB package to use."; @@ -37,7 +34,7 @@ in }; }; - config = mkIf cfg.enable + config = lib.mkIf cfg.enable { services.ferretdb.settings = { @@ -76,4 +73,3 @@ in }; }; } - From 567aa06ba26a6127bf41f846b847d02cfa527e4f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:57 +0200 Subject: [PATCH 049/139] nixos/services.firebird: remove `with lib;` --- nixos/modules/services/databases/firebird.nix | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/databases/firebird.nix b/nixos/modules/services/databases/firebird.nix index 17606218b633..4b2b34ae7b1d 100644 --- a/nixos/modules/services/databases/firebird.nix +++ b/nixos/modules/services/databases/firebird.nix @@ -18,9 +18,6 @@ # however there are no strong reasons to prefer this or the other one AFAIK # Eg superserver is said to be most efficiently using resources according to # https://www.firebirdsql.org/manual/qsg25-classic-or-super.html - -with lib; - let cfg = config.services.firebird; @@ -40,34 +37,34 @@ in services.firebird = { - enable = mkEnableOption "the Firebird super server"; + enable = lib.mkEnableOption "the Firebird super server"; - package = mkPackageOption pkgs "firebird" { + package = lib.mkPackageOption pkgs "firebird" { example = "firebird_3"; extraDescription = '' For SuperServer use override: `pkgs.firebird_3.override { superServer = true; };` ''; }; - port = mkOption { + port = lib.mkOption { default = 3050; - type = types.port; + type = lib.types.port; description = '' Port Firebird uses. ''; }; - user = mkOption { + user = lib.mkOption { default = "firebird"; - type = types.str; + type = lib.types.str; description = '' User account under which firebird runs. ''; }; - baseDir = mkOption { + baseDir = lib.mkOption { default = "/var/lib/firebird"; - type = types.str; + type = lib.types.str; description = '' Location containing data/ and system/ directories. data/ stores the databases, system/ stores the password database security2.fdb. @@ -81,7 +78,7 @@ in ###### implementation - config = mkIf config.services.firebird.enable { + config = lib.mkIf config.services.firebird.enable { environment.systemPackages = [cfg.package]; From 3db1445493cb3a3f31b0af3ca5b1e103d46fd442 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:58 +0200 Subject: [PATCH 050/139] nixos/services.hbase-standalone: remove `with lib;` --- .../services/databases/hbase-standalone.nix | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/nixos/modules/services/databases/hbase-standalone.nix b/nixos/modules/services/databases/hbase-standalone.nix index ac37e3932932..d3d2999eaeed 100644 --- a/nixos/modules/services/databases/hbase-standalone.nix +++ b/nixos/modules/services/databases/hbase-standalone.nix @@ -1,7 +1,4 @@ { config, options, lib, pkgs, ... }: - -with lib; - let cfg = config.services.hbase-standalone; opt = options.services.hbase-standalone; @@ -33,7 +30,7 @@ let in { imports = [ - (mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ]) + (lib.mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ]) ]; ###### interface @@ -41,31 +38,31 @@ in { options = { services.hbase-standalone = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' HBase master in standalone mode with embedded regionserver and zookeper. Do not use this configuration for production nor for evaluating HBase performance ''; - package = mkPackageOption pkgs "hbase" { }; + package = lib.mkPackageOption pkgs "hbase" { }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "hbase"; description = '' User account under which HBase runs. ''; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "hbase"; description = '' Group account under which HBase runs. ''; }; - dataDir = mkOption { - type = types.path; + dataDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/hbase"; description = '' Specifies location of HBase database files. This location should be @@ -74,21 +71,21 @@ in { ''; }; - logDir = mkOption { - type = types.path; + logDir = lib.mkOption { + type = lib.types.path; default = "/var/log/hbase"; description = '' Specifies the location of HBase log files. ''; }; - settings = mkOption { + settings = lib.mkOption { type = with lib.types; attrsOf (oneOf [ str int bool ]); default = { "hbase.rootdir" = "file://${cfg.dataDir}/hbase"; "hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper"; }; - defaultText = literalExpression '' + defaultText = lib.literalExpression '' { "hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase"; "hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper"; @@ -104,7 +101,7 @@ in { ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.tmpfiles.rules = [ "d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -" From 0dbb2e5fa1b309148d46edb83d84f3708b3b4642 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:58 +0200 Subject: [PATCH 051/139] nixos/services.influxdb: remove `with lib;` --- nixos/modules/services/databases/influxdb.nix | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/databases/influxdb.nix b/nixos/modules/services/databases/influxdb.nix index 6dd4ca3b71cd..9bc0b935d08f 100644 --- a/nixos/modules/services/databases/influxdb.nix +++ b/nixos/modules/services/databases/influxdb.nix @@ -1,11 +1,8 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.influxdb; - configOptions = recursiveUpdate { + configOptions = lib.recursiveUpdate { meta = { bind-address = ":8088"; commit-timeout = "50ms"; @@ -110,36 +107,36 @@ in services.influxdb = { - enable = mkOption { + enable = lib.mkOption { default = false; description = "Whether to enable the influxdb server"; - type = types.bool; + type = lib.types.bool; }; - package = mkPackageOption pkgs "influxdb" { }; + package = lib.mkPackageOption pkgs "influxdb" { }; - user = mkOption { + user = lib.mkOption { default = "influxdb"; description = "User account under which influxdb runs"; - type = types.str; + type = lib.types.str; }; - group = mkOption { + group = lib.mkOption { default = "influxdb"; description = "Group under which influxdb runs"; - type = types.str; + type = lib.types.str; }; - dataDir = mkOption { + dataDir = lib.mkOption { default = "/var/db/influxdb"; description = "Data directory for influxd data files."; - type = types.path; + type = lib.types.path; }; - extraConfig = mkOption { + extraConfig = lib.mkOption { default = {}; description = "Extra configuration options for influxdb"; - type = types.attrs; + type = lib.types.attrs; }; }; }; @@ -147,7 +144,7 @@ in ###### implementation - config = mkIf config.services.influxdb.enable { + config = lib.mkIf config.services.influxdb.enable { systemd.tmpfiles.rules = [ "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group} - -" @@ -166,16 +163,16 @@ in postStart = let scheme = if configOptions.http.https-enabled then "-k https" else "http"; - bindAddr = (ba: if hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address); + bindAddr = (ba: if lib.hasPrefix ":" ba then "127.0.0.1${ba}" else "${ba}")(toString configOptions.http.bind-address); in - mkBefore '' + lib.mkBefore '' until ${pkgs.curl.bin}/bin/curl -s -o /dev/null ${scheme}://${bindAddr}/ping; do sleep 1; done ''; }; - users.users = optionalAttrs (cfg.user == "influxdb") { + users.users = lib.optionalAttrs (cfg.user == "influxdb") { influxdb = { uid = config.ids.uids.influxdb; group = "influxdb"; @@ -183,7 +180,7 @@ in }; }; - users.groups = optionalAttrs (cfg.group == "influxdb") { + users.groups = lib.optionalAttrs (cfg.group == "influxdb") { influxdb.gid = config.ids.gids.influxdb; }; }; From 93fb328e44dc4a168e4551ea4bfe6f355d17f3de Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:42:59 +0200 Subject: [PATCH 052/139] nixos/services.openldap: remove `with lib;` --- nixos/modules/services/databases/openldap.nix | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/nixos/modules/services/databases/openldap.nix b/nixos/modules/services/databases/openldap.nix index feb974cdf6d3..20b1f03021f0 100644 --- a/nixos/modules/services/databases/openldap.nix +++ b/nixos/modules/services/databases/openldap.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.openldap; openldap = cfg.package; @@ -23,22 +21,22 @@ let merge = lib.mergeEqualOption; }; # We don't coerce to lists of single values, as some values must be unique - in types.either singleLdapValueType (types.listOf singleLdapValueType); + in lib.types.either singleLdapValueType (lib.types.listOf singleLdapValueType); ldapAttrsType = let options = { - attrs = mkOption { - type = types.attrsOf ldapValueType; + attrs = lib.mkOption { + type = lib.types.attrsOf ldapValueType; default = {}; description = "Attributes of the parent entry."; }; - children = mkOption { + children = lib.mkOption { # Hide the child attributes, to avoid infinite recursion in e.g. documentation # Actual Nix evaluation is lazy, so this is not an issue there type = let hiddenOptions = lib.mapAttrs (name: attr: attr // { visible = false; }) options; - in types.attrsOf (types.submodule { options = hiddenOptions; }); + in lib.types.attrsOf (lib.types.submodule { options = hiddenOptions; }); default = {}; description = "Child entries of the current entry, with recursively the same structure."; example = lib.literalExpression '' @@ -56,15 +54,15 @@ let } ''; }; - includes = mkOption { - type = types.listOf types.path; + includes = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' LDIF files to include after the parent's attributes but before its children. ''; }; }; - in types.submodule { inherit options; }; + in lib.types.submodule { inherit options; }; valueToLdif = attr: values: let listValues = if lib.isList values then values else lib.singleton values; @@ -85,13 +83,13 @@ let in { options = { services.openldap = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to enable the ldap server."; }; - package = mkPackageOption pkgs "openldap" { + package = lib.mkPackageOption pkgs "openldap" { extraDescription = '' This can be used to, for example, set an OpenLDAP package with custom overrides to enable modules or other @@ -99,26 +97,26 @@ in { ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "openldap"; description = "User account under which slapd runs."; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "openldap"; description = "Group account under which slapd runs."; }; - urlList = mkOption { - type = types.listOf types.str; + urlList = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "ldap:///" ]; description = "URL list slapd should listen on."; example = [ "ldaps:///" ]; }; - settings = mkOption { + settings = lib.mkOption { type = ldapAttrsType; description = "Configuration for OpenLDAP, in OLC format"; example = lib.literalExpression '' @@ -165,8 +163,8 @@ in { }; # This option overrides settings - configDir = mkOption { - type = types.nullOr types.path; + configDir = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Use this config directory instead of generating one from the @@ -175,8 +173,8 @@ in { example = "/var/lib/openldap/slapd.d"; }; - mutableConfig = mkOption { - type = types.bool; + mutableConfig = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to allow writable on-line configuration. If @@ -186,8 +184,8 @@ in { ''; }; - declarativeContents = mkOption { - type = with types; attrsOf lines; + declarativeContents = lib.mkOption { + type = with lib.types; attrsOf lines; default = {}; description = '' Declarative contents for the LDAP database, in LDIF format by suffix. @@ -225,8 +223,8 @@ in { meta.maintainers = with lib.maintainers; [ kwohlfahrt ]; config = let - dbSettings = mapAttrs' (name: { attrs, ... }: nameValuePair attrs.olcSuffix attrs) - (filterAttrs (name: { attrs, ... }: (hasPrefix "olcDatabase=" name) && attrs ? olcSuffix) cfg.settings.children); + dbSettings = lib.mapAttrs' (name: { attrs, ... }: lib.nameValuePair attrs.olcSuffix attrs) + (lib.filterAttrs (name: { attrs, ... }: (lib.hasPrefix "olcDatabase=" name) && attrs ? olcSuffix) cfg.settings.children); settingsFile = pkgs.writeText "config.ldif" (lib.concatStringsSep "\n" (attrsToLdif "cn=config" cfg.settings)); writeConfig = pkgs.writeShellScript "openldap-config" '' set -euo pipefail @@ -241,32 +239,32 @@ in { chmod -R ${if cfg.mutableConfig then "u+rw" else "u+r-w"} ${configDir} ''; - contentsFiles = mapAttrs (dn: ldif: pkgs.writeText "${dn}.ldif" ldif) cfg.declarativeContents; + contentsFiles = lib.mapAttrs (dn: ldif: pkgs.writeText "${dn}.ldif" ldif) cfg.declarativeContents; writeContents = pkgs.writeShellScript "openldap-load" '' set -euo pipefail rm -rf $2/* ${openldap}/bin/slapadd -F ${configDir} -b $1 -l $3 ''; - in mkIf cfg.enable { + in lib.mkIf cfg.enable { assertions = [{ assertion = (cfg.declarativeContents != {}) -> cfg.configDir == null; message = '' - Declarative DB contents (${attrNames cfg.declarativeContents}) are not + Declarative DB contents (${lib.attrNames cfg.declarativeContents}) are not supported with user-managed configuration. ''; }] ++ (map (dn: { - assertion = (getAttr dn dbSettings) ? "olcDbDirectory"; + assertion = (lib.getAttr dn dbSettings) ? "olcDbDirectory"; # olcDbDirectory is necessary to prepopulate database using `slapadd`. message = '' Declarative DB ${dn} does not exist in `services.openldap.settings`, or does not have `olcDbDirectory` configured. ''; - }) (attrNames cfg.declarativeContents)) ++ (mapAttrsToList (dn: { olcDbDirectory ? null, ... }: { + }) (lib.attrNames cfg.declarativeContents)) ++ (lib.mapAttrsToList (dn: { olcDbDirectory ? null, ... }: { # For forward compatibility with `DynamicUser`, and to avoid accidentally clobbering # directories with `declarativeContents`. assertion = (olcDbDirectory != null) -> - ((hasPrefix "/var/lib/openldap/" olcDbDirectory) && (olcDbDirectory != "/var/lib/openldap/")); + ((lib.hasPrefix "/var/lib/openldap/" olcDbDirectory) && (olcDbDirectory != "/var/lib/openldap/")); message = '' Database ${dn} has `olcDbDirectory` (${olcDbDirectory}) that is not a subdirectory of `/var/lib/openldap/`. @@ -303,8 +301,8 @@ in { "!${pkgs.coreutils}/bin/mkdir -p ${configDir}" "+${pkgs.coreutils}/bin/chown $USER ${configDir}" ] ++ (lib.optional (cfg.configDir == null) writeConfig) - ++ (mapAttrsToList (dn: content: lib.escapeShellArgs [ - writeContents dn (getAttr dn dbSettings).olcDbDirectory content + ++ (lib.mapAttrsToList (dn: content: lib.escapeShellArgs [ + writeContents dn (lib.getAttr dn dbSettings).olcDbDirectory content ]) contentsFiles) ++ [ "${openldap}/bin/slaptest -u -F ${configDir}" ]; ExecStart = lib.escapeShellArgs ([ @@ -317,7 +315,7 @@ in { NotifyAccess = "all"; RuntimeDirectory = "openldap"; StateDirectory = ["openldap"] - ++ (map ({olcDbDirectory, ... }: removePrefix "/var/lib/" olcDbDirectory) (attrValues dbSettings)); + ++ (map ({olcDbDirectory, ... }: lib.removePrefix "/var/lib/" olcDbDirectory) (lib.attrValues dbSettings)); StateDirectoryMode = "700"; AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ]; CapabilityBoundingSet = [ "CAP_NET_BIND_SERVICE" ]; From 6bbc3df0dd093f170f0491c821dd3da22db47e12 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:00 +0200 Subject: [PATCH 053/139] nixos/services.opentsdb: remove `with lib;` --- nixos/modules/services/databases/opentsdb.nix | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/databases/opentsdb.nix b/nixos/modules/services/databases/opentsdb.nix index e104c42f8b24..90268daec1d7 100644 --- a/nixos/modules/services/databases/opentsdb.nix +++ b/nixos/modules/services/databases/opentsdb.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.opentsdb; @@ -15,36 +12,36 @@ in { services.opentsdb = { - enable = mkEnableOption "OpenTSDB"; + enable = lib.mkEnableOption "OpenTSDB"; - package = mkPackageOption pkgs "opentsdb" { }; + package = lib.mkPackageOption pkgs "opentsdb" { }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "opentsdb"; description = '' User account under which OpenTSDB runs. ''; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "opentsdb"; description = '' Group account under which OpenTSDB runs. ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 4242; description = '' Which port OpenTSDB listens on. ''; }; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; default = '' tsd.core.auto_create_metrics = true tsd.http.request.enable_chunked = true @@ -60,7 +57,7 @@ in { ###### implementation - config = mkIf config.services.opentsdb.enable { + config = lib.mkIf config.services.opentsdb.enable { systemd.services.opentsdb = { description = "OpenTSDB Server"; From 18c0ca571450f006fdf3a8d20b485872705a27b4 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:01 +0200 Subject: [PATCH 054/139] nixos/services.pgmanage: remove `with lib;` --- nixos/modules/services/databases/pgmanage.nix | 67 +++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/databases/pgmanage.nix b/nixos/modules/services/databases/pgmanage.nix index c405162ed87e..fe3d1b5bfb9d 100644 --- a/nixos/modules/services/databases/pgmanage.nix +++ b/nixos/modules/services/databases/pgmanage.nix @@ -1,7 +1,4 @@ { lib, pkgs, config, ... } : - -with lib; - let cfg = config.services.pgmanage; @@ -16,7 +13,7 @@ let super_only = ${builtins.toJSON cfg.superOnly} - ${optionalString (cfg.loginGroup != null) "login_group = ${cfg.loginGroup}"} + ${lib.optionalString (cfg.loginGroup != null) "login_group = ${cfg.loginGroup}"} login_timeout = ${toString cfg.loginTimeout} @@ -24,7 +21,7 @@ let sql_root = ${cfg.sqlRoot} - ${optionalString (cfg.tls != null) '' + ${lib.optionalString (cfg.tls != null) '' tls_cert = ${cfg.tls.cert} tls_key = ${cfg.tls.key} ''} @@ -35,8 +32,8 @@ let pgmanageConnectionsFile = pkgs.writeTextFile { name = "pgmanage-connections.conf"; - text = concatStringsSep "\n" - (mapAttrsToList (name : conn : "${name}: ${conn}") cfg.connections); + text = lib.concatStringsSep "\n" + (lib.mapAttrsToList (name : conn : "${name}: ${conn}") cfg.connections); }; pgmanage = "pgmanage"; @@ -44,12 +41,12 @@ let in { options.services.pgmanage = { - enable = mkEnableOption "PostgreSQL Administration for the web"; + enable = lib.mkEnableOption "PostgreSQL Administration for the web"; - package = mkPackageOption pkgs "pgmanage" { }; + package = lib.mkPackageOption pkgs "pgmanage" { }; - connections = mkOption { - type = types.attrsOf types.str; + connections = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = {}; example = { nuc-server = "hostaddr=192.168.0.100 port=5432 dbname=postgres"; @@ -68,8 +65,8 @@ in { ''; }; - allowCustomConnections = mkOption { - type = types.bool; + allowCustomConnections = lib.mkOption { + type = lib.types.bool; default = false; description = '' This tells pgmanage whether or not to allow anyone to use a custom @@ -77,16 +74,16 @@ in { ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8080; description = '' This tells pgmanage what port to listen on for browser requests. ''; }; - localOnly = mkOption { - type = types.bool; + localOnly = lib.mkOption { + type = lib.types.bool; default = true; description = '' This tells pgmanage whether or not to set the listening socket to local @@ -94,8 +91,8 @@ in { ''; }; - superOnly = mkOption { - type = types.bool; + superOnly = lib.mkOption { + type = lib.types.bool; default = true; description = '' This tells pgmanage whether or not to only allow super users to @@ -106,8 +103,8 @@ in { ''; }; - loginGroup = mkOption { - type = types.nullOr types.str; + loginGroup = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' This tells pgmanage to only allow users in a certain PostgreSQL group to @@ -116,8 +113,8 @@ in { ''; }; - loginTimeout = mkOption { - type = types.int; + loginTimeout = lib.mkOption { + type = lib.types.int; default = 3600; description = '' Number of seconds of inactivity before user is automatically logged @@ -125,8 +122,8 @@ in { ''; }; - sqlRoot = mkOption { - type = types.str; + sqlRoot = lib.mkOption { + type = lib.types.str; default = "/var/lib/pgmanage"; description = '' This tells pgmanage where to put the SQL file history. All tabs are saved @@ -135,15 +132,15 @@ in { ''; }; - tls = mkOption { - type = types.nullOr (types.submodule { + tls = lib.mkOption { + type = lib.types.nullOr (lib.types.submodule { options = { - cert = mkOption { - type = types.str; + cert = lib.mkOption { + type = lib.types.str; description = "TLS certificate"; }; - key = mkOption { - type = types.str; + key = lib.mkOption { + type = lib.types.str; description = "TLS key"; }; }; @@ -162,8 +159,8 @@ in { ''; }; - logLevel = mkOption { - type = types.enum ["error" "warn" "notice" "info"]; + logLevel = lib.mkOption { + type = lib.types.enum ["error" "warn" "notice" "info"]; default = "error"; description = '' Verbosity of logs @@ -171,7 +168,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.pgmanage = { description = "pgmanage - PostgreSQL Administration for the web"; wants = [ "postgresql.service" ]; @@ -181,7 +178,7 @@ in { User = pgmanage; Group = pgmanage; ExecStart = "${cfg.package}/sbin/pgmanage -c ${confFile}" + - optionalString cfg.localOnly " --local-only=true"; + lib.optionalString cfg.localOnly " --local-only=true"; }; }; users = { From edcd08a8ff4c8f112246650620bc93628934aae5 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:01 +0200 Subject: [PATCH 055/139] nixos/services.rethinkdb: remove `with lib;` --- .../modules/services/databases/rethinkdb.nix | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/databases/rethinkdb.nix b/nixos/modules/services/databases/rethinkdb.nix index c764d6c21c6c..1b85fd1bb7bd 100644 --- a/nixos/modules/services/databases/rethinkdb.nix +++ b/nixos/modules/services/databases/rethinkdb.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.rethinkdb; rethinkdb = cfg.package; @@ -15,41 +12,41 @@ in services.rethinkdb = { - enable = mkEnableOption "RethinkDB server"; + enable = lib.mkEnableOption "RethinkDB server"; - #package = mkOption { + #package = lib.mkOption { # default = pkgs.rethinkdb; # description = "Which RethinkDB derivation to use."; #}; - user = mkOption { + user = lib.mkOption { default = "rethinkdb"; description = "User account under which RethinkDB runs."; }; - group = mkOption { + group = lib.mkOption { default = "rethinkdb"; description = "Group which rethinkdb user belongs to."; }; - dbpath = mkOption { + dbpath = lib.mkOption { default = "/var/db/rethinkdb"; description = "Location where RethinkDB stores its data, 1 data directory per instance."; }; - pidpath = mkOption { + pidpath = lib.mkOption { default = "/run/rethinkdb"; description = "Location where each instance's pid file is located."; }; - #cfgpath = mkOption { + #cfgpath = lib.mkOption { # default = "/etc/rethinkdb/instances.d"; # description = "Location where RethinkDB stores it config files, 1 config file per instance."; #}; # TODO: currently not used by our implementation. - #instances = mkOption { - # type = types.attrsOf types.str; + #instances = lib.mkOption { + # type = lib.types.attrsOf lib.types.str; # default = {}; # description = "List of named RethinkDB instances in our cluster."; #}; @@ -59,7 +56,7 @@ in }; ###### implementation - config = mkIf config.services.rethinkdb.enable { + config = lib.mkIf config.services.rethinkdb.enable { environment.systemPackages = [ rethinkdb ]; @@ -93,13 +90,13 @@ in ''; }; - users.users.rethinkdb = mkIf (cfg.user == "rethinkdb") + users.users.rethinkdb = lib.mkIf (cfg.user == "rethinkdb") { name = "rethinkdb"; description = "RethinkDB server user"; isSystemUser = true; }; - users.groups = optionalAttrs (cfg.group == "rethinkdb") (singleton + users.groups = lib.optionalAttrs (cfg.group == "rethinkdb") (lib.singleton { name = "rethinkdb"; }); From 24f82fc6b5d4feb059173c3f650890c1f473f951 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:01 +0200 Subject: [PATCH 056/139] nixos/services.surrealdb: remove `with lib;` --- .../modules/services/databases/surrealdb.nix | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/databases/surrealdb.nix b/nixos/modules/services/databases/surrealdb.nix index 2118312d5a1b..b88129ebc6f4 100644 --- a/nixos/modules/services/databases/surrealdb.nix +++ b/nixos/modules/services/databases/surrealdb.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.surrealdb; @@ -8,12 +6,12 @@ in { options = { services.surrealdb = { - enable = mkEnableOption "SurrealDB, a scalable, distributed, collaborative, document-graph database, for the realtime web"; + enable = lib.mkEnableOption "SurrealDB, a scalable, distributed, collaborative, document-graph database, for the realtime web"; - package = mkPackageOption pkgs "surrealdb" { }; + package = lib.mkPackageOption pkgs "surrealdb" { }; - dbPath = mkOption { - type = types.str; + dbPath = lib.mkOption { + type = lib.types.str; description = '' The path that surrealdb will write data to. Use null for in-memory. Can be one of "memory", "file://:path", "tikv://:addr". @@ -22,8 +20,8 @@ in { example = "memory"; }; - host = mkOption { - type = types.str; + host = lib.mkOption { + type = lib.types.str; description = '' The host that surrealdb will connect to. ''; @@ -31,8 +29,8 @@ in { example = "127.0.0.1"; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; description = '' The port that surrealdb will connect to. ''; @@ -40,8 +38,8 @@ in { example = 8000; }; - extraFlags = mkOption { - type = types.listOf types.str; + extraFlags = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "--allow-all" "--auth" "--user root" "--pass root" ]; description = '' @@ -52,7 +50,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # Used to connect to the running service environment.systemPackages = [ cfg.package ] ; @@ -63,7 +61,7 @@ in { after = [ "network.target" ]; serviceConfig = { - ExecStart = "${cfg.package}/bin/surreal start --bind ${cfg.host}:${toString cfg.port} ${escapeShellArgs cfg.extraFlags} -- ${cfg.dbPath}"; + ExecStart = "${cfg.package}/bin/surreal start --bind ${cfg.host}:${toString cfg.port} ${lib.escapeShellArgs cfg.extraFlags} -- ${cfg.dbPath}"; DynamicUser = true; Restart = "on-failure"; StateDirectory = "surrealdb"; From 38b5d41259eab8d373cd3525e9dec1b0dea602eb Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:02 +0200 Subject: [PATCH 057/139] nixos/services.blueman: remove `with lib;` --- nixos/modules/services/desktops/blueman.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/desktops/blueman.nix b/nixos/modules/services/desktops/blueman.nix index 28c2daa7191d..4f02d288e2df 100644 --- a/nixos/modules/services/desktops/blueman.nix +++ b/nixos/modules/services/desktops/blueman.nix @@ -1,20 +1,17 @@ # blueman service { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.blueman; in { ###### interface options = { services.blueman = { - enable = mkEnableOption "blueman, a bluetooth manager"; + enable = lib.mkEnableOption "blueman, a bluetooth manager"; }; }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.blueman ]; From f2e025b9a2d45701095bb485b672951f99f184c7 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:02 +0200 Subject: [PATCH 058/139] nixos/services.cpupower-gui: remove `with lib;` --- nixos/modules/services/desktops/cpupower-gui.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/desktops/cpupower-gui.nix b/nixos/modules/services/desktops/cpupower-gui.nix index f66afc0a3dc1..ceed84da840e 100644 --- a/nixos/modules/services/desktops/cpupower-gui.nix +++ b/nixos/modules/services/desktops/cpupower-gui.nix @@ -1,13 +1,10 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.cpupower-gui; in { options = { services.cpupower-gui = { - enable = mkOption { + enable = lib.mkOption { type = lib.types.bool; default = false; example = true; @@ -20,7 +17,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.cpupower-gui ]; services.dbus.packages = [ pkgs.cpupower-gui ]; systemd.user = { From 5fd49dc5fc77c7f577a4033ac3baea919d8142bc Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:03 +0200 Subject: [PATCH 059/139] nixos/services.deepin.app-services: remove `with lib;` --- nixos/modules/services/desktops/deepin/app-services.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/desktops/deepin/app-services.nix b/nixos/modules/services/desktops/deepin/app-services.nix index 4702274df374..7d99bd11802f 100644 --- a/nixos/modules/services/desktops/deepin/app-services.nix +++ b/nixos/modules/services/desktops/deepin/app-services.nix @@ -1,11 +1,8 @@ { config, pkgs, lib, ... }: - -with lib; - { meta = { - maintainers = teams.deepin.members; + maintainers = lib.teams.deepin.members; }; ###### interface @@ -14,7 +11,7 @@ with lib; services.deepin.app-services = { - enable = mkEnableOption "service collection of DDE applications, including dconfig-center"; + enable = lib.mkEnableOption "service collection of DDE applications, including dconfig-center"; }; @@ -23,7 +20,7 @@ with lib; ###### implementation - config = mkIf config.services.deepin.app-services.enable { + config = lib.mkIf config.services.deepin.app-services.enable { users.groups.dde-dconfig-daemon = { }; users.users.dde-dconfig-daemon = { From 345c0fc9ae66cf3520ff0ab01101c462ffeb554b Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:03 +0200 Subject: [PATCH 060/139] nixos/services.deepin.dde-api.enable: remove `with lib;` --- nixos/modules/services/desktops/deepin/dde-api.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/desktops/deepin/dde-api.nix b/nixos/modules/services/desktops/deepin/dde-api.nix index 36f9881fc766..89889b3530c9 100644 --- a/nixos/modules/services/desktops/deepin/dde-api.nix +++ b/nixos/modules/services/desktops/deepin/dde-api.nix @@ -1,11 +1,8 @@ { config, pkgs, lib, ... }: - -with lib; - { meta = { - maintainers = teams.deepin.members; + maintainers = lib.teams.deepin.members; }; ###### interface @@ -14,7 +11,7 @@ with lib; services.deepin.dde-api = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' the DDE API, which provides some dbus interfaces that is used for screen zone detecting, thumbnail generating, and sound playing in Deepin Desktop Environment ''; @@ -26,7 +23,7 @@ with lib; ###### implementation - config = mkIf config.services.deepin.dde-api.enable { + config = lib.mkIf config.services.deepin.dde-api.enable { environment.systemPackages = [ pkgs.deepin.dde-api ]; From 8de58d85420da107cea486de5b22b1f18a0fe87c Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:03 +0200 Subject: [PATCH 061/139] nixos/services.dleyna-renderer: remove `with lib;` --- nixos/modules/services/desktops/dleyna-renderer.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/desktops/dleyna-renderer.nix b/nixos/modules/services/desktops/dleyna-renderer.nix index 7f88605f627c..f36f1fbb1a4e 100644 --- a/nixos/modules/services/desktops/dleyna-renderer.nix +++ b/nixos/modules/services/desktops/dleyna-renderer.nix @@ -1,14 +1,11 @@ # dleyna-renderer service. { config, lib, pkgs, ... }: - -with lib; - { ###### interface options = { services.dleyna-renderer = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable dleyna-renderer service, a DBus service @@ -20,7 +17,7 @@ with lib; ###### implementation - config = mkIf config.services.dleyna-renderer.enable { + config = lib.mkIf config.services.dleyna-renderer.enable { environment.systemPackages = [ pkgs.dleyna-renderer ]; services.dbus.packages = [ pkgs.dleyna-renderer ]; From fe453fb99f4bdc492cc3e743cbd9eccfc7e7ad1f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:04 +0200 Subject: [PATCH 062/139] nixos/services.dleyna-server: remove `with lib;` --- nixos/modules/services/desktops/dleyna-server.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/desktops/dleyna-server.nix b/nixos/modules/services/desktops/dleyna-server.nix index 9a131a5e700f..812110281ae4 100644 --- a/nixos/modules/services/desktops/dleyna-server.nix +++ b/nixos/modules/services/desktops/dleyna-server.nix @@ -1,14 +1,11 @@ # dleyna-server service. { config, lib, pkgs, ... }: - -with lib; - { ###### interface options = { services.dleyna-server = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable dleyna-server service, a DBus service @@ -20,7 +17,7 @@ with lib; ###### implementation - config = mkIf config.services.dleyna-server.enable { + config = lib.mkIf config.services.dleyna-server.enable { environment.systemPackages = [ pkgs.dleyna-server ]; services.dbus.packages = [ pkgs.dleyna-server ]; From b7a963841c4c7ffb03fc442d9e57ce41ccbe2d87 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:04 +0200 Subject: [PATCH 063/139] nixos/services.flatpak: remove `with lib;` --- nixos/modules/services/desktops/flatpak.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/desktops/flatpak.nix b/nixos/modules/services/desktops/flatpak.nix index b386bafcfe6f..da07f602b3a0 100644 --- a/nixos/modules/services/desktops/flatpak.nix +++ b/nixos/modules/services/desktops/flatpak.nix @@ -1,8 +1,5 @@ # flatpak service. { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.flatpak; in { @@ -14,15 +11,15 @@ in { ###### interface options = { services.flatpak = { - enable = mkEnableOption "flatpak"; + enable = lib.mkEnableOption "flatpak"; - package = mkPackageOption pkgs "flatpak" { }; + package = lib.mkPackageOption pkgs "flatpak" { }; }; }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { assertion = (config.xdg.portal.enable == true); From 42f3c52358874c8f2c1dfcd0cb9e19c6724f8a9c Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:04 +0200 Subject: [PATCH 064/139] nixos/services.gsignond: remove `with lib;` --- nixos/modules/services/desktops/gsignond.nix | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/desktops/gsignond.nix b/nixos/modules/services/desktops/gsignond.nix index 465acd73fa64..c21d3f0aafd8 100644 --- a/nixos/modules/services/desktops/gsignond.nix +++ b/nixos/modules/services/desktops/gsignond.nix @@ -1,15 +1,11 @@ # Accounts-SSO gSignOn daemon - { config, lib, pkgs, ... }: - -with lib; - let package = pkgs.gsignond.override { plugins = config.services.gsignond.plugins; }; in { - meta.maintainers = teams.pantheon.members; + meta.maintainers = lib.teams.pantheon.members; ###### interface @@ -17,8 +13,8 @@ in services.gsignond = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable gSignOn daemon, a DBus service @@ -26,8 +22,8 @@ in ''; }; - plugins = mkOption { - type = types.listOf types.package; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.package; default = []; description = '' What plugins to use with the gSignOn daemon. @@ -37,7 +33,7 @@ in }; ###### implementation - config = mkIf config.services.gsignond.enable { + config = lib.mkIf config.services.gsignond.enable { environment.etc."gsignond.conf".source = "${package}/etc/gsignond.conf"; services.dbus.packages = [ package ]; }; From 6c702884e9b7e9944f5111038183d17fe90b51b3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:05 +0200 Subject: [PATCH 065/139] nixos/services.neard: remove `with lib;` --- nixos/modules/services/desktops/neard.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/desktops/neard.nix b/nixos/modules/services/desktops/neard.nix index 5459d2e5a1e5..5d67adc09870 100644 --- a/nixos/modules/services/desktops/neard.nix +++ b/nixos/modules/services/desktops/neard.nix @@ -1,19 +1,16 @@ # neard service. { config, lib, pkgs, ... }: - -with lib; - { ###### interface options = { services.neard = { - enable = mkEnableOption "neard, an NFC daemon"; + enable = lib.mkEnableOption "neard, an NFC daemon"; }; }; ###### implementation - config = mkIf config.services.neard.enable { + config = lib.mkIf config.services.neard.enable { environment.systemPackages = [ pkgs.neard ]; services.dbus.packages = [ pkgs.neard ]; From 5ee287118fc9c9a1e92d9f7831f2b14833b4a70a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:05 +0200 Subject: [PATCH 066/139] nixos/services.psd: remove `with lib;` --- .../modules/services/desktops/profile-sync-daemon.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/desktops/profile-sync-daemon.nix b/nixos/modules/services/desktops/profile-sync-daemon.nix index 6206295272fc..48b29a59135c 100644 --- a/nixos/modules/services/desktops/profile-sync-daemon.nix +++ b/nixos/modules/services/desktops/profile-sync-daemon.nix @@ -1,19 +1,16 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.psd; in { - options.services.psd = with types; { - enable = mkOption { + options.services.psd = with lib.types; { + enable = lib.mkOption { type = bool; default = false; description = '' Whether to enable the Profile Sync daemon. ''; }; - resyncTimer = mkOption { + resyncTimer = lib.mkOption { type = str; default = "1h"; example = "1h 30min"; @@ -27,7 +24,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd = { user = { services = { From 63f72067f85286db833d534f5de02719c38a31aa Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:06 +0200 Subject: [PATCH 067/139] nixos/services.system-config-printer: remove `with lib;` --- nixos/modules/services/desktops/system-config-printer.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/desktops/system-config-printer.nix b/nixos/modules/services/desktops/system-config-printer.nix index 55f27b0e6534..6a8ff8dd19c6 100644 --- a/nixos/modules/services/desktops/system-config-printer.nix +++ b/nixos/modules/services/desktops/system-config-printer.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - { ###### interface @@ -10,7 +7,7 @@ with lib; services.system-config-printer = { - enable = mkEnableOption "system-config-printer, a service for CUPS administration used by printing interfaces"; + enable = lib.mkEnableOption "system-config-printer, a service for CUPS administration used by printing interfaces"; }; @@ -19,7 +16,7 @@ with lib; ###### implementation - config = mkIf config.services.system-config-printer.enable { + config = lib.mkIf config.services.system-config-printer.enable { services.dbus.packages = [ pkgs.system-config-printer From 506e98b3066d0df23e36988567df78ba1f926219 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:06 +0200 Subject: [PATCH 068/139] nixos/services.telepathy: remove `with lib;` --- nixos/modules/services/desktops/telepathy.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/desktops/telepathy.nix b/nixos/modules/services/desktops/telepathy.nix index b5f6a5fcbcfd..8f8adf7f4f83 100644 --- a/nixos/modules/services/desktops/telepathy.nix +++ b/nixos/modules/services/desktops/telepathy.nix @@ -1,13 +1,9 @@ # Telepathy daemon. - { config, lib, pkgs, ... }: - -with lib; - { meta = { - maintainers = teams.gnome.members; + maintainers = lib.teams.gnome.members; }; ###### interface @@ -16,8 +12,8 @@ with lib; services.telepathy = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable Telepathy service, a communications framework @@ -32,7 +28,7 @@ with lib; ###### implementation - config = mkIf config.services.telepathy.enable { + config = lib.mkIf config.services.telepathy.enable { environment.systemPackages = [ pkgs.telepathy-mission-control ]; From dee0a9173011dc3184a659653d03acd81175c84a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:06 +0200 Subject: [PATCH 069/139] nixos/services.tumbler: remove `with lib;` --- nixos/modules/services/desktops/tumbler.nix | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/desktops/tumbler.nix b/nixos/modules/services/desktops/tumbler.nix index f5341df2f7a4..a52767301949 100644 --- a/nixos/modules/services/desktops/tumbler.nix +++ b/nixos/modules/services/desktops/tumbler.nix @@ -1,9 +1,5 @@ # Tumbler - { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.tumbler; @@ -13,13 +9,13 @@ in { imports = [ - (mkRemovedOptionModule + (lib.mkRemovedOptionModule [ "services" "tumbler" "package" ] "") ]; meta = with lib; { - maintainers = with maintainers; [ ] ++ teams.pantheon.members; + maintainers = with lib.maintainers; [ ] ++ lib.teams.pantheon.members; }; ###### interface @@ -28,7 +24,7 @@ in services.tumbler = { - enable = mkEnableOption "Tumbler, A D-Bus thumbnailer service"; + enable = lib.mkEnableOption "Tumbler, A D-Bus thumbnailer service"; }; @@ -37,7 +33,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs.xfce; [ tumbler From 8ddfb1375fb4300abc94ef961de8981bbc65927a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:07 +0200 Subject: [PATCH 070/139] nixos/services.distccd: remove `with lib;` --- .../modules/services/development/distccd.nix | 69 +++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/development/distccd.nix b/nixos/modules/services/development/distccd.nix index 916c0905034c..7eb9789b5c38 100644 --- a/nixos/modules/services/development/distccd.nix +++ b/nixos/modules/services/development/distccd.nix @@ -1,17 +1,14 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.distccd; in { options = { services.distccd = { - enable = mkEnableOption "distccd, a distributed C/C++ compiler"; + enable = lib.mkEnableOption "distccd, a distributed C/C++ compiler"; - allowedClients = mkOption { - type = types.listOf types.str; + allowedClients = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "127.0.0.1" ]; example = [ "127.0.0.1" "192.168.0.0/24" "10.0.0.0/24" ]; description = '' @@ -23,16 +20,16 @@ in ''; }; - jobTimeout = mkOption { - type = types.nullOr types.int; + jobTimeout = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' Maximum duration, in seconds, of a single compilation request. ''; }; - logLevel = mkOption { - type = types.nullOr (types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]); + logLevel = lib.mkOption { + type = lib.types.nullOr (lib.types.enum [ "critical" "error" "warning" "notice" "info" "debug" ]); default = "warning"; description = '' Set the minimum severity of error that will be included in the log @@ -41,35 +38,35 @@ in ''; }; - maxJobs = mkOption { - type = types.nullOr types.int; + maxJobs = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' - Maximum number of tasks distccd should execute at any time. + Maximum number of tasks distccd should execute at lib.any time. ''; }; - nice = mkOption { - type = types.nullOr types.int; + nice = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' Niceness of the compilation tasks. ''; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Opens the specified TCP port for distcc. ''; }; - package = mkPackageOption pkgs "distcc" { }; + package = lib.mkPackageOption pkgs "distcc" { }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 3632; description = '' The TCP port which distccd will listen on. @@ -77,9 +74,9 @@ in }; stats = { - enable = mkEnableOption "statistics reporting via HTTP server"; - port = mkOption { - type = types.port; + enable = lib.mkEnableOption "statistics reporting via HTTP server"; + port = lib.mkOption { + type = lib.types.port; default = 3633; description = '' The TCP port which the distccd statistics HTTP server will listen @@ -88,8 +85,8 @@ in }; }; - zeroconf = mkOption { - type = types.bool; + zeroconf = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to register via mDNS/DNS-SD @@ -98,10 +95,10 @@ in }; }; - config = mkIf cfg.enable { - networking.firewall = mkIf cfg.openFirewall { + config = lib.mkIf cfg.enable { + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ] - ++ optionals cfg.stats.enable [ cfg.stats.port ]; + ++ lib.optionals cfg.stats.enable [ cfg.stats.port ]; }; systemd.services.distccd = { @@ -124,14 +121,14 @@ in --daemon \ --enable-tcp-insecure \ --port ${toString cfg.port} \ - ${optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \ - ${optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \ - ${optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \ - ${optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \ - ${optionalString cfg.stats.enable "--stats"} \ - ${optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \ - ${optionalString cfg.zeroconf "--zeroconf"} \ - ${concatMapStrings (c: "--allow ${c} ") cfg.allowedClients} + ${lib.optionalString (cfg.jobTimeout != null) "--job-lifetime ${toString cfg.jobTimeout}"} \ + ${lib.optionalString (cfg.logLevel != null) "--log-level ${cfg.logLevel}"} \ + ${lib.optionalString (cfg.maxJobs != null) "--jobs ${toString cfg.maxJobs}"} \ + ${lib.optionalString (cfg.nice != null) "--nice ${toString cfg.nice}"} \ + ${lib.optionalString cfg.stats.enable "--stats"} \ + ${lib.optionalString cfg.stats.enable "--stats-port ${toString cfg.stats.port}"} \ + ${lib.optionalString cfg.zeroconf "--zeroconf"} \ + ${lib.concatMapStrings (c: "--allow ${c} ") cfg.allowedClients} ''; }; }; From 25ddce8617d3a7ea8fa10171f2aa90135dfc1eba Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:07 +0200 Subject: [PATCH 071/139] nixos/services.hoogle: remove `with lib;` --- nixos/modules/services/development/hoogle.nix | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/nixos/modules/services/development/hoogle.nix b/nixos/modules/services/development/hoogle.nix index 1747ef391290..0a09a339e2be 100644 --- a/nixos/modules/services/development/hoogle.nix +++ b/nixos/modules/services/development/hoogle.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.hoogle; @@ -14,21 +11,21 @@ let in { options.services.hoogle = { - enable = mkEnableOption "Haskell documentation server"; + enable = lib.mkEnableOption "Haskell documentation server"; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8080; description = '' Port number Hoogle will be listening to. ''; }; - packages = mkOption { - type = types.functionTo (types.listOf types.package); + packages = lib.mkOption { + type = lib.types.functionTo (lib.types.listOf lib.types.package); default = hp: []; - defaultText = literalExpression "hp: []"; - example = literalExpression "hp: with hp; [ text lens ]"; + defaultText = lib.literalExpression "hp: []"; + example = lib.literalExpression "hp: with hp; [ text lens ]"; description = '' The Haskell packages to generate documentation for. @@ -38,27 +35,27 @@ in { ''; }; - haskellPackages = mkOption { + haskellPackages = lib.mkOption { description = "Which haskell package set to use."; - type = types.attrs; + type = lib.types.attrs; default = pkgs.haskellPackages; - defaultText = literalExpression "pkgs.haskellPackages"; + defaultText = lib.literalExpression "pkgs.haskellPackages"; }; - home = mkOption { - type = types.str; + home = lib.mkOption { + type = lib.types.str; description = "Url for hoogle logo"; default = "https://hoogle.haskell.org"; }; - host = mkOption { - type = types.str; + host = lib.mkOption { + type = lib.types.str; description = "Set the host to bind on."; default = "127.0.0.1"; }; - extraOptions = mkOption { - type = types.listOf types.str; + extraOptions = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "--no-security-headers" ]; description = '' @@ -68,7 +65,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.hoogle = { description = "Haskell documentation server"; @@ -78,7 +75,7 @@ in { Restart = "always"; ExecStart = '' ${hoogleEnv}/bin/hoogle server --local --port ${toString cfg.port} --home ${cfg.home} --host ${cfg.host} \ - ${concatStringsSep " " cfg.extraOptions} + ${lib.concatStringsSep " " cfg.extraOptions} ''; DynamicUser = true; From 5134f4b55cb2305dde6b35b06d4c59a9efa54554 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:08 +0200 Subject: [PATCH 072/139] nixos/services.jupyter: remove `with lib;` --- .../services/development/jupyter/default.nix | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/nixos/modules/services/development/jupyter/default.nix b/nixos/modules/services/development/jupyter/default.nix index 561ea86ea18b..b3991fa4c268 100644 --- a/nixos/modules/services/development/jupyter/default.nix +++ b/nixos/modules/services/development/jupyter/default.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.jupyter; @@ -21,13 +18,13 @@ let ''; in { - meta.maintainers = with maintainers; [ aborsu ]; + meta.maintainers = with lib.maintainers; [ aborsu ]; options.services.jupyter = { - enable = mkEnableOption "Jupyter development server"; + enable = lib.mkEnableOption "Jupyter development server"; - ip = mkOption { - type = types.str; + ip = lib.mkOption { + type = lib.types.str; default = "localhost"; description = '' IP address Jupyter will be listening on. @@ -37,10 +34,10 @@ in { # NOTE: We don't use top-level jupyter because we don't # want to pass in JUPYTER_PATH but use .environment instead, # saving a rebuild. - package = mkPackageOption pkgs [ "python3" "pkgs" "notebook" ] { }; + package = lib.mkPackageOption pkgs [ "python3" "pkgs" "notebook" ] { }; - command = mkOption { - type = types.str; + command = lib.mkOption { + type = lib.types.str; default = "jupyter-notebook"; example = "jupyter-lab"; description = '' @@ -49,24 +46,24 @@ in { ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8888; description = '' Port number Jupyter will be listening on. ''; }; - notebookDir = mkOption { - type = types.str; + notebookDir = lib.mkOption { + type = lib.types.str; default = "~/"; description = '' Root directory for notebooks. ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "jupyter"; description = '' Name of the user used to run the jupyter service. @@ -76,8 +73,8 @@ in { example = "aborsu"; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "jupyter"; description = '' Name of the group used to run the jupyter service. @@ -86,8 +83,8 @@ in { example = "users"; }; - password = mkOption { - type = types.str; + password = lib.mkOption { + type = lib.types.str; description = '' Password to use with notebook. Can be generated using: @@ -102,21 +99,21 @@ in { example = "'sha1:1b961dc713fb:88483270a63e57d18d43cf337e629539de1436ba'"; }; - notebookConfig = mkOption { - type = types.lines; + notebookConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Raw jupyter config. ''; }; - kernels = mkOption { - type = types.nullOr (types.attrsOf(types.submodule (import ./kernel-options.nix { + kernels = lib.mkOption { + type = lib.types.nullOr (lib.types.attrsOf(lib.types.submodule (import ./kernel-options.nix { inherit lib pkgs; }))); default = null; - example = literalExpression '' + example = lib.literalExpression '' { python3 = let env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ @@ -153,8 +150,8 @@ in { }; }; - config = mkMerge [ - (mkIf cfg.enable { + config = lib.mkMerge [ + (lib.mkIf cfg.enable { systemd.services.jupyter = { description = "Jupyter development server"; @@ -183,10 +180,10 @@ in { }; }; }) - (mkIf (cfg.enable && (cfg.group == "jupyter")) { + (lib.mkIf (cfg.enable && (cfg.group == "jupyter")) { users.groups.jupyter = {}; }) - (mkIf (cfg.enable && (cfg.user == "jupyter")) { + (lib.mkIf (cfg.enable && (cfg.user == "jupyter")) { users.extraUsers.jupyter = { extraGroups = [ cfg.group ]; home = "/var/lib/jupyter"; From a986e3c10a263569ea4dfb909cb45648fc807a23 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:08 +0200 Subject: [PATCH 073/139] nixos/services.jupyter.kernels: remove `with lib;` --- .../development/jupyter/kernel-options.nix | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/nixos/modules/services/development/jupyter/kernel-options.nix b/nixos/modules/services/development/jupyter/kernel-options.nix index 8a91125e6cce..421e1a0cf51d 100644 --- a/nixos/modules/services/development/jupyter/kernel-options.nix +++ b/nixos/modules/services/development/jupyter/kernel-options.nix @@ -1,17 +1,14 @@ # Options that can be used for creating a jupyter kernel. { lib, pkgs }: - -with lib; - { freeformType = (pkgs.formats.json { }).type; options = { - displayName = mkOption { - type = types.str; + displayName = lib.mkOption { + type = lib.types.str; default = ""; - example = literalExpression '' + example = lib.literalExpression '' "Python 3" "Python 3 for Data Science" ''; @@ -20,8 +17,8 @@ with lib; ''; }; - argv = mkOption { - type = types.listOf types.str; + argv = lib.mkOption { + type = lib.types.listOf lib.types.str; example = [ "{customEnv.interpreter}" "-m" @@ -34,16 +31,16 @@ with lib; ''; }; - language = mkOption { - type = types.str; + language = lib.mkOption { + type = lib.types.str; example = "python"; description = '' Language of the environment. Typically the name of the binary. ''; }; - env = mkOption { - type = types.attrsOf types.str; + env = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = { }; example = { OMP_NUM_THREADS = "1"; }; description = '' @@ -51,27 +48,27 @@ with lib; ''; }; - logo32 = mkOption { - type = types.nullOr types.path; + logo32 = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; - example = literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-32x32.png"''; + example = lib.literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-32x32.png"''; description = '' Path to 32x32 logo png. ''; }; - logo64 = mkOption { - type = types.nullOr types.path; + logo64 = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; - example = literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-64x64.png"''; + example = lib.literalExpression ''"''${env.sitePackages}/ipykernel/resources/logo-64x64.png"''; description = '' Path to 64x64 logo png. ''; }; - extraPaths = mkOption { - type = types.attrsOf types.path; + extraPaths = lib.mkOption { + type = lib.types.attrsOf lib.types.path; default = { }; - example = literalExpression ''"{ examples = ''${env.sitePack}/IRkernel/kernelspec/kernel.js"; }''; + example = lib.literalExpression ''"{ examples = ''${env.sitePack}/IRkernel/kernelspec/kernel.js"; }''; description = '' Extra paths to link in kernel directory ''; From df4401eac86fcc7528f02f143aa802997ab9a562 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:09 +0200 Subject: [PATCH 074/139] nixos/services.jupyterhub: remove `with lib;` --- .../development/jupyterhub/default.nix | 53 +++++++++---------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/nixos/modules/services/development/jupyterhub/default.nix b/nixos/modules/services/development/jupyterhub/default.nix index d9a37ad915d4..196d4aafabd4 100644 --- a/nixos/modules/services/development/jupyterhub/default.nix +++ b/nixos/modules/services/development/jupyterhub/default.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.jupyterhub; @@ -27,13 +24,13 @@ let ${cfg.extraConfig} ''; in { - meta.maintainers = with maintainers; [ costrouc ]; + meta.maintainers = with lib.maintainers; [ costrouc ]; options.services.jupyterhub = { - enable = mkEnableOption "Jupyterhub development server"; + enable = lib.mkEnableOption "Jupyterhub development server"; - authentication = mkOption { - type = types.str; + authentication = lib.mkOption { + type = lib.types.str; default = "jupyterhub.auth.PAMAuthenticator"; description = '' Jupyterhub authentication to use @@ -43,8 +40,8 @@ in { ''; }; - spawner = mkOption { - type = types.str; + spawner = lib.mkOption { + type = lib.types.str; default = "systemdspawner.SystemdSpawner"; description = '' Jupyterhub spawner to use @@ -54,8 +51,8 @@ in { ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Extra contents appended to the jupyterhub configuration @@ -72,13 +69,13 @@ in { ''; }; - jupyterhubEnv = mkOption { - type = types.package; + jupyterhubEnv = lib.mkOption { + type = lib.types.package; default = pkgs.python3.withPackages (p: with p; [ jupyterhub jupyterhub-systemdspawner ]); - defaultText = literalExpression '' + defaultText = lib.literalExpression '' pkgs.python3.withPackages (p: with p; [ jupyterhub jupyterhub-systemdspawner @@ -94,13 +91,13 @@ in { ''; }; - jupyterlabEnv = mkOption { - type = types.package; + jupyterlabEnv = lib.mkOption { + type = lib.types.package; default = pkgs.python3.withPackages (p: with p; [ jupyterhub jupyterlab ]); - defaultText = literalExpression '' + defaultText = lib.literalExpression '' pkgs.python3.withPackages (p: with p; [ jupyterhub jupyterlab @@ -117,13 +114,13 @@ in { ''; }; - kernels = mkOption { - type = types.nullOr (types.attrsOf(types.submodule (import ../jupyter/kernel-options.nix { + kernels = lib.mkOption { + type = lib.types.nullOr (lib.types.attrsOf(lib.types.submodule (import ../jupyter/kernel-options.nix { inherit lib pkgs; }))); default = null; - example = literalExpression '' + example = lib.literalExpression '' { python3 = let env = (pkgs.python3.withPackages (pythonPackages: with pythonPackages; [ @@ -156,24 +153,24 @@ in { ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 8000; description = '' Port number Jupyterhub will be listening on ''; }; - host = mkOption { - type = types.str; + host = lib.mkOption { + type = lib.types.str; default = "0.0.0.0"; description = '' Bind IP JupyterHub will be listening on ''; }; - stateDirectory = mkOption { - type = types.str; + stateDirectory = lib.mkOption { + type = lib.types.str; default = "jupyterhub"; description = '' Directory for jupyterhub state (token + database) @@ -181,8 +178,8 @@ in { }; }; - config = mkMerge [ - (mkIf cfg.enable { + config = lib.mkMerge [ + (lib.mkIf cfg.enable { systemd.services.jupyterhub = { description = "Jupyterhub development server"; From f65c35866a57a1860318bd6cef3681b07e68c7c2 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:09 +0200 Subject: [PATCH 075/139] nixos/services.livebook: remove `with lib;` --- .../modules/services/development/livebook.nix | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/development/livebook.nix b/nixos/modules/services/development/livebook.nix index 859083635201..3861d18e4ab5 100644 --- a/nixos/modules/services/development/livebook.nix +++ b/nixos/modules/services/development/livebook.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.livebook; in @@ -10,12 +8,12 @@ in # either has access to all the data or none at all), the decision # was made to run this as a user service. If that changes in the # future, this can be changed to a system service. - enableUserService = mkEnableOption "a user service for Livebook"; + enableUserService = lib.mkEnableOption "a user service for Livebook"; - package = mkPackageOption pkgs "livebook" { }; + package = lib.mkPackageOption pkgs "livebook" { }; - environment = mkOption { - type = with types; attrsOf (nullOr (oneOf [ bool int str ])); + environment = lib.mkOption { + type = with lib.types; attrsOf (nullOr (oneOf [ bool int str ])); default = { }; description = '' Environment variables to set. @@ -37,15 +35,15 @@ in variables specified in this option. ''; - example = literalExpression '' + example = lib.literalExpression '' { LIVEBOOK_PORT = 8080; } ''; }; - environmentFile = mkOption { - type = with types; nullOr types.path; + environmentFile = lib.mkOption { + type = with lib.types; nullOr lib.types.path; default = null; description = '' Additional dnvironment file as defined in {manpage}`systemd.exec(5)`. @@ -72,17 +70,17 @@ in example = "/var/lib/livebook.env"; }; - extraPackages = mkOption { - type = with types; listOf package; + extraPackages = lib.mkOption { + type = with lib.types; listOf package; default = [ ]; description = '' Extra packages to make available to the Livebook service. ''; - example = literalExpression "with pkgs; [ gcc gnumake ]"; + example = lib.literalExpression "with pkgs; [ gcc gnumake ]"; }; }; - config = mkIf cfg.enableUserService { + config = lib.mkIf cfg.enableUserService { systemd.user.services.livebook = { serviceConfig = { Restart = "always"; @@ -97,8 +95,8 @@ in # stuck running a `cat /dev/urandom | tr | fold` pipeline. IgnoreSIGPIPE = false; }; - environment = mapAttrs (name: value: - if isBool value then boolToString value else toString value) + environment = lib.mapAttrs (name: value: + if lib.isBool value then lib.boolToString value else toString value) cfg.environment; path = [ pkgs.bash ] ++ cfg.extraPackages; wantedBy = [ "default.target" ]; From 45bc5974dd41d4fcfcea29e8f575cfb7ea77a671 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:09 +0200 Subject: [PATCH 076/139] nixos/services.rstudio-server: remove `with lib;` --- .../development/rstudio-server/default.nix | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/development/rstudio-server/default.nix b/nixos/modules/services/development/rstudio-server/default.nix index 0126e105b3d3..70f665b09e31 100644 --- a/nixos/modules/services/development/rstudio-server/default.nix +++ b/nixos/modules/services/development/rstudio-server/default.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.rstudio-server; @@ -18,41 +15,41 @@ let in { - meta.maintainers = with maintainers; [ jbedo cfhammill ]; + meta.maintainers = with lib.maintainers; [ jbedo cfhammill ]; options.services.rstudio-server = { - enable = mkEnableOption "RStudio server"; + enable = lib.mkEnableOption "RStudio server"; - serverWorkingDir = mkOption { - type = types.str; + serverWorkingDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/rstudio-server"; description = '' Default working directory for server (server-working-dir in rserver.conf). ''; }; - listenAddr = mkOption { - type = types.str; + listenAddr = lib.mkOption { + type = lib.types.str; default = "127.0.0.1"; description = '' Address to listen on (www-address in rserver.conf). ''; }; - package = mkPackageOption pkgs "rstudio-server" { + package = lib.mkPackageOption pkgs "rstudio-server" { example = "rstudioServerWrapper.override { packages = [ pkgs.rPackages.ggplot2 ]; }"; }; - rserverExtraConfig = mkOption { - type = types.str; + rserverExtraConfig = lib.mkOption { + type = lib.types.str; default = ""; description = '' Extra contents for rserver.conf. ''; }; - rsessionExtraConfig = mkOption { - type = types.str; + rsessionExtraConfig = lib.mkOption { + type = lib.types.str; default = ""; description = '' Extra contents for resssion.conf. @@ -61,7 +58,7 @@ in }; - config = mkIf cfg.enable + config = lib.mkIf cfg.enable { systemd.services.rstudio-server = { description = "Rstudio server"; From 260654677f1e4c502bfe01c73b7795c9e1c4b2d4 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:10 +0200 Subject: [PATCH 077/139] nixos/services.greetd: remove `with lib;` --- .../services/display-managers/greetd.nix | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/nixos/modules/services/display-managers/greetd.nix b/nixos/modules/services/display-managers/greetd.nix index 118a3e1df378..9774b6a4d12e 100644 --- a/nixos/modules/services/display-managers/greetd.nix +++ b/nixos/modules/services/display-managers/greetd.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: -with lib; - let cfg = config.services.greetd; tty = "tty${toString cfg.vt}"; @@ -8,13 +6,13 @@ let in { options.services.greetd = { - enable = mkEnableOption "greetd, a minimal and flexible login manager daemon"; + enable = lib.mkEnableOption "greetd, a minimal and flexible login manager daemon"; - package = mkPackageOption pkgs [ "greetd" "greetd" ] { }; + package = lib.mkPackageOption pkgs [ "greetd" "greetd" ] { }; - settings = mkOption { + settings = lib.mkOption { type = settingsFormat.type; - example = literalExpression '' + example = lib.literalExpression '' { default_session = { command = "''${pkgs.greetd.greetd}/bin/agreety --cmd sway"; @@ -27,8 +25,8 @@ in ''; }; - greeterManagesPlymouth = mkOption { - type = types.bool; + greeterManagesPlymouth = lib.mkOption { + type = lib.types.bool; internal = true; default = false; description = '' @@ -38,18 +36,18 @@ in ''; }; - vt = mkOption { - type = types.int; + vt = lib.mkOption { + type = lib.types.int; default = 1; description = '' The virtual console (tty) that greetd should use. This option also disables getty on that tty. ''; }; - restart = mkOption { - type = types.bool; + restart = lib.mkOption { + type = lib.types.bool; default = !(cfg.settings ? initial_session); - defaultText = literalExpression "!(config.services.greetd.settings ? initial_session)"; + defaultText = lib.literalExpression "!(config.services.greetd.settings ? initial_session)"; description = '' Whether to restart greetd when it terminates (e.g. on failure). This is usually desirable so a user can always log in, but should be disabled when using 'settings.initial_session' (autologin), @@ -57,15 +55,15 @@ in ''; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { - services.greetd.settings.terminal.vt = mkDefault cfg.vt; - services.greetd.settings.default_session.user = mkDefault "greeter"; + services.greetd.settings.terminal.vt = lib.mkDefault cfg.vt; + services.greetd.settings.default_session.user = lib.mkDefault "greeter"; security.pam.services.greetd = { allowNullPassword = true; startSession = true; - enableGnomeKeyring = mkDefault config.services.gnome.gnome-keyring.enable; + enableGnomeKeyring = lib.mkDefault config.services.gnome.gnome-keyring.enable; }; # This prevents nixos-rebuild from killing greetd by activating getty again @@ -95,7 +93,7 @@ in serviceConfig = { ExecStart = "${pkgs.greetd.greetd}/bin/greetd --config ${settingsFormat.generate "greetd.toml" cfg.settings}"; - Restart = mkIf cfg.restart "on-success"; + Restart = lib.mkIf cfg.restart "on-success"; # Defaults from greetd upstream configuration IgnoreSIGPIPE = false; @@ -128,5 +126,5 @@ in users.groups.greeter = { }; }; - meta.maintainers = with maintainers; [ queezle ]; + meta.maintainers = with lib.maintainers; [ queezle ]; } From facc95c0ce7a4d1bfbaffd5bdda7cbf003f90436 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:10 +0200 Subject: [PATCH 078/139] nixos/services.emacs: remove `with lib;` --- nixos/modules/services/editors/emacs.nix | 31 +++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/nixos/modules/services/editors/emacs.nix b/nixos/modules/services/editors/emacs.nix index 98d8506e6727..ee1951e26222 100644 --- a/nixos/modules/services/editors/emacs.nix +++ b/nixos/modules/services/editors/emacs.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.emacs; @@ -18,8 +15,8 @@ in { options.services.emacs = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable a user service for the Emacs daemon. Use `emacsclient` to connect to the @@ -28,8 +25,8 @@ in ''; }; - install = mkOption { - type = types.bool; + install = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to install a user service for the Emacs daemon. Once @@ -43,10 +40,10 @@ in }; - package = mkPackageOption pkgs "emacs" { }; + package = lib.mkPackageOption pkgs "emacs" { }; - defaultEditor = mkOption { - type = types.bool; + defaultEditor = lib.mkOption { + type = lib.types.bool; default = false; description = '' When enabled, configures emacsclient to be the default editor @@ -54,17 +51,17 @@ in ''; }; - startWithGraphical = mkOption { - type = types.bool; + startWithGraphical = lib.mkOption { + type = lib.types.bool; default = config.services.xserver.enable; - defaultText = literalExpression "config.services.xserver.enable"; + defaultText = lib.literalExpression "config.services.xserver.enable"; description = '' Start emacs with the graphical session instead of any session. Without this, emacs clients will not be able to create frames in the graphical session. ''; }; }; - config = mkIf (cfg.enable || cfg.install) { + config = lib.mkIf (cfg.enable || cfg.install) { systemd.user.services.emacs = { description = "Emacs: the extensible, self-documenting text editor"; @@ -75,16 +72,16 @@ in Restart = "always"; }; - unitConfig = optionalAttrs cfg.startWithGraphical { + unitConfig = lib.optionalAttrs cfg.startWithGraphical { After = "graphical-session.target"; }; - } // optionalAttrs cfg.enable { + } // lib.optionalAttrs cfg.enable { wantedBy = if cfg.startWithGraphical then [ "graphical-session.target" ] else [ "default.target" ]; }; environment.systemPackages = [ cfg.package editorScript ]; - environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "emacseditor"); + environment.variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "emacseditor"); }; meta.doc = ./emacs.md; From 11e4758bd31909a7eb6ba453d1c5fe0e258b20d6 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:11 +0200 Subject: [PATCH 079/139] nixos/services.haste: remove `with lib;` --- nixos/modules/services/editors/haste.nix | 37 +++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/editors/haste.nix b/nixos/modules/services/editors/haste.nix index f2a40e62e718..cf5bde6a5865 100644 --- a/nixos/modules/services/editors/haste.nix +++ b/nixos/modules/services/editors/haste.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let pkg = pkgs.haste-server; cfg = config.services.haste-server; @@ -10,10 +7,10 @@ let in { options.services.haste-server = { - enable = mkEnableOption "haste-server"; - openFirewall = mkEnableOption "firewall passthrough for haste-server"; + enable = lib.mkEnableOption "haste-server"; + openFirewall = lib.mkEnableOption "firewall passthrough for haste-server"; - settings = mkOption { + settings = lib.mkOption { description = '' Configuration for haste-server. For documentation see [project readme](https://github.com/toptal/haste-server#settings) @@ -22,21 +19,21 @@ in }; }; - config = mkIf (cfg.enable) { - networking.firewall.allowedTCPPorts = mkIf (cfg.openFirewall) [ cfg.settings.port ]; + config = lib.mkIf (cfg.enable) { + networking.firewall.allowedTCPPorts = lib.mkIf (cfg.openFirewall) [ cfg.settings.port ]; services.haste-server = { settings = { - host = mkDefault "::"; - port = mkDefault 7777; + host = lib.mkDefault "::"; + port = lib.mkDefault 7777; - keyLength = mkDefault 10; - maxLength = mkDefault 400000; + keyLength = lib.mkDefault 10; + maxLength = lib.mkDefault 400000; - staticMaxAge = mkDefault 86400; - recompressStaticAssets = mkDefault false; + staticMaxAge = lib.mkDefault 86400; + recompressStaticAssets = lib.mkDefault false; - logging = mkDefault [ + logging = lib.mkDefault [ { level = "verbose"; type = "Console"; @@ -44,25 +41,25 @@ in } ]; - keyGenerator = mkDefault { + keyGenerator = lib.mkDefault { type = "phonetic"; }; rateLimits = { categories = { normal = { - totalRequests = mkDefault 500; - every = mkDefault 60000; + totalRequests = lib.mkDefault 500; + every = lib.mkDefault 60000; }; }; }; - storage = mkDefault { + storage = lib.mkDefault { type = "file"; }; documents = { - about = mkDefault "${pkg}/share/haste-server/about.md"; + about = lib.mkDefault "${pkg}/share/haste-server/about.md"; }; }; }; From fe2d014a096812a673c64226c9fa8d05fbbcc6fc Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:11 +0200 Subject: [PATCH 080/139] nixos/services.infinoted: remove `with lib;` --- nixos/modules/services/editors/infinoted.nix | 67 ++++++++++---------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/editors/infinoted.nix b/nixos/modules/services/editors/infinoted.nix index 2a7f1d45c2d8..b6e353b637e8 100644 --- a/nixos/modules/services/editors/infinoted.nix +++ b/nixos/modules/services/editors/infinoted.nix @@ -1,33 +1,30 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.infinoted; in { options.services.infinoted = { - enable = mkEnableOption "infinoted"; + enable = lib.mkEnableOption "infinoted"; - package = mkPackageOption pkgs "libinfinity" { }; + package = lib.mkPackageOption pkgs "libinfinity" { }; - keyFile = mkOption { - type = types.nullOr types.path; + keyFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Private key to use for TLS ''; }; - certificateFile = mkOption { - type = types.nullOr types.path; + certificateFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Server certificate to use for TLS ''; }; - certificateChain = mkOption { - type = types.nullOr types.path; + certificateChain = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Chain of CA-certificates to which our `certificateFile` is relative. @@ -35,48 +32,48 @@ in { ''; }; - securityPolicy = mkOption { - type = types.enum ["no-tls" "allow-tls" "require-tls"]; + securityPolicy = lib.mkOption { + type = lib.types.enum ["no-tls" "allow-tls" "require-tls"]; default = "require-tls"; description = '' How strictly to enforce clients connection with TLS. ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 6523; description = '' Port to listen on ''; }; - rootDirectory = mkOption { - type = types.path; + rootDirectory = lib.mkOption { + type = lib.types.path; default = "/var/lib/infinoted/documents/"; description = '' Root of the directory structure to serve ''; }; - plugins = mkOption { - type = types.listOf types.str; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "note-text" "note-chat" "logging" "autosave" ]; description = '' Plugins to enable ''; }; - passwordFile = mkOption { - type = types.nullOr types.path; + passwordFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' File to read server-wide password from ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = '' [autosave] interval=10 @@ -86,16 +83,16 @@ in { ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "infinoted"; description = '' What to call the dedicated user under which infinoted is run ''; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = "infinoted"; description = '' What to call the primary group of the dedicated user under which infinoted is run @@ -103,15 +100,15 @@ in { }; }; - config = mkIf (cfg.enable) { - users.users = optionalAttrs (cfg.user == "infinoted") + config = lib.mkIf (cfg.enable) { + users.users = lib.optionalAttrs (cfg.user == "infinoted") { infinoted = { description = "Infinoted user"; group = cfg.group; isSystemUser = true; }; }; - users.groups = optionalAttrs (cfg.group == "infinoted") + users.groups = lib.optionalAttrs (cfg.group == "infinoted") { infinoted = { }; }; @@ -134,14 +131,14 @@ in { install -o ${cfg.user} -g ${cfg.group} -m 0600 /dev/null /var/lib/infinoted/infinoted.conf cat >>/var/lib/infinoted/infinoted.conf < Date: Tue, 27 Aug 2024 20:43:11 +0200 Subject: [PATCH 081/139] nixos/services.odoo: remove `with lib;` --- nixos/modules/services/finance/odoo.nix | 37 ++++++++++++------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/finance/odoo.nix b/nixos/modules/services/finance/odoo.nix index 074617d35e3d..1414500389d6 100644 --- a/nixos/modules/services/finance/odoo.nix +++ b/nixos/modules/services/finance/odoo.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.odoo; format = pkgs.formats.ini {}; @@ -9,35 +6,35 @@ in { options = { services.odoo = { - enable = mkEnableOption "odoo, an open source ERP and CRM system"; + enable = lib.mkEnableOption "odoo, an open source ERP and CRM system"; - package = mkPackageOption pkgs "odoo" { }; + package = lib.mkPackageOption pkgs "odoo" { }; - addons = mkOption { - type = with types; listOf package; + addons = lib.mkOption { + type = with lib.types; listOf package; default = []; - example = literalExpression "[ pkgs.odoo_enterprise ]"; + example = lib.literalExpression "[ pkgs.odoo_enterprise ]"; description = "Odoo addons."; }; - autoInit = mkEnableOption "automatically initialize the DB"; + autoInit = lib.mkEnableOption "automatically initialize the DB"; - autoInitExtraFlags = mkOption { - type = with types; listOf str; + autoInitExtraFlags = lib.mkOption { + type = with lib.types; listOf str; default = [ ]; - example = literalExpression /*nix*/ '' + example = lib.literalExpression /*nix*/ '' [ "--without-demo=all" ] ''; description = "Extra flags passed to odoo when run for the first time by autoInit"; }; - settings = mkOption { + settings = lib.mkOption { type = format.type; default = {}; description = '' Odoo configuration settings. For more details see ''; - example = literalExpression '' + example = lib.literalExpression '' options = { db_user = "odoo"; db_password="odoo"; @@ -45,18 +42,18 @@ in ''; }; - domain = mkOption { - type = with types; nullOr str; + domain = lib.mkOption { + type = with lib.types; nullOr str; description = "Domain to host Odoo with nginx"; default = null; }; }; }; - config = mkIf (cfg.enable) (let + config = lib.mkIf (cfg.enable) (let cfgFile = format.generate "odoo.cfg" cfg.settings; in { - services.nginx = mkIf (cfg.domain != null) { + services.nginx = lib.mkIf (cfg.domain != null) { upstreams = { odoo.servers = { "127.0.0.1:8069" = {}; @@ -98,7 +95,7 @@ in data_dir = "/var/lib/private/odoo/data"; proxy_mode = cfg.domain != null; } // (lib.optionalAttrs (cfg.addons != []) { - addons_path = concatMapStringsSep "," escapeShellArg cfg.addons; + addons_path = lib.concatMapStringsSep "," lib.escapeShellArg cfg.addons; }); users.users.odoo = { @@ -137,7 +134,7 @@ in echo "pre-start: auto-init" INITIALIZED="${cfg.settings.options.data_dir}/.odoo.initialized" if [ ! -e "$INITIALIZED" ]; then - ${cfg.package}/bin/odoo --init=INIT --database=odoo --db_user=odoo --stop-after-init ${concatStringsSep " " cfg.autoInitExtraFlags} + ${cfg.package}/bin/odoo --init=INIT --database=odoo --db_user=odoo --stop-after-init ${lib.concatStringsSep " " cfg.autoInitExtraFlags} touch "$INITIALIZED" fi '') From eb3a044360edb46dce95ab76ef7525df7abe26bf Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:11 +0200 Subject: [PATCH 082/139] nixos/services.crossfire-server: remove `with lib;` --- .../services/games/crossfire-server.nix | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/nixos/modules/services/games/crossfire-server.nix b/nixos/modules/services/games/crossfire-server.nix index 314b4bad9a29..91a684873c2a 100644 --- a/nixos/modules/services/games/crossfire-server.nix +++ b/nixos/modules/services/games/crossfire-server.nix @@ -1,21 +1,18 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.crossfire-server; serverPort = 13327; in { options.services.crossfire-server = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, the Crossfire game server will be started at boot. ''; }; - package = mkPackageOption pkgs "crossfire-server" { + package = lib.mkPackageOption pkgs "crossfire-server" { extraDescription = '' ::: {.note} This will also be used for map/arch data, if you don't change {option}`dataDir` @@ -23,10 +20,10 @@ in { ''; }; - dataDir = mkOption { - type = types.str; + dataDir = lib.mkOption { + type = lib.types.str; default = "${cfg.package}/share/crossfire"; - defaultText = literalExpression ''"''${config.services.crossfire.package}/share/crossfire"''; + defaultText = lib.literalExpression ''"''${config.services.crossfire.package}/share/crossfire"''; description = '' Where to load readonly data from -- maps, archetypes, treasure tables, and the like. If you plan to edit the data on the live server (rather @@ -36,8 +33,8 @@ in { ''; }; - stateDir = mkOption { - type = types.str; + stateDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/crossfire"; description = '' Where to store runtime data (save files, persistent items, etc). @@ -49,16 +46,16 @@ in { ''; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to open ports in the firewall for the server. ''; }; - configFiles = mkOption { - type = types.attrsOf types.str; + configFiles = lib.mkOption { + type = lib.types.attrsOf lib.types.str; description = '' Text to append to the corresponding configuration files. Note that the files given in the example are *not* the complete set of files available @@ -70,7 +67,7 @@ in { overwrite the example files that come with the server, rather than being appended to them as the other configuration files are. ''; - example = literalExpression '' + example = lib.literalExpression '' { dm_file = ''' admin:secret_password:localhost @@ -101,7 +98,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.crossfire = { description = "Crossfire server daemon user"; home = cfg.stateDir; @@ -120,8 +117,8 @@ in { (name: value: lib.attrsets.nameValuePair "crossfire/${name}" { mode = "0644"; text = - (optionalString (!elem name ["motd" "news" "rules"]) - (fileContents "${cfg.package}/etc/crossfire/${name}")) + (lib.optionalString (!lib.elem name ["motd" "news" "rules"]) + (lib.fileContents "${cfg.package}/etc/crossfire/${name}")) + "\n${value}"; }) ({ ban_file = ""; @@ -129,9 +126,9 @@ in { exp_table = ""; forbid = ""; metaserver2 = ""; - motd = fileContents "${cfg.package}/etc/crossfire/motd"; - news = fileContents "${cfg.package}/etc/crossfire/news"; - rules = fileContents "${cfg.package}/etc/crossfire/rules"; + motd = lib.fileContents "${cfg.package}/etc/crossfire/motd"; + news = lib.fileContents "${cfg.package}/etc/crossfire/news"; + rules = lib.fileContents "${cfg.package}/etc/crossfire/rules"; settings = ""; stat_bonus = ""; } // cfg.configFiles); @@ -141,7 +138,7 @@ in { wantedBy = [ "multi-user.target" ]; after = [ "network.target" ]; - serviceConfig = mkMerge [ + serviceConfig = lib.mkMerge [ { ExecStart = "${cfg.package}/bin/crossfire-server -conf /etc/crossfire -local '${cfg.stateDir}' -data '${cfg.dataDir}'"; Restart = "always"; @@ -149,7 +146,7 @@ in { Group = "crossfire"; WorkingDirectory = cfg.stateDir; } - (mkIf (cfg.stateDir == "/var/lib/crossfire") { + (lib.mkIf (cfg.stateDir == "/var/lib/crossfire") { StateDirectory = "crossfire"; }) ]; @@ -170,7 +167,7 @@ in { ''; }; - networking.firewall = mkIf cfg.openFirewall { + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ serverPort ]; }; }; From 07d3ecf363d5f2dd35d3771dc5718f6497567a6d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:12 +0200 Subject: [PATCH 083/139] nixos/services.deliantra-server: remove `with lib;` --- .../services/games/deliantra-server.nix | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/nixos/modules/services/games/deliantra-server.nix b/nixos/modules/services/games/deliantra-server.nix index 401a453ba932..0bb9cea92c7e 100644 --- a/nixos/modules/services/games/deliantra-server.nix +++ b/nixos/modules/services/games/deliantra-server.nix @@ -1,21 +1,18 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.deliantra-server; serverPort = 13327; in { options.services.deliantra-server = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, the Deliantra game server will be started at boot. ''; }; - package = mkPackageOption pkgs "deliantra-server" { + package = lib.mkPackageOption pkgs "deliantra-server" { extraDescription = '' ::: {.note} This will also be used for map/arch data, if you don't change {option}`dataDir` @@ -23,10 +20,10 @@ in { ''; }; - dataDir = mkOption { - type = types.str; + dataDir = lib.mkOption { + type = lib.types.str; default = "${pkgs.deliantra-data}"; - defaultText = literalExpression ''"''${pkgs.deliantra-data}"''; + defaultText = lib.literalExpression ''"''${pkgs.deliantra-data}"''; description = '' Where to store readonly data (maps, archetypes, sprites, etc). Note that if you plan to use the live map editor (rather than editing @@ -36,8 +33,8 @@ in { ''; }; - stateDir = mkOption { - type = types.str; + stateDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/deliantra"; description = '' Where to store runtime data (save files, persistent items, etc). @@ -49,16 +46,16 @@ in { ''; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to open ports in the firewall for the server. ''; }; - configFiles = mkOption { - type = types.attrsOf types.str; + configFiles = lib.mkOption { + type = lib.types.attrsOf lib.types.str; description = '' Contents of the server configuration files. These will be appended to the example configurations the server comes with and overwrite any @@ -67,7 +64,7 @@ in { The example here is not comprehensive. See the files in /etc/deliantra-server after enabling this module for full documentation. ''; - example = literalExpression '' + example = lib.literalExpression '' { dm_file = ''' admin:secret_password:localhost @@ -92,7 +89,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.deliantra = { description = "Deliantra server daemon user"; home = cfg.stateDir; @@ -113,8 +110,8 @@ in { text = # Deliantra doesn't come with a motd file, but respects it if present # in /etc. - (optionalString (name != "motd") - (fileContents "${cfg.package}/etc/deliantra-server/${name}")) + (lib.optionalString (name != "motd") + (lib.fileContents "${cfg.package}/etc/deliantra-server/${name}")) + "\n${value}"; }) ({ motd = ""; @@ -134,7 +131,7 @@ in { DELIANTRA_CONFDIR="/etc/deliantra-server"; }; - serviceConfig = mkMerge [ + serviceConfig = lib.mkMerge [ { ExecStart = "${cfg.package}/bin/deliantra-server"; Restart = "always"; @@ -142,7 +139,7 @@ in { Group = "deliantra"; WorkingDirectory = cfg.stateDir; } - (mkIf (cfg.stateDir == "/var/lib/deliantra") { + (lib.mkIf (cfg.stateDir == "/var/lib/deliantra") { StateDirectory = "deliantra"; }) ]; @@ -163,7 +160,7 @@ in { ''; }; - networking.firewall = mkIf cfg.openFirewall { + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ serverPort ]; }; }; From d74605503f4fbf4f44661f26d2a02d98624cdb87 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:12 +0200 Subject: [PATCH 084/139] nixos/services.freeciv: remove `with lib;` --- nixos/modules/services/games/freeciv.nix | 61 ++++++++++++------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/nixos/modules/services/games/freeciv.nix b/nixos/modules/services/games/freeciv.nix index e4c05af3caba..fc73824e6920 100644 --- a/nixos/modules/services/games/freeciv.nix +++ b/nixos/modules/services/games/freeciv.nix @@ -1,5 +1,4 @@ { config, lib, pkgs, ... }: -with lib; let cfg = config.services.freeciv; inherit (config.users) groups; @@ -16,31 +15,31 @@ let generate = name: value: let mkParam = k: v: if v == null then [] - else if isBool v then optional v ("--"+k) + else if lib.isBool v then lib.optional v ("--"+k) else [("--"+k) v]; - mkParams = k: v: map (mkParam k) (if isList v then v else [v]); - in escapeShellArgs (concatLists (concatLists (mapAttrsToList mkParams value))); + mkParams = k: v: map (mkParam k) (if lib.isList v then v else [v]); + in lib.escapeShellArgs (lib.concatLists (lib.concatLists (lib.mapAttrsToList mkParams value))); }; in { options = { services.freeciv = { - enable = mkEnableOption ''freeciv''; - settings = mkOption { + enable = lib.mkEnableOption ''freeciv''; + settings = lib.mkOption { description = '' Parameters of freeciv-server. ''; default = {}; - type = types.submodule { + type = lib.types.submodule { freeformType = argsFormat.type; - options.Announce = mkOption { - type = types.enum ["IPv4" "IPv6" "none"]; + options.Announce = lib.mkOption { + type = lib.types.enum ["IPv4" "IPv6" "none"]; default = "none"; description = "Announce game in LAN using given protocol."; }; - options.auth = mkEnableOption "server authentication"; - options.Database = mkOption { - type = types.nullOr types.str; + options.auth = lib.mkEnableOption "server authentication"; + options.Database = lib.mkOption { + type = lib.types.nullOr lib.types.str; apply = pkgs.writeText "auth.conf"; default = '' [fcdb] @@ -49,34 +48,34 @@ in ''; description = "Enable database connection with given configuration."; }; - options.debug = mkOption { - type = types.ints.between 0 3; + options.debug = lib.mkOption { + type = lib.types.ints.between 0 3; default = 0; description = "Set debug log level."; }; - options.exit-on-end = mkEnableOption "exit instead of restarting when a game ends"; - options.Guests = mkEnableOption "guests to login if auth is enabled"; - options.Newusers = mkEnableOption "new users to login if auth is enabled"; - options.port = mkOption { - type = types.port; + options.exit-on-end = lib.mkEnableOption "exit instead of restarting when a game ends"; + options.Guests = lib.mkEnableOption "guests to login if auth is enabled"; + options.Newusers = lib.mkEnableOption "new users to login if auth is enabled"; + options.port = lib.mkOption { + type = lib.types.port; default = 5556; description = "Listen for clients on given port"; }; - options.quitidle = mkOption { - type = types.nullOr types.int; + options.quitidle = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = "Quit if no players for given time in seconds."; }; - options.read = mkOption { - type = types.lines; + options.read = lib.mkOption { + type = lib.types.lines; apply = v: pkgs.writeTextDir "read.serv" v + "/read"; default = '' /fcdb lua sqlite_createdb() ''; description = "Startup script."; }; - options.saves = mkOption { - type = types.nullOr types.str; + options.saves = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = "/var/lib/freeciv/saves/"; description = '' Save games to given directory, @@ -86,10 +85,10 @@ in }; }; }; - openFirewall = mkEnableOption "opening the firewall for the port listening for clients"; + openFirewall = lib.mkEnableOption "opening the firewall for the port listening for clients"; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.groups.freeciv = {}; # Use with: # journalctl -u freeciv.service -f -o cat & @@ -119,8 +118,8 @@ in set -eux savedir=$(date +%Y-%m-%d_%H-%M-%S) '' + "${pkgs.freeciv}/bin/freeciv-server" - + " " + optionalString (cfg.settings.saves != null) - (concatStringsSep " " [ "--saves" "${escapeShellArg cfg.settings.saves}/$savedir" ]) + + " " + lib.optionalString (cfg.settings.saves != null) + (lib.concatStringsSep " " [ "--saves" "${lib.escapeShellArg cfg.settings.saves}/$savedir" ]) + " " + argsFormat.generate "freeciv-server" (cfg.settings // { saves = null; })); DynamicUser = true; # Create rootDir in the host's mount namespace. @@ -152,7 +151,7 @@ in NoNewPrivileges = true; PrivateDevices = true; PrivateMounts = true; - PrivateNetwork = mkDefault false; + PrivateNetwork = lib.mkDefault false; PrivateTmp = true; PrivateUsers = true; ProtectClock = true; @@ -180,7 +179,7 @@ in SystemCallErrorNumber = "EPERM"; }; }; - networking.firewall = mkIf cfg.openFirewall + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.settings.port ]; }; }; meta.maintainers = with lib.maintainers; [ julm ]; From d93ebcfd04bddefebadd8c2248c0cc54fcac38bc Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:13 +0200 Subject: [PATCH 085/139] nixos/services.minecraft-server: remove `with lib;` --- .../services/games/minecraft-server.nix | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/games/minecraft-server.nix b/nixos/modules/services/games/minecraft-server.nix index 00af8dce6603..bc56feffb748 100644 --- a/nixos/modules/services/games/minecraft-server.nix +++ b/nixos/modules/services/games/minecraft-server.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.minecraft-server; @@ -13,13 +10,13 @@ let whitelistFile = pkgs.writeText "whitelist.json" (builtins.toJSON - (mapAttrsToList (n: v: { name = n; uuid = v; }) cfg.whitelist)); + (lib.mapAttrsToList (n: v: { name = n; uuid = v; }) cfg.whitelist)); - cfgToString = v: if builtins.isBool v then boolToString v else toString v; + cfgToString = v: if builtins.isBool v then lib.boolToString v else toString v; serverPropertiesFile = pkgs.writeText "server.properties" ('' # server.properties managed by NixOS configuration - '' + concatStringsSep "\n" (mapAttrsToList + '' + lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: "${n}=${cfgToString v}") cfg.serverProperties)); stopScript = pkgs.writeShellScript "minecraft-server-stop" '' @@ -51,8 +48,8 @@ in { options = { services.minecraft-server = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, start a Minecraft Server. The server @@ -61,8 +58,8 @@ in { ''; }; - declarative = mkOption { - type = types.bool; + declarative = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to use a declarative Minecraft server configuration. @@ -73,8 +70,8 @@ in { ''; }; - eula = mkOption { - type = types.bool; + eula = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether you agree to @@ -84,29 +81,29 @@ in { ''; }; - dataDir = mkOption { - type = types.path; + dataDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/minecraft"; description = '' Directory to store Minecraft database and other state/data files. ''; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to open ports in the firewall for the server. ''; }; - whitelist = mkOption { + whitelist = lib.mkOption { type = let - minecraftUUID = types.strMatching + minecraftUUID = lib.types.strMatching "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" // { description = "Minecraft UUID"; }; - in types.attrsOf minecraftUUID; + in lib.types.attrsOf minecraftUUID; default = {}; description = '' Whitelisted players, only has an effect when @@ -118,7 +115,7 @@ in { You can use to get a Minecraft UUID for a username. ''; - example = literalExpression '' + example = lib.literalExpression '' { username1 = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; username2 = "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"; @@ -126,10 +123,10 @@ in { ''; }; - serverProperties = mkOption { - type = with types; attrsOf (oneOf [ bool int str ]); + serverProperties = lib.mkOption { + type = with lib.types; attrsOf (oneOf [ bool int str ]); default = {}; - example = literalExpression '' + example = lib.literalExpression '' { server-port = 43000; difficulty = 3; @@ -150,12 +147,12 @@ in { ''; }; - package = mkPackageOption pkgs "minecraft-server" { + package = lib.mkPackageOption pkgs "minecraft-server" { example = "minecraft-server_1_12_2"; }; - jvmOpts = mkOption { - type = types.separatedString " "; + jvmOpts = lib.mkOption { + type = lib.types.separatedString " "; default = "-Xmx2048M -Xms2048M"; # Example options from https://minecraft.gamepedia.com/Tutorials/Server_startup_script example = "-Xms4092M -Xmx4092M -XX:+UseG1GC -XX:+CMSIncrementalPacing " @@ -166,7 +163,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.minecraft = { description = "Minecraft server service user"; @@ -259,11 +256,11 @@ in { ''); }; - networking.firewall = mkIf cfg.openFirewall (if cfg.declarative then { + networking.firewall = lib.mkIf cfg.openFirewall (if cfg.declarative then { allowedUDPPorts = [ serverPort ]; allowedTCPPorts = [ serverPort ] - ++ optional (queryPort != null) queryPort - ++ optional (rconPort != null) rconPort; + ++ lib.optional (queryPort != null) queryPort + ++ lib.optional (rconPort != null) rconPort; } else { allowedUDPPorts = [ defaultServerPort ]; allowedTCPPorts = [ defaultServerPort ]; From 3e001960ebd39c873b0950fb7f58670928af6995 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:13 +0200 Subject: [PATCH 086/139] nixos/services.minetest-server: remove `with lib;` --- .../services/games/minetest-server.nix | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/nixos/modules/services/games/minetest-server.nix b/nixos/modules/services/games/minetest-server.nix index 7fa687d2c7ed..98613e4391ef 100644 --- a/nixos/modules/services/games/minetest-server.nix +++ b/nixos/modules/services/games/minetest-server.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let CONTAINS_NEWLINE_RE = ".*\n.*"; # The following values are reserved as complete option values: @@ -53,14 +50,14 @@ in { options = { services.minetest-server = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "If enabled, starts a Minetest Server."; }; - gameId = mkOption { - type = types.nullOr types.str; + gameId = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Id of the game to use. To list available games run @@ -70,8 +67,8 @@ in ''; }; - world = mkOption { - type = types.nullOr types.path; + world = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Name of the world to use. To list available worlds run @@ -81,8 +78,8 @@ in ''; }; - configPath = mkOption { - type = types.nullOr types.path; + configPath = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Path to the config to use. @@ -92,8 +89,8 @@ in ''; }; - config = mkOption { - type = types.attrsOf types.anything; + config = lib.mkOption { + type = lib.types.attrsOf lib.types.anything; default = {}; description = '' Settings to add to the minetest config file. @@ -102,8 +99,8 @@ in ''; }; - logPath = mkOption { - type = types.nullOr types.path; + logPath = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' Path to logfile for logging. @@ -113,8 +110,8 @@ in ''; }; - port = mkOption { - type = types.nullOr types.int; + port = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' Port number to bind to. @@ -123,8 +120,8 @@ in ''; }; - extraArgs = mkOption { - type = types.listOf types.str; + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = '' Additional command line flags to pass to the minetest executable. @@ -133,7 +130,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.minetest = { description = "Minetest Server Service user"; home = "/var/lib/minetest"; From e79224ab545627c87eeb4cdb2f0eab29a960246e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:14 +0200 Subject: [PATCH 087/139] nixos/services.terraria: remove `with lib;` --- nixos/modules/services/games/terraria.nix | 61 +++++++++++------------ 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/nixos/modules/services/games/terraria.nix b/nixos/modules/services/games/terraria.nix index 4c32cc92a1b9..144186dc7701 100644 --- a/nixos/modules/services/games/terraria.nix +++ b/nixos/modules/services/games/terraria.nix @@ -1,13 +1,10 @@ { config, lib, options, pkgs, ... }: - -with lib; - let cfg = config.services.terraria; opt = options.services.terraria; worldSizeMap = { small = 1; medium = 2; large = 3; }; - valFlag = name: val: optionalString (val != null) "-${name} \"${escape ["\\" "\""] (toString val)}\""; - boolFlag = name: val: optionalString val "-${name}"; + valFlag = name: val: lib.optionalString (val != null) "-${name} \"${lib.escape ["\\" "\""] (toString val)}\""; + boolFlag = name: val: lib.optionalString val "-${name}"; flags = [ (valFlag "port" cfg.port) (valFlag "maxPlayers" cfg.maxPlayers) @@ -46,8 +43,8 @@ in { options = { services.terraria = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, starts a Terraria server. The server can be connected to via `tmux -S ''${config.${opt.dataDir}}/terraria.sock attach` @@ -55,40 +52,40 @@ in ''; }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 7777; description = '' Specifies the port to listen on. ''; }; - maxPlayers = mkOption { - type = types.ints.u8; + maxPlayers = lib.mkOption { + type = lib.types.ints.u8; default = 255; description = '' Sets the max number of players (between 1 and 255). ''; }; - password = mkOption { - type = types.nullOr types.str; + password = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Sets the server password. Leave `null` for no password. ''; }; - messageOfTheDay = mkOption { - type = types.nullOr types.str; + messageOfTheDay = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Set the server message of the day text. ''; }; - worldPath = mkOption { - type = types.nullOr types.path; + worldPath = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' The path to the world file (`.wld`) which should be loaded. @@ -97,8 +94,8 @@ in ''; }; - autoCreatedWorldSize = mkOption { - type = types.enum [ "small" "medium" "large" ]; + autoCreatedWorldSize = lib.mkOption { + type = lib.types.enum [ "small" "medium" "large" ]; default = "medium"; description = '' Specifies the size of the auto-created world if `worldPath` does not @@ -106,34 +103,34 @@ in ''; }; - banListPath = mkOption { - type = types.nullOr types.path; + banListPath = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' The path to the ban list. ''; }; - secure = mkOption { - type = types.bool; + secure = lib.mkOption { + type = lib.types.bool; default = false; description = "Adds additional cheat protection to the server."; }; - noUPnP = mkOption { - type = types.bool; + noUPnP = lib.mkOption { + type = lib.types.bool; default = false; description = "Disables automatic Universal Plug and Play."; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to open ports in the firewall"; }; - dataDir = mkOption { - type = types.str; + dataDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/terraria"; example = "/srv/terraria"; description = "Path to variable state data directory for terraria."; @@ -141,7 +138,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.terraria = { description = "Terraria server service user"; group = "terraria"; @@ -165,12 +162,12 @@ in Type = "forking"; GuessMainPID = true; UMask = 007; - ExecStart = "${tmuxCmd} new -d ${pkgs.terraria-server}/bin/TerrariaServer ${concatStringsSep " " flags}"; + ExecStart = "${tmuxCmd} new -d ${pkgs.terraria-server}/bin/TerrariaServer ${lib.concatStringsSep " " flags}"; ExecStop = "${stopScript} $MAINPID"; }; }; - networking.firewall = mkIf cfg.openFirewall { + networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; allowedUDPPorts = [ cfg.port ]; }; From f8305b629b8a9e602dd7a63a31d669a8f47a6ec0 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:14 +0200 Subject: [PATCH 088/139] nixos/services.acpid: remove `with lib;` --- nixos/modules/services/hardware/acpid.nix | 43 +++++++++++------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/nixos/modules/services/hardware/acpid.nix b/nixos/modules/services/hardware/acpid.nix index 581b6cb40136..357f692801b4 100644 --- a/nixos/modules/services/hardware/acpid.nix +++ b/nixos/modules/services/hardware/acpid.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.acpid; @@ -34,7 +31,7 @@ let echo "event=${handler.event}" > $fn echo "action=${pkgs.writeShellScriptBin "${name}.sh" handler.action }/bin/${name}.sh '%e'" >> $fn ''; - in concatStringsSep "\n" (mapAttrsToList f (canonicalHandlers // cfg.handlers)) + in lib.concatStringsSep "\n" (lib.mapAttrsToList f (canonicalHandlers // cfg.handlers)) } ''; @@ -48,25 +45,25 @@ in services.acpid = { - enable = mkEnableOption "the ACPI daemon"; + enable = lib.mkEnableOption "the ACPI daemon"; - logEvents = mkOption { - type = types.bool; + logEvents = lib.mkOption { + type = lib.types.bool; default = false; description = "Log all event activity."; }; - handlers = mkOption { - type = types.attrsOf (types.submodule { + handlers = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule { options = { - event = mkOption { - type = types.str; - example = literalExpression ''"button/power.*" "button/lid.*" "ac_adapter.*" "button/mute.*" "button/volumedown.*" "cd/play.*" "cd/next.*"''; + event = lib.mkOption { + type = lib.types.str; + example = lib.literalExpression ''"button/power.*" "button/lid.*" "ac_adapter.*" "button/mute.*" "button/volumedown.*" "cd/play.*" "cd/next.*"''; description = "Event type."; }; - action = mkOption { - type = types.lines; + action = lib.mkOption { + type = lib.types.lines; description = "Shell commands to execute when the event is triggered."; }; }; @@ -101,20 +98,20 @@ in }; }; - powerEventCommands = mkOption { - type = types.lines; + powerEventCommands = lib.mkOption { + type = lib.types.lines; default = ""; description = "Shell commands to execute on a button/power.* event."; }; - lidEventCommands = mkOption { - type = types.lines; + lidEventCommands = lib.mkOption { + type = lib.types.lines; default = ""; description = "Shell commands to execute on a button/lid.* event."; }; - acEventCommands = mkOption { - type = types.lines; + acEventCommands = lib.mkOption { + type = lib.types.lines; default = ""; description = "Shell commands to execute on an ac_adapter.* event."; }; @@ -126,7 +123,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.acpid = { description = "ACPI Daemon"; @@ -135,12 +132,12 @@ in wantedBy = [ "multi-user.target" ]; serviceConfig = { - ExecStart = escapeShellArgs + ExecStart = lib.escapeShellArgs ([ "${pkgs.acpid}/bin/acpid" "--foreground" "--netlink" "--confdir" "${acpiConfDir}" - ] ++ optional cfg.logEvents "--logevents" + ] ++ lib.optional cfg.logEvents "--logevents" ); }; unitConfig = { From efcfb7ec52b250a2c6451d4d8e22d095cc783a4e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:14 +0200 Subject: [PATCH 089/139] nixos/services.auto-cpufreq: remove `with lib;` --- nixos/modules/services/hardware/auto-cpufreq.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/hardware/auto-cpufreq.nix b/nixos/modules/services/hardware/auto-cpufreq.nix index f61fa38be175..ed24c656c543 100644 --- a/nixos/modules/services/hardware/auto-cpufreq.nix +++ b/nixos/modules/services/hardware/auto-cpufreq.nix @@ -1,5 +1,4 @@ { config, lib, pkgs, ... }: -with lib; let cfg = config.services.auto-cpufreq; cfgFilename = "auto-cpufreq.conf"; @@ -9,9 +8,9 @@ let in { options = { services.auto-cpufreq = { - enable = mkEnableOption "auto-cpufreq daemon"; + enable = lib.mkEnableOption "auto-cpufreq daemon"; - settings = mkOption { + settings = lib.mkOption { description = '' Configuration for `auto-cpufreq`. @@ -19,12 +18,12 @@ in { ''; default = {}; - type = types.submodule { freeformType = format.type; }; + type = lib.types.submodule { freeformType = format.type; }; }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.auto-cpufreq ]; systemd = { From 555402cee58ec55418fa76de284e8072c7ecba31 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:15 +0200 Subject: [PATCH 090/139] nixos/services.bolt: remove `with lib;` --- nixos/modules/services/hardware/bolt.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/hardware/bolt.nix b/nixos/modules/services/hardware/bolt.nix index 729273f94f12..f005d24e0883 100644 --- a/nixos/modules/services/hardware/bolt.nix +++ b/nixos/modules/services/hardware/bolt.nix @@ -1,15 +1,12 @@ { config, lib, pkgs, ...}: - -with lib; - let cfg = config.services.hardware.bolt; in { options = { services.hardware.bolt = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable Bolt, a userspace daemon to enable @@ -19,11 +16,11 @@ in ''; }; - package = mkPackageOption pkgs "bolt" { }; + package = lib.mkPackageOption pkgs "bolt" { }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; services.udev.packages = [ cfg.package ]; systemd.packages = [ cfg.package ]; From 3822e798f8bdd01f37dff74c852a34a146b4ac00 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:15 +0200 Subject: [PATCH 091/139] nixos/services.brltty: remove `with lib;` --- nixos/modules/services/hardware/brltty.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/hardware/brltty.nix b/nixos/modules/services/hardware/brltty.nix index bdec5d79be96..c4ded927345d 100644 --- a/nixos/modules/services/hardware/brltty.nix +++ b/nixos/modules/services/hardware/brltty.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.brltty; @@ -22,15 +19,15 @@ in { options = { - services.brltty.enable = mkOption { - type = types.bool; + services.brltty.enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to enable the BRLTTY daemon."; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.brltty = { description = "BRLTTY daemon user"; group = "brltty"; From 29536d4a4df5da981194087a8b2eb9eb23e9afbe Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:16 +0200 Subject: [PATCH 092/139] nixos/services.fancontrol: remove `with lib;` --- nixos/modules/services/hardware/fancontrol.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index f9fc8593f852..06c217b4d3c9 100644 --- a/nixos/modules/services/hardware/fancontrol.nix +++ b/nixos/modules/services/hardware/fancontrol.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.fancontrol; configFile = pkgs.writeText "fancontrol.conf" cfg.config; @@ -9,10 +6,10 @@ let in { options.hardware.fancontrol = { - enable = mkEnableOption "software fan control (requires fancontrol.config)"; + enable = lib.mkEnableOption "software fan control (requires fancontrol.config)"; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; description = "Required fancontrol configuration file content. See {manpage}`pwmconfig(8)` from the lm_sensors package."; example = '' # Configuration file generated by pwmconfig @@ -29,7 +26,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.fancontrol = { documentation = [ "man:fancontrol(8)" ]; @@ -51,5 +48,5 @@ in }; - meta.maintainers = [ maintainers.evils ]; + meta.maintainers = [ lib.maintainers.evils ]; } From 6c707fe30f92e9df679de813ca3548d6ddcb05b3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:17 +0200 Subject: [PATCH 093/139] nixos/services.freefall: remove `with lib;` --- nixos/modules/services/hardware/freefall.nix | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/hardware/freefall.nix b/nixos/modules/services/hardware/freefall.nix index 4ac7c54d4d8a..fe017bb17f7e 100644 --- a/nixos/modules/services/hardware/freefall.nix +++ b/nixos/modules/services/hardware/freefall.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, utils, ... }: - -with lib; - let cfg = config.services.freefall; @@ -10,18 +7,18 @@ in { options.services.freefall = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to protect HP/Dell laptop hard drives (not SSDs) in free fall. ''; }; - package = mkPackageOption pkgs "freefall" { }; + package = lib.mkPackageOption pkgs "freefall" { }; - devices = mkOption { - type = types.listOf types.str; + devices = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "/dev/sda" ]; description = '' Device paths to all internal spinning hard drives. @@ -35,7 +32,7 @@ in { mkService = dev: assert dev != ""; let dev' = utils.escapeSystemdPath dev; in - nameValuePair "freefall-${dev'}" { + lib.nameValuePair "freefall-${dev'}" { description = "Free-fall protection for ${dev}"; after = [ "${dev'}.device" ]; wantedBy = [ "${dev'}.device" ]; @@ -46,7 +43,7 @@ in { }; }; - in mkIf cfg.enable { + in lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; From 8ebc06069db9eb561e01a4107e32b47075b2be48 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:17 +0200 Subject: [PATCH 094/139] nixos/services.fwupd: remove `with lib;` --- nixos/modules/services/hardware/fwupd.nix | 70 +++++++++++------------ 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/nixos/modules/services/hardware/fwupd.nix b/nixos/modules/services/hardware/fwupd.nix index bdbd0ac2440b..09a55ad28052 100644 --- a/nixos/modules/services/hardware/fwupd.nix +++ b/nixos/modules/services/hardware/fwupd.nix @@ -1,15 +1,11 @@ # fwupd daemon. - { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.fwupd; format = pkgs.formats.ini { - listToValue = l: lib.concatStringsSep ";" (map (s: generators.mkValueStringDefault {} s) l); - mkKeyValue = generators.mkKeyValueDefault {} "="; + listToValue = l: lib.concatStringsSep ";" (map (s: lib.generators.mkValueStringDefault {} s) l); + mkKeyValue = lib.generators.mkKeyValueDefault {} "="; }; customEtc = { @@ -26,13 +22,13 @@ let originalEtc = let - mkEtcFile = n: nameValuePair n { source = "${cfg.package}/etc/${n}"; }; - in listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc); + mkEtcFile = n: lib.nameValuePair n { source = "${cfg.package}/etc/${n}"; }; + in lib.listToAttrs (map mkEtcFile cfg.package.filesInstalledToEtc); extraTrustedKeys = let mkName = p: "pki/fwupd/${baseNameOf (toString p)}"; - mkEtcFile = p: nameValuePair (mkName p) { source = p; }; - in listToAttrs (map mkEtcFile cfg.extraTrustedKeys); + mkEtcFile = p: lib.nameValuePair (mkName p) { source = p; }; + in lib.listToAttrs (map mkEtcFile cfg.extraTrustedKeys); enableRemote = base: remote: { "fwupd/remotes.d/${remote}.conf" = { @@ -42,7 +38,7 @@ let ''; }; }; - remotes = (foldl' + remotes = (lib.foldl' (configFiles: remote: configFiles // (enableRemote cfg.package remote)) {} cfg.extraRemotes @@ -61,8 +57,8 @@ in { ###### interface options = { services.fwupd = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable fwupd, a DBus service that allows @@ -70,17 +66,17 @@ in { ''; }; - extraTrustedKeys = mkOption { - type = types.listOf types.path; + extraTrustedKeys = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; - example = literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]"; + example = lib.literalExpression "[ /etc/nixos/fwupd/myfirmware.pem ]"; description = '' Installing a public key allows firmware signed with a matching private key to be recognized as trusted, which may require less authentication to install than for untrusted files. By default trusted firmware can be upgraded (but not downgraded) without the user or administrator password. Only very few keys are installed by default. ''; }; - extraRemotes = mkOption { - type = with types; listOf str; + extraRemotes = lib.mkOption { + type = with lib.types; listOf str; default = []; example = [ "lvfs-testing" ]; description = '' @@ -88,14 +84,14 @@ in { ''; }; - package = mkPackageOption pkgs "fwupd" { }; + package = lib.mkPackageOption pkgs "fwupd" { }; - daemonSettings = mkOption { - type = types.submodule { + daemonSettings = lib.mkOption { + type = lib.types.submodule { freeformType = format.type.nestedTypes.elemType; options = { - DisabledDevices = mkOption { - type = types.listOf types.str; + DisabledDevices = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "2082b5e0-7a64-478a-b1b2-e3404fab6dad" ]; description = '' @@ -103,8 +99,8 @@ in { ''; }; - DisabledPlugins = mkOption { - type = types.listOf types.str; + DisabledPlugins = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "udev" ]; description = '' @@ -112,8 +108,8 @@ in { ''; }; - EspLocation = mkOption { - type = types.path; + EspLocation = lib.mkOption { + type = lib.types.path; default = config.boot.loader.efi.efiSysMountPoint; defaultText = lib.literalExpression "config.boot.loader.efi.efiSysMountPoint"; description = '' @@ -122,9 +118,9 @@ in { ''; }; - TestDevices = mkOption { + TestDevices = lib.mkOption { internal = true; - type = types.bool; + type = lib.types.bool; default = false; description = '' Create virtual test devices and remote for validating daemon flows. @@ -139,8 +135,8 @@ in { ''; }; - uefiCapsuleSettings = mkOption { - type = types.submodule { + uefiCapsuleSettings = lib.mkOption { + type = lib.types.submodule { freeformType = format.type.nestedTypes.elemType; }; default = {}; @@ -152,15 +148,15 @@ in { }; imports = [ - (mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ]) - (mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ]) - (mkRenamedOptionModule [ "services" "fwupd" "disabledDevices" ] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ]) - (mkRenamedOptionModule [ "services" "fwupd" "disabledPlugins" ] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ]) - (mkRemovedOptionModule [ "services" "fwupd" "enableTestRemote" ] "This option was removed after being removed upstream. It only provided a method for testing fwupd functionality, and should not have been exposed for use outside of nix tests.") + (lib.mkRenamedOptionModule [ "services" "fwupd" "blacklistDevices"] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ]) + (lib.mkRenamedOptionModule [ "services" "fwupd" "blacklistPlugins"] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ]) + (lib.mkRenamedOptionModule [ "services" "fwupd" "disabledDevices" ] [ "services" "fwupd" "daemonSettings" "DisabledDevices" ]) + (lib.mkRenamedOptionModule [ "services" "fwupd" "disabledPlugins" ] [ "services" "fwupd" "daemonSettings" "DisabledPlugins" ]) + (lib.mkRemovedOptionModule [ "services" "fwupd" "enableTestRemote" ] "This option was removed after being removed upstream. It only provided a method for testing fwupd functionality, and should not have been exposed for use outside of nix tests.") ]; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # Disable test related plug-ins implicitly so that users do not have to care about them. services.fwupd.daemonSettings = { EspLocation = config.boot.loader.efi.efiSysMountPoint; From d3a4a69eda1d98f22c46eea4fd8f733edd09dc80 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:17 +0200 Subject: [PATCH 095/139] nixos/services.illum: remove `with lib;` --- nixos/modules/services/hardware/illum.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/hardware/illum.nix b/nixos/modules/services/hardware/illum.nix index 7f7a85000234..61ab24a5de7c 100644 --- a/nixos/modules/services/hardware/illum.nix +++ b/nixos/modules/services/hardware/illum.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.illum; in { @@ -10,9 +7,9 @@ in { services.illum = { - enable = mkOption { + enable = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Enable illum, a daemon for controlling screen brightness with brightness buttons. ''; @@ -22,7 +19,7 @@ in { }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.illum = { description = "Backlight Adjustment Service"; From 650db2b016b2ba50f9204c573d9774c25b9c30ae Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:18 +0200 Subject: [PATCH 096/139] nixos/services.interception-tools: remove `with lib;` --- .../services/hardware/interception-tools.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/hardware/interception-tools.nix b/nixos/modules/services/hardware/interception-tools.nix index e69c05841ee0..d60e7ca59547 100644 --- a/nixos/modules/services/hardware/interception-tools.nix +++ b/nixos/modules/services/hardware/interception-tools.nix @@ -1,29 +1,26 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.interception-tools; in { options.services.interception-tools = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to enable the interception tools service."; }; - plugins = mkOption { - type = types.listOf types.package; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.package; default = [ pkgs.interception-tools-plugins.caps2esc ]; - defaultText = literalExpression "[ pkgs.interception-tools-plugins.caps2esc ]"; + defaultText = lib.literalExpression "[ pkgs.interception-tools-plugins.caps2esc ]"; description = '' A list of interception tools plugins that will be made available to use inside the udevmon configuration. ''; }; - udevmonConfig = mkOption { - type = types.either types.str types.path; + udevmonConfig = lib.mkOption { + type = lib.types.either lib.types.str lib.types.path; default = '' - JOB: "intercept -g $DEVNODE | caps2esc | uinput -d $DEVNODE" DEVICE: @@ -43,7 +40,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.interception-tools = { description = "Interception tools"; path = [ pkgs.bash pkgs.interception-tools ] ++ cfg.plugins; From d71be6eda5e2a95d9ce93bbba8ee5f8c3c2b835e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:18 +0200 Subject: [PATCH 097/139] nixos/services.irqbalance: remove `with lib;` --- nixos/modules/services/hardware/irqbalance.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/hardware/irqbalance.nix b/nixos/modules/services/hardware/irqbalance.nix index c79e0eb83ece..42878725cca3 100644 --- a/nixos/modules/services/hardware/irqbalance.nix +++ b/nixos/modules/services/hardware/irqbalance.nix @@ -1,17 +1,14 @@ # { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.irqbalance; in { - options.services.irqbalance.enable = mkEnableOption "irqbalance daemon"; + options.services.irqbalance.enable = lib.mkEnableOption "irqbalance daemon"; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.irqbalance ]; From f5c96d88c1d87fa801c831abde2113a1217af993 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:19 +0200 Subject: [PATCH 098/139] nixos/services.joycond: remove `with lib;` --- nixos/modules/services/hardware/joycond.nix | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/hardware/joycond.nix b/nixos/modules/services/hardware/joycond.nix index 106c19243c49..b6d2b8328af7 100644 --- a/nixos/modules/services/hardware/joycond.nix +++ b/nixos/modules/services/hardware/joycond.nix @@ -1,19 +1,15 @@ { config, lib, pkgs, ... }: - let cfg = config.services.joycond; in - -with lib; - { options.services.joycond = { - enable = mkEnableOption "support for Nintendo Pro Controllers and Joycons"; + enable = lib.mkEnableOption "support for Nintendo Pro Controllers and Joycons"; - package = mkPackageOption pkgs "joycond" { }; + package = lib.mkPackageOption pkgs "joycond" { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; services.udev.packages = [ cfg.package ]; From 3b7622d31b50e332a54955d2ef10621ce39ec0e9 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:19 +0200 Subject: [PATCH 099/139] nixos/services.kanata: remove `with lib;` --- nixos/modules/services/hardware/kanata.nix | 69 +++++++++++----------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/hardware/kanata.nix b/nixos/modules/services/hardware/kanata.nix index 60fb33881f25..67bcac6fe443 100644 --- a/nixos/modules/services/hardware/kanata.nix +++ b/nixos/modules/services/hardware/kanata.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, utils, ... }: - -with lib; - let cfg = config.services.kanata; @@ -9,8 +6,8 @@ let keyboard = { name, config, ... }: { options = { - devices = mkOption { - type = types.listOf types.str; + devices = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "/dev/input/by-id/usb-0000_0000-event-kbd" ]; description = '' @@ -20,8 +17,8 @@ let input devices are keyboards and intercept them all. ''; }; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; example = '' (defsrc caps) @@ -36,8 +33,8 @@ let ${upstreamDoc} ''; }; - extraDefCfg = mkOption { - type = types.lines; + extraDefCfg = lib.mkOption { + type = lib.types.lines; default = ""; example = "danger-enable-cmd yes"; description = '' @@ -48,8 +45,8 @@ let ${upstreamDoc} ''; }; - configFile = mkOption { - type = types.path; + configFile = lib.mkOption { + type = lib.types.path; default = mkConfig name config; defaultText = "A config file generated by values from other kanata module options."; @@ -63,13 +60,13 @@ let overrides all other kanata module options. ${upstreamDoc} ''; }; - extraArgs = mkOption { - type = types.listOf types.str; + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; description = "Extra command line arguments passed to kanata."; }; - port = mkOption { - type = types.nullOr types.port; + port = lib.mkOption { + type = lib.types.nullOr lib.types.port; default = null; example = 6666; description = '' @@ -83,12 +80,12 @@ let mkDevices = devices: let - devicesString = pipe devices [ + devicesString = lib.pipe devices [ (map (device: "\"" + device + "\"")) - (concatStringsSep " ") + (lib.concatStringsSep " ") ]; in - optionalString ((length devices) > 0) "linux-dev (${devicesString})"; + lib.optionalString ((lib.length devices) > 0) "linux-dev (${devicesString})"; mkConfig = name: keyboard: pkgs.writeTextFile { name = "${mkName name}-config.kdb"; @@ -105,20 +102,20 @@ let # at build time. I think this is a good balance between module # complexity and functionality. checkPhase = '' - ${getExe cfg.package} --cfg "$target" --check --debug + ${lib.getExe cfg.package} --cfg "$target" --check --debug ''; }; - mkService = name: keyboard: nameValuePair (mkName name) { + mkService = name: keyboard: lib.nameValuePair (mkName name) { wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "notify"; ExecStart = '' - ${getExe cfg.package} \ + ${lib.getExe cfg.package} \ --cfg ${keyboard.configFile} \ --symlink-path ''${RUNTIME_DIRECTORY}/${name} \ - ${optionalString (keyboard.port != null) "--port ${toString keyboard.port}"} \ - ${utils.escapeSystemdExecArgs keyboard.extraArgs} + ${lib.optionalString (keyboard.port != null) "--port ${toString keyboard.port}"} \ + ${utils.lib.escapeSystemdExecArgs keyboard.extraArgs} ''; DynamicUser = true; @@ -135,7 +132,7 @@ let ]; CapabilityBoundingSet = [ "" ]; DevicePolicy = "closed"; - IPAddressAllow = optional (keyboard.port != null) "localhost"; + IPAddressAllow = lib.optional (keyboard.port != null) "localhost"; IPAddressDeny = [ "any" ]; LockPersonality = true; MemoryDenyWriteExecute = true; @@ -150,7 +147,7 @@ let ProtectKernelModules = true; ProtectKernelTunables = true; ProtectProc = "invisible"; - RestrictAddressFamilies = [ "AF_UNIX" ] ++ optional (keyboard.port != null) "AF_INET"; + RestrictAddressFamilies = [ "AF_UNIX" ] ++ lib.optional (keyboard.port != null) "AF_INET"; RestrictNamespaces = true; RestrictRealtime = true; SystemCallArchitectures = [ "native" ]; @@ -165,8 +162,8 @@ let in { options.services.kanata = { - enable = mkEnableOption "kanata, a tool to improve keyboard comfort and usability with advanced customization"; - package = mkPackageOption pkgs "kanata" { + enable = lib.mkEnableOption "kanata, a tool to improve keyboard comfort and usability with advanced customization"; + package = lib.mkPackageOption pkgs "kanata" { example = [ "kanata-with-cmd" ]; extraDescription = '' ::: {.note} @@ -175,26 +172,26 @@ in ::: ''; }; - keyboards = mkOption { - type = types.attrsOf (types.submodule keyboard); + keyboards = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule keyboard); default = { }; description = "Keyboard configurations."; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { warnings = let - keyboardsWithEmptyDevices = filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards; - existEmptyDevices = length (attrNames keyboardsWithEmptyDevices) > 0; - moreThanOneKeyboard = length (attrNames cfg.keyboards) > 1; + keyboardsWithEmptyDevices = lib.filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards; + existEmptyDevices = lib.length (lib.attrNames keyboardsWithEmptyDevices) > 0; + moreThanOneKeyboard = lib.length (lib.attrNames cfg.keyboards) > 1; in - optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${head (attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition."; + lib.optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${lib.head (lib.attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition."; hardware.uinput.enable = true; - systemd.services = mapAttrs' mkService cfg.keyboards; + systemd.services = lib.mapAttrs' mkService cfg.keyboards; }; - meta.maintainers = with maintainers; [ linj ]; + meta.maintainers = with lib.maintainers; [ linj ]; } From 827d9dfac960289d59af147c6aca85009cb1e65f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:20 +0200 Subject: [PATCH 100/139] nixos/services.keyd: remove `with lib;` --- nixos/modules/services/hardware/keyd.nix | 35 ++++++++++++------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/nixos/modules/services/hardware/keyd.nix b/nixos/modules/services/hardware/keyd.nix index 2aee7817c6f3..92b62fe2e977 100644 --- a/nixos/modules/services/hardware/keyd.nix +++ b/nixos/modules/services/hardware/keyd.nix @@ -1,12 +1,11 @@ { config, lib, pkgs, ... }: -with lib; let cfg = config.services.keyd; keyboardOptions = { ... }: { options = { - ids = mkOption { - type = types.listOf types.str; + ids = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ "*" ]; example = [ "*" "-0123:0456" ]; description = '' @@ -14,7 +13,7 @@ let ''; }; - settings = mkOption { + settings = lib.mkOption { type = (pkgs.formats.ini { }).type; default = { }; example = { @@ -37,8 +36,8 @@ let ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = '' [control+shift] @@ -55,19 +54,19 @@ let in { imports = [ - (mkRemovedOptionModule [ "services" "keyd" "ids" ] + (lib.mkRemovedOptionModule [ "services" "keyd" "ids" ] ''Use keyboards..ids instead. If you don't need a multi-file configuration, just add keyboards.default before the ids. See https://github.com/NixOS/nixpkgs/pull/243271.'') - (mkRemovedOptionModule [ "services" "keyd" "settings" ] + (lib.mkRemovedOptionModule [ "services" "keyd" "settings" ] ''Use keyboards..settings instead. If you don't need a multi-file configuration, just add keyboards.default before the settings. See https://github.com/NixOS/nixpkgs/pull/243271.'') ]; options.services.keyd = { - enable = mkEnableOption "keyd, a key remapping daemon"; + enable = lib.mkEnableOption "keyd, a key remapping daemon"; - keyboards = mkOption { - type = types.attrsOf (types.submodule keyboardOptions); + keyboards = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule keyboardOptions); default = { }; - example = literalExpression '' + example = lib.literalExpression '' { default = { ids = [ "*" ]; @@ -93,16 +92,16 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # Creates separate files in the `/etc/keyd/` directory for each key in the dictionary - environment.etc = mapAttrs' + environment.etc = lib.mapAttrs' (name: options: - nameValuePair "keyd/${name}.conf" { + lib.nameValuePair "keyd/${name}.conf" { text = '' [ids] - ${concatStringsSep "\n" options.ids} + ${lib.concatStringsSep "\n" options.ids} - ${generators.toINI {} options.settings} + ${lib.generators.toINI {} options.settings} ${options.extraConfig} ''; }) @@ -116,7 +115,7 @@ in wantedBy = [ "multi-user.target" ]; - restartTriggers = mapAttrsToList + restartTriggers = lib.mapAttrsToList (name: options: config.environment.etc."keyd/${name}.conf".source ) From 78b24bea0f41ccacc66aea0230b803172e02c70a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:20 +0200 Subject: [PATCH 101/139] nixos/services.lirc: remove `with lib;` --- nixos/modules/services/hardware/lirc.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/hardware/lirc.nix b/nixos/modules/services/hardware/lirc.nix index 8103dbeb2d48..9942b9a97513 100644 --- a/nixos/modules/services/hardware/lirc.nix +++ b/nixos/modules/services/hardware/lirc.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.lirc; in { @@ -11,10 +8,10 @@ in { options = { services.lirc = { - enable = mkEnableOption "the LIRC daemon, to receive and send infrared signals"; + enable = lib.mkEnableOption "the LIRC daemon, to receive and send infrared signals"; - options = mkOption { - type = types.lines; + options = lib.mkOption { + type = lib.types.lines; example = '' [lircd] nodaemon = False @@ -22,13 +19,13 @@ in { description = "LIRC default options described in man:lircd(8) ({file}`lirc_options.conf`)"; }; - configs = mkOption { - type = types.listOf types.lines; + configs = lib.mkOption { + type = lib.types.listOf lib.types.lines; description = "Configurations for lircd to load, see man:lircd.conf(5) for details ({file}`lircd.conf`)"; }; - extraArguments = mkOption { - type = types.listOf types.str; + extraArguments = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "Extra arguments to lircd."; }; @@ -37,7 +34,7 @@ in { ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # Note: LIRC executables raises a warning, if lirc_options.conf do not exists environment.etc."lirc/lirc_options.conf".text = cfg.options; @@ -82,7 +79,7 @@ in { ExecStart = '' ${pkgs.lirc}/bin/lircd --nodaemon \ - ${escapeShellArgs cfg.extraArguments} \ + ${lib.escapeShellArgs cfg.extraArguments} \ ${configFile} ''; User = "lirc"; From b2d74343f12cdc0194e71cb05f14fc84ec3d3a70 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:21 +0200 Subject: [PATCH 102/139] nixos/services.openrgb: remove `with lib;` --- nixos/modules/services/hardware/openrgb.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/hardware/openrgb.nix b/nixos/modules/services/hardware/openrgb.nix index 4dc521aa9780..0e06f9720ac1 100644 --- a/nixos/modules/services/hardware/openrgb.nix +++ b/nixos/modules/services/hardware/openrgb.nix @@ -1,21 +1,18 @@ { pkgs, lib, config, ... }: - -with lib; - let cfg = config.services.hardware.openrgb; in { options.services.hardware.openrgb = { - enable = mkEnableOption "OpenRGB server, for RGB lighting control"; + enable = lib.mkEnableOption "OpenRGB server, for RGB lighting control"; - package = mkPackageOption pkgs "openrgb" { }; + package = lib.mkPackageOption pkgs "openrgb" { }; - motherboard = mkOption { - type = types.nullOr (types.enum [ "amd" "intel" ]); + motherboard = lib.mkOption { + type = lib.types.nullOr (lib.types.enum [ "amd" "intel" ]); default = if config.hardware.cpu.intel.updateMicrocode then "intel" else if config.hardware.cpu.amd.updateMicrocode then "amd" else null; - defaultText = literalMD '' + defaultText = lib.literalMD '' if config.hardware.cpu.intel.updateMicrocode then "intel" else if config.hardware.cpu.amd.updateMicrocode then "amd" else null; @@ -23,15 +20,15 @@ in { description = "CPU family of motherboard. Allows for addition motherboard i2c support."; }; - server.port = mkOption { - type = types.port; + server.port = lib.mkOption { + type = lib.types.port; default = 6742; description = "Set server port of openrgb."; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; services.udev.packages = [ cfg.package ]; From 2f256fd905823fb16ea844c2c031154124965423 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:21 +0200 Subject: [PATCH 103/139] nixos/services.pcscd: remove `with lib;` --- nixos/modules/services/hardware/pcscd.nix | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/nixos/modules/services/hardware/pcscd.nix b/nixos/modules/services/hardware/pcscd.nix index 17bab2c5bf20..df98c1fd208d 100644 --- a/nixos/modules/services/hardware/pcscd.nix +++ b/nixos/modules/services/hardware/pcscd.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.pcscd; cfgFile = pkgs.writeText "reader.conf" config.services.pcscd.readerConfig; @@ -18,17 +15,17 @@ let in { options.services.pcscd = { - enable = mkEnableOption "PCSC-Lite daemon, to access smart cards using SCard API (PC/SC)"; + enable = lib.mkEnableOption "PCSC-Lite daemon, to access smart cards using SCard API (PC/SC)"; - plugins = mkOption { - type = types.listOf types.package; - defaultText = literalExpression "[ pkgs.ccid ]"; - example = literalExpression "[ pkgs.pcsc-cyberjack ]"; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.package; + defaultText = lib.literalExpression "[ pkgs.ccid ]"; + example = lib.literalExpression "[ pkgs.pcsc-cyberjack ]"; description = "Plugin packages to be used for PCSC-Lite."; }; - readerConfig = mkOption { - type = types.lines; + readerConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = '' FRIENDLYNAME "Some serial reader" @@ -43,14 +40,14 @@ in ''; }; - extraArgs = mkOption { - type = types.listOf types.str; + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; description = "Extra command line arguments to be passed to the PCSC daemon."; }; }; - config = mkIf config.services.pcscd.enable { + config = lib.mkIf config.services.pcscd.enable { environment.etc."reader.conf".source = cfgFile; environment.systemPackages = [ package ]; From 08ec49ef4174a6266dd2222eec76beefe205260f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:21 +0200 Subject: [PATCH 104/139] nixos/services.pommed: remove `with lib;` --- nixos/modules/services/hardware/pommed.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/hardware/pommed.nix b/nixos/modules/services/hardware/pommed.nix index 9cdb2d4d1af8..c5efb76d6eec 100644 --- a/nixos/modules/services/hardware/pommed.nix +++ b/nixos/modules/services/hardware/pommed.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.hardware.pommed; defaultConf = "${pkgs.pommed_light}/etc/pommed.conf.mactel"; in { @@ -10,8 +7,8 @@ in { services.hardware.pommed = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to use the pommed tool to handle Apple laptop @@ -19,8 +16,8 @@ in { ''; }; - configFile = mkOption { - type = types.nullOr types.path; + configFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' The path to the {file}`pommed.conf` file. Leave @@ -35,7 +32,7 @@ in { }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.polkit pkgs.pommed_light ]; environment.etc."pommed.conf".source = From 439cb745b0d8eb3f881c77c7d8bccecba3782a75 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:22 +0200 Subject: [PATCH 105/139] nixos/hardware.rasdaemon: remove `with lib;` --- nixos/modules/services/hardware/rasdaemon.nix | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/nixos/modules/services/hardware/rasdaemon.nix b/nixos/modules/services/hardware/rasdaemon.nix index 3fe75984b3fb..ac3c675a7fbe 100644 --- a/nixos/modules/services/hardware/rasdaemon.nix +++ b/nixos/modules/services/hardware/rasdaemon.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.rasdaemon; @@ -10,16 +7,16 @@ in { options.hardware.rasdaemon = { - enable = mkEnableOption "RAS logging daemon"; + enable = lib.mkEnableOption "RAS logging daemon"; - record = mkOption { - type = types.bool; + record = lib.mkOption { + type = lib.types.bool; default = true; description = "record events via sqlite3, required for ras-mc-ctl"; }; - mainboard = mkOption { - type = types.lines; + mainboard = lib.mkOption { + type = lib.types.lines; default = ""; description = "Custom mainboard description, see {manpage}`ras-mc-ctl(8)` for more details."; example = '' @@ -37,8 +34,8 @@ in # TODO, accept `rasdaemon.labels = " ";` or `rasdaemon.labels = { dell = " "; asrock = " "; };' - labels = mkOption { - type = types.lines; + labels = lib.mkOption { + type = lib.types.lines; default = ""; description = "Additional memory module label descriptions to be placed in /etc/ras/dimm_labels.d/labels"; example = '' @@ -54,8 +51,8 @@ in ''; }; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; default = ""; description = '' rasdaemon configuration, currently only used for CE PFA @@ -69,17 +66,17 @@ in ''; }; - extraModules = mkOption { - type = types.listOf types.str; + extraModules = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "extra kernel modules to load"; example = [ "i7core_edac" ]; }; - testing = mkEnableOption "error injection infrastructure"; + testing = lib.mkEnableOption "error injection infrastructure"; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.etc = { "ras/mainboard" = { @@ -97,14 +94,14 @@ in }; }; environment.systemPackages = [ pkgs.rasdaemon ] - ++ optionals (cfg.testing) (with pkgs.error-inject; [ + ++ lib.optionals (cfg.testing) (with pkgs.error-inject; [ edac-inject mce-inject aer-inject ]); boot.initrd.kernelModules = cfg.extraModules - ++ optionals (cfg.testing) [ + ++ lib.optionals (cfg.testing) [ # edac_core and amd64_edac should get loaded automatically # i7core_edac may not be, and may not be required, but should load successfully "edac_core" @@ -114,7 +111,7 @@ in "aer-inject" ]; - boot.kernelPatches = optionals (cfg.testing) [{ + boot.kernelPatches = lib.optionals (cfg.testing) [{ name = "rasdaemon-tests"; patch = null; extraConfig = '' @@ -139,10 +136,10 @@ in wantedBy = [ "multi-user.target" ]; serviceConfig = { - StateDirectory = optionalString (cfg.record) "rasdaemon"; + StateDirectory = lib.optionalString (cfg.record) "rasdaemon"; ExecStart = "${pkgs.rasdaemon}/bin/rasdaemon --foreground" - + optionalString (cfg.record) " --record"; + + lib.optionalString (cfg.record) " --record"; ExecStop = "${pkgs.rasdaemon}/bin/rasdaemon --disable"; Restart = "on-abort"; @@ -152,7 +149,7 @@ in # and everything seems to be enabled without this... }; }; - ras-mc-ctl = mkIf (cfg.labels != "") { + ras-mc-ctl = lib.mkIf (cfg.labels != "") { description = "register DIMM labels on startup"; documentation = [ "man:ras-mc-ctl(8)" ]; wantedBy = [ "multi-user.target" ]; @@ -165,6 +162,6 @@ in }; }; - meta.maintainers = [ maintainers.evils ]; + meta.maintainers = [ lib.maintainers.evils ]; } From e2a4b6715f4ca2dfffe9b393f021215504dc236e Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:22 +0200 Subject: [PATCH 106/139] nixos/services.ratbagd: remove `with lib;` --- nixos/modules/services/hardware/ratbagd.nix | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/hardware/ratbagd.nix b/nixos/modules/services/hardware/ratbagd.nix index 4398e8d582ea..c7a6e9093b47 100644 --- a/nixos/modules/services/hardware/ratbagd.nix +++ b/nixos/modules/services/hardware/ratbagd.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.ratbagd; in @@ -10,15 +7,15 @@ in options = { services.ratbagd = { - enable = mkEnableOption "ratbagd for configuring gaming mice"; + enable = lib.mkEnableOption "ratbagd for configuring gaming mice"; - package = mkPackageOption pkgs "libratbag" { }; + package = lib.mkPackageOption pkgs "libratbag" { }; }; }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # Give users access to the "ratbagctl" tool environment.systemPackages = [ cfg.package ]; From 131116e4f04b4d7649df700768537bb8af942fa6 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:22 +0200 Subject: [PATCH 107/139] nixos/services.saned: remove `with lib;` --- nixos/modules/services/hardware/sane.nix | 69 ++++++++++++------------ 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/hardware/sane.nix b/nixos/modules/services/hardware/sane.nix index b6b36b6b60f4..98207ada78c3 100644 --- a/nixos/modules/services/hardware/sane.nix +++ b/nixos/modules/services/hardware/sane.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let pkg = config.hardware.sane.backends-package.override { @@ -32,7 +29,7 @@ let LD_LIBRARY_PATH = [ "/etc/sane-libs" ]; }; - backends = [ pkg netConf ] ++ optional config.services.saned.enable sanedConf ++ config.hardware.sane.extraBackends; + backends = [ pkg netConf ] ++ lib.optional config.services.saned.enable sanedConf ++ config.hardware.sane.extraBackends; saneConfig = pkgs.mkSaneConfig { paths = backends; inherit (config.hardware.sane) disabledDefaultBackends; }; enabled = config.hardware.sane.enable || config.services.saned.enable; @@ -45,8 +42,8 @@ in options = { - hardware.sane.enable = mkOption { - type = types.bool; + hardware.sane.enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enable support for SANE scanners. @@ -57,21 +54,21 @@ in ''; }; - hardware.sane.backends-package = mkOption { - type = types.package; + hardware.sane.backends-package = lib.mkOption { + type = lib.types.package; default = pkgs.sane-backends; - defaultText = literalExpression "pkgs.sane-backends"; + defaultText = lib.literalExpression "pkgs.sane-backends"; description = "Backends driver package to use."; }; - hardware.sane.snapshot = mkOption { - type = types.bool; + hardware.sane.snapshot = lib.mkOption { + type = lib.types.bool; default = false; description = "Use a development snapshot of SANE scanner drivers."; }; - hardware.sane.extraBackends = mkOption { - type = types.listOf types.path; + hardware.sane.extraBackends = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' Packages providing extra SANE backends to enable. @@ -82,11 +79,11 @@ in vendors/devices). ::: ''; - example = literalExpression "[ pkgs.hplipWithPlugin pkgs.sane-airscan ]"; + example = lib.literalExpression "[ pkgs.hplipWithPlugin pkgs.sane-airscan ]"; }; - hardware.sane.disabledDefaultBackends = mkOption { - type = types.listOf types.str; + hardware.sane.disabledDefaultBackends = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "v4l" ]; description = '' @@ -95,14 +92,14 @@ in ''; }; - hardware.sane.configDir = mkOption { - type = types.str; + hardware.sane.configDir = lib.mkOption { + type = lib.types.str; internal = true; description = "The value of SANE_CONFIG_DIR."; }; - hardware.sane.netConf = mkOption { - type = types.lines; + hardware.sane.netConf = lib.mkOption { + type = lib.types.lines; default = ""; example = "192.168.0.16"; description = '' @@ -110,8 +107,8 @@ in ''; }; - hardware.sane.drivers.scanSnap.enable = mkOption { - type = types.bool; + hardware.sane.drivers.scanSnap.enable = lib.mkOption { + type = lib.types.bool; default = false; example = true; description = '' @@ -121,7 +118,7 @@ in ''; }; - hardware.sane.drivers.scanSnap.package = mkPackageOption pkgs [ "sane-drivers" "epjitsu" ] { + hardware.sane.drivers.scanSnap.package = lib.mkPackageOption pkgs [ "sane-drivers" "epjitsu" ] { extraDescription = '' Useful if you want to extract the driver files yourself. @@ -130,8 +127,8 @@ in ''; }; - hardware.sane.openFirewall = mkOption { - type = types.bool; + hardware.sane.openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Open ports needed for discovery of scanners on the local network, e.g. @@ -139,8 +136,8 @@ in ''; }; - services.saned.enable = mkOption { - type = types.bool; + services.saned.enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enable saned network daemon for remote connection to scanners. @@ -151,8 +148,8 @@ in ''; }; - services.saned.extraConfig = mkOption { - type = types.lines; + services.saned.extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = "192.168.0.0/24"; description = '' @@ -165,9 +162,9 @@ in ###### implementation - config = mkMerge [ - (mkIf enabled { - hardware.sane.configDir = mkDefault "${saneConfig}/etc/sane.d"; + config = lib.mkMerge [ + (lib.mkIf enabled { + hardware.sane.configDir = lib.mkDefault "${saneConfig}/etc/sane.d"; environment.systemPackages = backends; environment.sessionVariables = env; @@ -176,19 +173,19 @@ in services.udev.packages = backends; users.groups.scanner.gid = config.ids.gids.scanner; - networking.firewall.allowedUDPPorts = mkIf config.hardware.sane.openFirewall [ 8612 ]; + networking.firewall.allowedUDPPorts = lib.mkIf config.hardware.sane.openFirewall [ 8612 ]; systemd.tmpfiles.rules = [ "d /var/lock/sane 0770 root scanner - -" ]; }) - (mkIf config.services.saned.enable { + (lib.mkIf config.services.saned.enable { networking.firewall.connectionTrackingModules = [ "sane" ]; systemd.services."saned@" = { description = "Scanner Service"; - environment = mapAttrs (name: val: toString val) env; + environment = lib.mapAttrs (name: val: toString val) env; serviceConfig = { User = "scanner"; Group = "scanner"; @@ -211,7 +208,7 @@ in users.users.scanner = { uid = config.ids.uids.scanner; group = "scanner"; - extraGroups = [ "lp" ] ++ optionals config.services.avahi.enable [ "avahi" ]; + extraGroups = [ "lp" ] ++ lib.optionals config.services.avahi.enable [ "avahi" ]; }; }) ]; From d59ce5878ba5164f42bff7159aef50bb652b727f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:23 +0200 Subject: [PATCH 108/139] nixos/hardware.spacenavd: remove `with lib;` --- nixos/modules/services/hardware/spacenavd.nix | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/hardware/spacenavd.nix b/nixos/modules/services/hardware/spacenavd.nix index 69ca6f102efe..c09439356998 100644 --- a/nixos/modules/services/hardware/spacenavd.nix +++ b/nixos/modules/services/hardware/spacenavd.nix @@ -1,18 +1,15 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.spacenavd; in { options = { hardware.spacenavd = { - enable = mkEnableOption "spacenavd to support 3DConnexion devices"; + enable = lib.mkEnableOption "spacenavd to support 3DConnexion devices"; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.user.services.spacenavd = { description = "Daemon for the Spacenavigator 6DOF mice by 3Dconnexion"; wantedBy = [ "graphical.target" ]; From b80de00ac610295a6a0cace49f50d015bbf97395 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:23 +0200 Subject: [PATCH 109/139] nixos/services.tcsd: remove `with lib;` --- nixos/modules/services/hardware/tcsd.nix | 51 +++++++++++------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/nixos/modules/services/hardware/tcsd.nix b/nixos/modules/services/hardware/tcsd.nix index e414b9647c9b..24bb20b0146d 100644 --- a/nixos/modules/services/hardware/tcsd.nix +++ b/nixos/modules/services/hardware/tcsd.nix @@ -1,8 +1,5 @@ # tcsd daemon. - { config, options, pkgs, lib, ... }: - -with lib; let cfg = config.services.tcsd; @@ -37,9 +34,9 @@ in services.tcsd = { - enable = mkOption { + enable = lib.mkOption { default = false; - type = types.bool; + type = lib.types.bool; description = '' Whether to enable tcsd, a Trusted Computing management service that provides TCG Software Stack (TSS). The tcsd daemon is @@ -48,21 +45,21 @@ in ''; }; - user = mkOption { + user = lib.mkOption { default = "tss"; - type = types.str; + type = lib.types.str; description = "User account under which tcsd runs."; }; - group = mkOption { + group = lib.mkOption { default = "tss"; - type = types.str; + type = lib.types.str; description = "Group account under which tcsd runs."; }; - stateDir = mkOption { + stateDir = lib.mkOption { default = "/var/lib/tpm"; - type = types.path; + type = lib.types.path; description = '' The location of the system persistent storage file. The system persistent storage file holds keys and data across @@ -70,22 +67,22 @@ in ''; }; - firmwarePCRs = mkOption { + firmwarePCRs = lib.mkOption { default = "0,1,2,3,4,5,6,7"; - type = types.str; + type = lib.types.str; description = "PCR indices used in the TPM for firmware measurements."; }; - kernelPCRs = mkOption { + kernelPCRs = lib.mkOption { default = "8,9,10,11,12"; - type = types.str; + type = lib.types.str; description = "PCR indices used in the TPM for kernel measurements."; }; - platformCred = mkOption { + platformCred = lib.mkOption { default = "${cfg.stateDir}/platform.cert"; - defaultText = literalExpression ''"''${config.${opt.stateDir}}/platform.cert"''; - type = types.path; + defaultText = lib.literalExpression ''"''${config.${opt.stateDir}}/platform.cert"''; + type = lib.types.path; description = '' Path to the platform credential for your TPM. Your TPM manufacturer may have provided you with a set of credentials @@ -96,19 +93,19 @@ in on this process. ''; }; - conformanceCred = mkOption { + conformanceCred = lib.mkOption { default = "${cfg.stateDir}/conformance.cert"; - defaultText = literalExpression ''"''${config.${opt.stateDir}}/conformance.cert"''; - type = types.path; + defaultText = lib.literalExpression ''"''${config.${opt.stateDir}}/conformance.cert"''; + type = lib.types.path; description = '' Path to the conformance credential for your TPM. See also the platformCred option''; }; - endorsementCred = mkOption { + endorsementCred = lib.mkOption { default = "${cfg.stateDir}/endorsement.cert"; - defaultText = literalExpression ''"''${config.${opt.stateDir}}/endorsement.cert"''; - type = types.path; + defaultText = lib.literalExpression ''"''${config.${opt.stateDir}}/endorsement.cert"''; + type = lib.types.path; description = '' Path to the endorsement credential for your TPM. See also the platformCred option''; @@ -119,7 +116,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.trousers ]; @@ -150,13 +147,13 @@ in }; }; - users.users = optionalAttrs (cfg.user == "tss") { + users.users = lib.optionalAttrs (cfg.user == "tss") { tss = { group = "tss"; isSystemUser = true; }; }; - users.groups = optionalAttrs (cfg.group == "tss") { tss = {}; }; + users.groups = lib.optionalAttrs (cfg.group == "tss") { tss = {}; }; }; } From f4fdd33746e458a6e119085bf26bec17c74a2c82 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:23 +0200 Subject: [PATCH 110/139] nixos/services.thermald: remove `with lib;` --- nixos/modules/services/hardware/thermald.nix | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/hardware/thermald.nix b/nixos/modules/services/hardware/thermald.nix index fb7cf3735a7e..d7f706f1ef05 100644 --- a/nixos/modules/services/hardware/thermald.nix +++ b/nixos/modules/services/hardware/thermald.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.thermald; in @@ -9,24 +6,24 @@ in ###### interface options = { services.thermald = { - enable = mkEnableOption "thermald, the temperature management daemon"; + enable = lib.mkEnableOption "thermald, the temperature management daemon"; - debug = mkOption { - type = types.bool; + debug = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable debug logging. ''; }; - ignoreCpuidCheck = mkOption { - type = types.bool; + ignoreCpuidCheck = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to ignore the cpuid check to allow running on unsupported platforms"; }; - configFile = mkOption { - type = types.nullOr types.path; + configFile = lib.mkOption { + type = lib.types.nullOr lib.types.path; default = null; description = '' The thermald manual configuration file. @@ -37,12 +34,12 @@ in ''; }; - package = mkPackageOption pkgs "thermald" { }; + package = lib.mkPackageOption pkgs "thermald" { }; }; }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.dbus.packages = [ cfg.package ]; systemd.services.thermald = { @@ -53,8 +50,8 @@ in ExecStart = '' ${cfg.package}/sbin/thermald \ --no-daemon \ - ${optionalString cfg.debug "--loglevel=debug"} \ - ${optionalString cfg.ignoreCpuidCheck "--ignore-cpuid-check"} \ + ${lib.optionalString cfg.debug "--loglevel=debug"} \ + ${lib.optionalString cfg.ignoreCpuidCheck "--ignore-cpuid-check"} \ ${if cfg.configFile != null then "--config-file ${cfg.configFile}" else "--adaptive"} \ --dbus-enable ''; From d9dc50dc1193ad14f8534611f7280fac4a3543d0 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:24 +0200 Subject: [PATCH 111/139] nixos/services.thinkfan: remove `with lib;` --- nixos/modules/services/hardware/thinkfan.nix | 69 ++++++++++---------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/hardware/thinkfan.nix b/nixos/modules/services/hardware/thinkfan.nix index 37c9fef03d78..9dd4c5434211 100644 --- a/nixos/modules/services/hardware/thinkfan.nix +++ b/nixos/modules/services/hardware/thinkfan.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.thinkfan; @@ -10,13 +7,13 @@ let thinkfan = pkgs.thinkfan.override { inherit (cfg) smartSupport; }; # fan-speed and temperature levels - levelType = with types; + levelType = with lib.types; let - tuple = ts: mkOptionType { + tuple = ts: lib.mkOptionType { name = "tuple"; - merge = mergeOneOption; + merge = lib.mergeOneOption; check = xs: all id (zipListsWith (t: x: t.check x) ts xs); - description = "tuple of" + concatMapStrings (t: " (${t.description})") ts; + description = "tuple of" + lib.concatMapStrings (t: " (${t.description})") ts; }; level = ints.unsigned; special = enum [ "level auto" "level full-speed" "level disengaged" ]; @@ -24,11 +21,11 @@ let tuple [ (either level special) level level ]; # sensor or fan config - sensorType = name: types.submodule { - freeformType = types.attrsOf settingsFormat.type; + sensorType = name: lib.types.submodule { + freeformType = lib.types.attrsOf settingsFormat.type; options = { - type = mkOption { - type = types.enum [ "hwmon" "atasmart" "tpacpi" "nvml" ]; + type = lib.mkOption { + type = lib.types.enum [ "hwmon" "atasmart" "tpacpi" "nvml" ]; description = '' The ${name} type, can be `hwmon` for standard ${name}s, @@ -41,8 +38,8 @@ let `nvml` for the (proprietary) nVidia driver. ''; }; - query = mkOption { - type = types.str; + query = lib.mkOption { + type = lib.types.str; description = '' The query string used to match one or more ${name}s: can be a fullpath to the temperature file (single ${name}) or a fullpath @@ -54,8 +51,8 @@ let ::: ''; }; - indices = mkOption { - type = with types; nullOr (listOf ints.unsigned); + indices = lib.mkOption { + type = with lib.types; nullOr (listOf ints.unsigned); default = null; description = '' A list of ${name}s to pick in case multiple ${name}s match the query. @@ -65,9 +62,9 @@ let ::: ''; }; - } // optionalAttrs (name == "sensor") { - correction = mkOption { - type = with types; nullOr (listOf int); + } // lib.optionalAttrs (name == "sensor") { + correction = lib.mkOption { + type = with lib.types; nullOr (listOf int); default = null; description = '' A list of values to be added to the temperature of each sensor, @@ -79,7 +76,7 @@ let # removes NixOS special and unused attributes sensorToConf = { type, query, ... }@args: - (filterAttrs (k: v: v != null && !(elem k ["type" "query"])) args) + (lib.filterAttrs (k: v: v != null && !(lib.elem k ["type" "query"])) args) // { "${type}" = query; }; syntaxNote = name: '' @@ -103,8 +100,8 @@ in { services.thinkfan = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable thinkfan, a fan control program. @@ -117,8 +114,8 @@ in { relatedPackages = [ "thinkfan" ]; }; - smartSupport = mkOption { - type = types.bool; + smartSupport = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to build thinkfan with S.M.A.R.T. support to read temperatures @@ -126,8 +123,8 @@ in { ''; }; - sensors = mkOption { - type = types.listOf (sensorType "sensor"); + sensors = lib.mkOption { + type = lib.types.listOf (sensorType "sensor"); default = [ { type = "tpacpi"; query = "/proc/acpi/ibm/thermal"; @@ -140,8 +137,8 @@ in { ''; }; - fans = mkOption { - type = types.listOf (sensorType "fan"); + fans = lib.mkOption { + type = lib.types.listOf (sensorType "fan"); default = [ { type = "tpacpi"; query = "/proc/acpi/ibm/fan"; @@ -154,8 +151,8 @@ in { ''; }; - levels = mkOption { - type = types.listOf levelType; + levels = lib.mkOption { + type = lib.types.listOf levelType; default = [ [0 0 55] [1 48 60] @@ -177,8 +174,8 @@ in { ''; }; - extraArgs = mkOption { - type = types.listOf types.str; + extraArgs = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "-b" "0" ]; description = '' @@ -187,8 +184,8 @@ in { ''; }; - settings = mkOption { - type = types.attrsOf settingsFormat.type; + settings = lib.mkOption { + type = lib.types.attrsOf settingsFormat.type; default = { }; description = '' Thinkfan settings. Use this option to configure thinkfan @@ -203,11 +200,11 @@ in { }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ thinkfan ]; - services.thinkfan.settings = mapAttrs (k: v: mkDefault v) { + services.thinkfan.settings = lib.mapAttrs (k: v: lib.mkDefault v) { sensors = map sensorToConf cfg.sensors; fans = map sensorToConf cfg.fans; levels = cfg.levels; @@ -216,7 +213,7 @@ in { systemd.packages = [ thinkfan ]; systemd.services = { - thinkfan.environment.THINKFAN_ARGS = escapeShellArgs ([ "-c" configFile ] ++ cfg.extraArgs); + thinkfan.environment.THINKFAN_ARGS = lib.escapeShellArgs ([ "-c" configFile ] ++ cfg.extraArgs); thinkfan.serviceConfig = { Restart = "on-failure"; RestartSec = "30s"; From 00052ae198632574d8e788807bd9fed2bbefbe96 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:24 +0200 Subject: [PATCH 112/139] nixos/services.throttled: remove `with lib;` --- nixos/modules/services/hardware/throttled.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/hardware/throttled.nix b/nixos/modules/services/hardware/throttled.nix index 143dc83a1d8b..30f10b3361a6 100644 --- a/nixos/modules/services/hardware/throttled.nix +++ b/nixos/modules/services/hardware/throttled.nix @@ -1,23 +1,20 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.throttled; in { options = { services.throttled = { - enable = mkEnableOption "fix for Intel CPU throttling"; + enable = lib.mkEnableOption "fix for Intel CPU throttling"; - extraConfig = mkOption { - type = types.str; + extraConfig = lib.mkOption { + type = lib.types.str; default = ""; description = "Alternative configuration"; }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.packages = [ pkgs.throttled ]; # The upstream package has this in Install, but that's not enough, see the NixOS manual systemd.services.throttled.wantedBy = [ "multi-user.target" ]; @@ -31,6 +28,6 @@ in { # Kernel 5.9 spams warnings whenever userspace writes to CPU MSRs. # See https://github.com/erpalma/throttled/issues/215 hardware.cpu.x86.msr.settings.allow-writes = - mkIf (versionAtLeast config.boot.kernelPackages.kernel.version "5.9") "on"; + lib.mkIf (lib.versionAtLeast config.boot.kernelPackages.kernel.version "5.9") "on"; }; } From cb1696c7287c33223b403707eea0858798083739 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:24 +0200 Subject: [PATCH 113/139] nixos/services.tlp: remove `with lib;` --- nixos/modules/services/hardware/tlp.nix | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/hardware/tlp.nix b/nixos/modules/services/hardware/tlp.nix index 148a88e2030f..53e232a32912 100644 --- a/nixos/modules/services/hardware/tlp.nix +++ b/nixos/modules/services/hardware/tlp.nix @@ -1,14 +1,13 @@ { config, lib, pkgs, ... }: -with lib; let cfg = config.services.tlp; enableRDW = config.networking.networkmanager.enable; tlp = pkgs.tlp.override { inherit enableRDW; }; # TODO: Use this for having proper parameters in the future - mkTlpConfig = tlpConfig: generators.toKeyValue { - mkKeyValue = generators.mkKeyValueDefault { + mkTlpConfig = tlpConfig: lib.generators.toKeyValue { + mkKeyValue = lib.generators.mkKeyValueDefault { mkValueString = val: - if isList val then "\"" + (toString val) + "\"" + if lib.isList val then "\"" + (toString val) + "\"" else toString val; } "="; } tlpConfig; @@ -17,13 +16,13 @@ in ###### interface options = { services.tlp = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Whether to enable the TLP power management daemon."; }; - settings = mkOption {type = with types; attrsOf (oneOf [bool int float str (listOf str)]); + settings = lib.mkOption {type = with lib.types; attrsOf (oneOf [bool int float str (listOf str)]); default = {}; example = { SATA_LINKPWR_ON_BAT = "med_power_with_dipm"; @@ -34,8 +33,8 @@ in ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Verbatim additional configuration variables for TLP. @@ -46,10 +45,10 @@ in }; ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { hardware.cpu.x86.msr.enable = true; - warnings = optional (cfg.extraConfig != "") '' + warnings = lib.optional (cfg.extraConfig != "") '' Using config.services.tlp.extraConfig is deprecated and will become unsupported in a future release. Use config.services.tlp.settings instead. ''; @@ -63,7 +62,7 @@ in environment.etc = { "tlp.conf".text = (mkTlpConfig cfg.settings) + cfg.extraConfig; - } // optionalAttrs enableRDW { + } // lib.optionalAttrs enableRDW { "NetworkManager/dispatcher.d/99tlp-rdw-nm".source = "${tlp}/usr/lib/NetworkManager/dispatcher.d/99tlp-rdw-nm"; }; From 624ea29c2737814383efecc93d0098aea284dfe2 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:25 +0200 Subject: [PATCH 114/139] nixos/services.triggerhappy: remove `with lib;` --- .../services/hardware/triggerhappy.nix | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/nixos/modules/services/hardware/triggerhappy.nix b/nixos/modules/services/hardware/triggerhappy.nix index 89f8754c0e68..d2137971b3a7 100644 --- a/nixos/modules/services/hardware/triggerhappy.nix +++ b/nixos/modules/services/hardware/triggerhappy.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.triggerhappy; @@ -9,9 +6,9 @@ let socket = "/run/thd.socket"; configFile = pkgs.writeText "triggerhappy.conf" '' - ${concatMapStringsSep "\n" + ${lib.concatMapStringsSep "\n" ({ keys, event, cmd, ... }: - ''${concatMapStringsSep "+" (x: "KEY_" + x) keys} ${toString { press = 1; hold = 2; release = 0; }.${event}} ${cmd}'' + ''${lib.concatMapStringsSep "+" (x: "KEY_" + x) keys} ${toString { press = 1; hold = 2; release = 0; }.${event}} ${cmd}'' ) cfg.bindings} ${cfg.extraConfig} @@ -20,19 +17,19 @@ let bindingCfg = { ... }: { options = { - keys = mkOption { - type = types.listOf types.str; + keys = lib.mkOption { + type = lib.types.listOf lib.types.str; description = "List of keys to match. Key names as defined in linux/input-event-codes.h"; }; - event = mkOption { - type = types.enum ["press" "hold" "release"]; + event = lib.mkOption { + type = lib.types.enum ["press" "hold" "release"]; default = "press"; description = "Event to match."; }; - cmd = mkOption { - type = types.str; + cmd = lib.mkOption { + type = lib.types.str; description = "What to run."; }; @@ -49,16 +46,16 @@ in services.triggerhappy = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable the {command}`triggerhappy` hotkey daemon. ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "nobody"; example = "root"; description = '' @@ -66,8 +63,8 @@ in ''; }; - bindings = mkOption { - type = types.listOf (types.submodule bindingCfg); + bindings = lib.mkOption { + type = lib.types.listOf (lib.types.submodule bindingCfg); default = []; example = lib.literalExpression '' [ { keys = ["PLAYPAUSE"]; cmd = "''${pkgs.mpc-cli}/bin/mpc -q toggle"; } ] @@ -77,8 +74,8 @@ in ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Literal contents to append to the end of {command}`triggerhappy` configuration file. @@ -92,7 +89,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.sockets.triggerhappy = { description = "Triggerhappy Socket"; @@ -104,7 +101,7 @@ in wantedBy = [ "multi-user.target" ]; description = "Global hotkey daemon"; serviceConfig = { - ExecStart = "${pkgs.triggerhappy}/bin/thd ${optionalString (cfg.user != "root") "--user ${cfg.user}"} --socket ${socket} --triggers ${configFile} --deviceglob /dev/input/event*"; + ExecStart = "${pkgs.triggerhappy}/bin/thd ${lib.optionalString (cfg.user != "root") "--user ${cfg.user}"} --socket ${socket} --triggers ${configFile} --deviceglob /dev/input/event*"; }; }; From 48633eb323f600b9226e27f2e3aba8aacc5d1535 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:25 +0200 Subject: [PATCH 115/139] nixos/hardware.tuxedo-rs: remove `with lib;` --- nixos/modules/services/hardware/tuxedo-rs.nix | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nixos/modules/services/hardware/tuxedo-rs.nix b/nixos/modules/services/hardware/tuxedo-rs.nix index 506454c1cadf..cfdc1c64d118 100644 --- a/nixos/modules/services/hardware/tuxedo-rs.nix +++ b/nixos/modules/services/hardware/tuxedo-rs.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.hardware.tuxedo-rs; @@ -9,13 +6,13 @@ in { options = { hardware.tuxedo-rs = { - enable = mkEnableOption "Rust utilities for interacting with hardware from TUXEDO Computers"; + enable = lib.mkEnableOption "Rust utilities for interacting with hardware from TUXEDO Computers"; - tailor-gui.enable = mkEnableOption "tailor-gui, an alternative to TUXEDO Control Center, written in Rust"; + tailor-gui.enable = lib.mkEnableOption "tailor-gui, an alternative to TUXEDO Control Center, written in Rust"; }; }; - config = mkIf cfg.enable (mkMerge [ + config = lib.mkIf cfg.enable (lib.mkMerge [ { hardware.tuxedo-keyboard.enable = true; @@ -40,10 +37,10 @@ in environment.systemPackages = [ pkgs.tuxedo-rs ]; } - (mkIf cfg.tailor-gui.enable { + (lib.mkIf cfg.tailor-gui.enable { environment.systemPackages = [ pkgs.tailor-gui ]; }) ]); - meta.maintainers = with maintainers; [ mrcjkb ]; + meta.maintainers = with lib.maintainers; [ mrcjkb ]; } From b00fba5c637cf602eb6854ff8a5d87a1c3557912 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:25 +0200 Subject: [PATCH 116/139] nixos/services.udev: remove `with lib;` --- nixos/modules/services/hardware/udev.nix | 69 ++++++++++++------------ 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix index 67956fdd6c76..e3f356ade678 100644 --- a/nixos/modules/services/hardware/udev.nix +++ b/nixos/modules/services/hardware/udev.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let udev = config.systemd.package; @@ -42,7 +39,7 @@ let udevRulesFor = { name, udevPackages, udevPath, udev, systemd, binPackages, initrdBin ? null }: pkgs.runCommand name { preferLocalBuild = true; allowSubstitutes = false; - packages = unique (map toString udevPackages); + packages = lib.unique (map toString udevPackages); } '' mkdir -p $out @@ -70,8 +67,8 @@ let --replace \"/bin/mount \"${pkgs.util-linux}/bin/mount \ --replace /usr/bin/readlink ${pkgs.coreutils}/bin/readlink \ --replace /usr/bin/basename ${pkgs.coreutils}/bin/basename 2>/dev/null - ${optionalString (initrdBin != null) '' - substituteInPlace $i --replace '/run/current-system/systemd' "${removeSuffix "/bin" initrdBin}" + ${lib.optionalString (initrdBin != null) '' + substituteInPlace $i --replace '/run/current-system/systemd' "${lib.removeSuffix "/bin" initrdBin}" ''} done @@ -137,7 +134,7 @@ let # If auto-configuration is disabled, then remove # udev's 80-drivers.rules file, which contains rules for # automatically calling modprobe. - ${optionalString (!config.boot.hardwareScan) '' + ${lib.optionalString (!config.boot.hardwareScan) '' ln -s /dev/null $out/80-drivers.rules ''} ''; @@ -145,7 +142,7 @@ let hwdbBin = pkgs.runCommand "hwdb.bin" { preferLocalBuild = true; allowSubstitutes = false; - packages = unique (map toString ([udev] ++ cfg.packages)); + packages = lib.unique (map toString ([udev] ++ cfg.packages)); } '' mkdir -p etc/udev/hwdb.d @@ -191,8 +188,8 @@ in ###### interface options = { - boot.hardwareScan = mkOption { - type = types.bool; + boot.hardwareScan = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether to try to load kernel modules for all detected hardware. @@ -203,12 +200,12 @@ in }; services.udev = { - enable = mkEnableOption "udev, a device manager for the Linux kernel" // { + enable = lib.mkEnableOption "udev, a device manager for the Linux kernel" // { default = true; }; - packages = mkOption { - type = types.listOf types.path; + packages = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' List of packages containing {command}`udev` rules. @@ -217,11 +214,11 @@ in {file}`«pkg»/lib/udev/rules.d` will be included. ''; - apply = map getBin; + apply = map lib.getBin; }; - path = mkOption { - type = types.listOf types.path; + path = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' Packages added to the {env}`PATH` environment variable when @@ -232,12 +229,12 @@ in ''; }; - extraRules = mkOption { + extraRules = lib.mkOption { default = ""; example = '' ENV{ID_VENDOR_ID}=="046d", ENV{ID_MODEL_ID}=="0825", ENV{PULSE_IGNORE}="1" ''; - type = types.lines; + type = lib.types.lines; description = '' Additional {command}`udev` rules. They'll be written into file {file}`99-local.rules`. Thus they are @@ -245,14 +242,14 @@ in ''; }; - extraHwdb = mkOption { + extraHwdb = lib.mkOption { default = ""; example = '' evdev:input:b0003v05AFp8277* KEYBOARD_KEY_70039=leftalt KEYBOARD_KEY_700e2=leftctrl ''; - type = types.lines; + type = lib.types.lines; description = '' Additional {command}`hwdb` files. They'll be written into file {file}`99-local.hwdb`. Thus they are @@ -262,8 +259,8 @@ in }; - hardware.firmware = mkOption { - type = types.listOf types.package; + hardware.firmware = lib.mkOption { + type = lib.types.listOf lib.types.package; default = []; description = '' List of packages containing firmware files. Such files @@ -282,9 +279,9 @@ in }; }; - networking.usePredictableInterfaceNames = mkOption { + networking.usePredictableInterfaceNames = lib.mkOption { default = true; - type = types.bool; + type = lib.types.bool; description = '' Whether to assign [predictable names to network interfaces](https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/). If enabled, interfaces @@ -300,8 +297,8 @@ in boot.initrd.services.udev = { - packages = mkOption { - type = types.listOf types.path; + packages = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' *This will only be used when systemd is used in stage 1.* @@ -314,8 +311,8 @@ in ''; }; - binPackages = mkOption { - type = types.listOf types.path; + binPackages = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' *This will only be used when systemd is used in stage 1.* @@ -323,15 +320,15 @@ in Packages to search for binaries that are referenced by the udev rules in stage 1. This list always contains /bin of the initrd. ''; - apply = map getBin; + apply = map lib.getBin; }; - rules = mkOption { + rules = lib.mkOption { default = ""; example = '' SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1D:60:B9:6D:4F", KERNEL=="eth*", NAME="my_fast_network_card" ''; - type = types.lines; + type = lib.types.lines; description = '' {command}`udev` rules to include in the initrd *only*. They'll be written into file @@ -347,7 +344,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.udev.extraRules = nixosRules; @@ -355,9 +352,9 @@ in services.udev.path = [ pkgs.coreutils pkgs.gnused pkgs.gnugrep pkgs.util-linux udev ]; - boot.kernelParams = mkIf (!config.networking.usePredictableInterfaceNames) [ "net.ifnames=0" ]; + boot.kernelParams = lib.mkIf (!config.networking.usePredictableInterfaceNames) [ "net.ifnames=0" ]; - boot.initrd.extraUdevRulesCommands = mkIf (!config.boot.initrd.systemd.enable && config.boot.initrd.services.udev.rules != "") + boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable && config.boot.initrd.services.udev.rules != "") '' cat <<'EOF' > $out/99-local.rules ${config.boot.initrd.services.udev.rules} @@ -397,7 +394,7 @@ in # Insert initrd rules boot.initrd.services.udev.packages = [ initrdUdevRules - (mkIf (config.boot.initrd.services.udev.rules != "") (pkgs.writeTextFile { + (lib.mkIf (config.boot.initrd.services.udev.rules != "") (pkgs.writeTextFile { name = "initrd-udev-rules"; destination = "/etc/udev/rules.d/99-local.rules"; text = config.boot.initrd.services.udev.rules; @@ -443,6 +440,6 @@ in }; imports = [ - (mkRenamedOptionModule [ "services" "udev" "initrdRules" ] [ "boot" "initrd" "services" "udev" "rules" ]) + (lib.mkRenamedOptionModule [ "services" "udev" "initrdRules" ] [ "boot" "initrd" "services" "udev" "rules" ]) ]; } From 0de89d26ea59907d0bdf84dc6216c480880bf2a3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:26 +0200 Subject: [PATCH 117/139] nixos/services.udisks2: remove `with lib;` --- nixos/modules/services/hardware/udisks2.nix | 30 ++++++++++----------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/nixos/modules/services/hardware/udisks2.nix b/nixos/modules/services/hardware/udisks2.nix index 46a72b961501..e52aa5a58df2 100644 --- a/nixos/modules/services/hardware/udisks2.nix +++ b/nixos/modules/services/hardware/udisks2.nix @@ -1,13 +1,11 @@ # Udisks daemon. { config, lib, pkgs, ... }: -with lib; - let cfg = config.services.udisks2; settingsFormat = pkgs.formats.ini { - listToValue = concatMapStringsSep "," (generators.mkValueStringDefault {}); + listToValue = lib.concatMapStringsSep "," (lib.generators.mkValueStringDefault {}); }; - configFiles = mapAttrs (name: value: (settingsFormat.generate name value)) (mapAttrs' (name: value: nameValuePair name value ) config.services.udisks2.settings); + configFiles = lib.mapAttrs (name: value: (settingsFormat.generate name value)) (lib.mapAttrs' (name: value: lib.nameValuePair name value ) config.services.udisks2.settings); in { @@ -18,10 +16,10 @@ in services.udisks2 = { - enable = mkEnableOption "udisks2, a DBus service that allows applications to query and manipulate storage devices"; + enable = lib.mkEnableOption "udisks2, a DBus service that allows applications to query and manipulate storage devices"; - mountOnMedia = mkOption { - type = types.bool; + mountOnMedia = lib.mkOption { + type = lib.types.bool; default = false; description = '' When enabled, instructs udisks2 to mount removable drives under `/media/` directory, instead of the @@ -30,9 +28,9 @@ in ''; }; - settings = mkOption rec { - type = types.attrsOf settingsFormat.type; - apply = recursiveUpdate default; + settings = lib.mkOption rec { + type = lib.types.attrsOf settingsFormat.type; + apply = lib.recursiveUpdate default; default = { "udisks2.conf" = { udisks2 = { @@ -44,7 +42,7 @@ in }; }; }; - example = literalExpression '' + example = lib.literalExpression '' { "WDC-WD10EZEX-60M2NA0-WD-WCC3F3SJ0698.conf" = { ATA = { @@ -67,14 +65,14 @@ in ###### implementation - config = mkIf config.services.udisks2.enable { + config = lib.mkIf config.services.udisks2.enable { environment.systemPackages = [ pkgs.udisks2 ]; - environment.etc = (mapAttrs' (name: value: nameValuePair "udisks2/${name}" { source = value; } ) configFiles) // ( + environment.etc = (lib.mapAttrs' (name: value: lib.nameValuePair "udisks2/${name}" { source = value; } ) configFiles) // ( let libblockdev = pkgs.udisks2.libblockdev; - majorVer = versions.major libblockdev.version; + majorVer = lib.versions.major libblockdev.version; in { # We need to make sure /etc/libblockdev/@major_ver@/conf.d is populated to avoid # warnings @@ -87,11 +85,11 @@ in services.dbus.packages = [ pkgs.udisks2 ]; systemd.tmpfiles.rules = [ "d /var/lib/udisks2 0755 root root -" ] - ++ optional cfg.mountOnMedia "D! /media 0755 root root -"; + ++ lib.optional cfg.mountOnMedia "D! /media 0755 root root -"; services.udev.packages = [ pkgs.udisks2 ]; - services.udev.extraRules = optionalString cfg.mountOnMedia '' + services.udev.extraRules = lib.optionalString cfg.mountOnMedia '' ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1" ''; From c1573bb3efbaa0c5ca796922ffc431bf8bd471d7 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:26 +0200 Subject: [PATCH 118/139] nixos/services.undervolt: remove `with lib;` --- nixos/modules/services/hardware/undervolt.nix | 68 +++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/hardware/undervolt.nix b/nixos/modules/services/hardware/undervolt.nix index 23bc848b2398..1fce225db366 100644 --- a/nixos/modules/services/hardware/undervolt.nix +++ b/nixos/modules/services/hardware/undervolt.nix @@ -1,12 +1,10 @@ { config, pkgs, lib, ... }: - -with lib; let cfg = config.services.undervolt; mkPLimit = limit: window: if (limit == null && window == null) then null - else assert asserts.assertMsg (limit != null && window != null) "Both power limit and window must be set"; + else assert lib.asserts.assertMsg (limit != null && window != null) "Both power limit and window must be set"; "${toString limit} ${toString window}"; cliArgs = lib.cli.toGNUCommandLine {} { inherit (cfg) @@ -34,96 +32,96 @@ let in { options.services.undervolt = { - enable = mkEnableOption '' + enable = lib.mkEnableOption '' Undervolting service for Intel CPUs. Warning: This service is not endorsed by Intel and may permanently damage your hardware. Use at your own risk ''; - verbose = mkOption { - type = types.bool; + verbose = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable verbose logging. ''; }; - package = mkPackageOption pkgs "undervolt" { }; + package = lib.mkPackageOption pkgs "undervolt" { }; - coreOffset = mkOption { - type = types.nullOr types.int; + coreOffset = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The amount of voltage in mV to offset the CPU cores by. ''; }; - gpuOffset = mkOption { - type = types.nullOr types.int; + gpuOffset = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The amount of voltage in mV to offset the GPU by. ''; }; - uncoreOffset = mkOption { - type = types.nullOr types.int; + uncoreOffset = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The amount of voltage in mV to offset uncore by. ''; }; - analogioOffset = mkOption { - type = types.nullOr types.int; + analogioOffset = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The amount of voltage in mV to offset analogio by. ''; }; - temp = mkOption { - type = types.nullOr types.int; + temp = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The temperature target in Celsius degrees. ''; }; - tempAc = mkOption { - type = types.nullOr types.int; + tempAc = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The temperature target on AC power in Celsius degrees. ''; }; - tempBat = mkOption { - type = types.nullOr types.int; + tempBat = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' The temperature target on battery power in Celsius degrees. ''; }; - turbo = mkOption { - type = types.nullOr types.int; + turbo = lib.mkOption { + type = lib.types.nullOr lib.types.int; default = null; description = '' Changes the Intel Turbo feature status (1 is disabled and 0 is enabled). ''; }; - p1.limit = mkOption { - type = with types; nullOr int; + p1.limit = lib.mkOption { + type = with lib.types; nullOr int; default = null; description = '' The P1 Power Limit in Watts. Both limit and window must be set. ''; }; - p1.window = mkOption { - type = with types; nullOr (oneOf [ float int ]); + p1.window = lib.mkOption { + type = with lib.types; nullOr (oneOf [ float int ]); default = null; description = '' The P1 Time Window in seconds. @@ -131,16 +129,16 @@ in ''; }; - p2.limit = mkOption { - type = with types; nullOr int; + p2.limit = lib.mkOption { + type = with lib.types; nullOr int; default = null; description = '' The P2 Power Limit in Watts. Both limit and window must be set. ''; }; - p2.window = mkOption { - type = with types; nullOr (oneOf [ float int ]); + p2.window = lib.mkOption { + type = with lib.types; nullOr (oneOf [ float int ]); default = null; description = '' The P2 Time Window in seconds. @@ -148,8 +146,8 @@ in ''; }; - useTimer = mkOption { - type = types.bool; + useTimer = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to set a timer that applies the undervolt settings every 30s. @@ -160,7 +158,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { hardware.cpu.x86.msr.enable = true; environment.systemPackages = [ cfg.package ]; @@ -179,7 +177,7 @@ in }; }; - systemd.timers.undervolt = mkIf cfg.useTimer { + systemd.timers.undervolt = lib.mkIf cfg.useTimer { description = "Undervolt timer to ensure voltage settings are always applied"; partOf = [ "undervolt.service" ]; wantedBy = [ "multi-user.target" ]; From ab7b22c311f40fd8cfd9b5097de0bca06646f4c7 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:26 +0200 Subject: [PATCH 119/139] nixos/services.upower: remove `with lib;` --- nixos/modules/services/hardware/upower.nix | 58 ++++++++++------------ 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/nixos/modules/services/hardware/upower.nix b/nixos/modules/services/hardware/upower.nix index 3d0edb0467ea..bcc768cc05d3 100644 --- a/nixos/modules/services/hardware/upower.nix +++ b/nixos/modules/services/hardware/upower.nix @@ -1,9 +1,5 @@ # Upower daemon. - { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.upower; @@ -18,8 +14,8 @@ in services.upower = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable Upower, a DBus service that provides power @@ -27,10 +23,10 @@ in ''; }; - package = mkPackageOption pkgs "upower" { }; + package = lib.mkPackageOption pkgs "upower" { }; - enableWattsUpPro = mkOption { - type = types.bool; + enableWattsUpPro = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enable the Watts Up Pro device. @@ -47,8 +43,8 @@ in ''; }; - noPollBatteries = mkOption { - type = types.bool; + noPollBatteries = lib.mkOption { + type = lib.types.bool; default = false; description = '' Don't poll the kernel for battery level changes. @@ -59,8 +55,8 @@ in ''; }; - ignoreLid = mkOption { - type = types.bool; + ignoreLid = lib.mkOption { + type = lib.types.bool; default = false; description = '' Do we ignore the lid state @@ -73,8 +69,8 @@ in ''; }; - usePercentageForPolicy = mkOption { - type = types.bool; + usePercentageForPolicy = lib.mkOption { + type = lib.types.bool; default = true; description = '' Policy for warnings and action based on battery levels @@ -87,8 +83,8 @@ in ''; }; - percentageLow = mkOption { - type = types.ints.unsigned; + percentageLow = lib.mkOption { + type = lib.types.ints.unsigned; default = 10; description = '' When `usePercentageForPolicy` is @@ -105,8 +101,8 @@ in ''; }; - percentageCritical = mkOption { - type = types.ints.unsigned; + percentageCritical = lib.mkOption { + type = lib.types.ints.unsigned; default = 3; description = '' When `usePercentageForPolicy` is @@ -123,8 +119,8 @@ in ''; }; - percentageAction = mkOption { - type = types.ints.unsigned; + percentageAction = lib.mkOption { + type = lib.types.ints.unsigned; default = 2; description = '' When `usePercentageForPolicy` is @@ -141,8 +137,8 @@ in ''; }; - timeLow = mkOption { - type = types.ints.unsigned; + timeLow = lib.mkOption { + type = lib.types.ints.unsigned; default = 1200; description = '' When `usePercentageForPolicy` is @@ -155,8 +151,8 @@ in ''; }; - timeCritical = mkOption { - type = types.ints.unsigned; + timeCritical = lib.mkOption { + type = lib.types.ints.unsigned; default = 300; description = '' When `usePercentageForPolicy` is @@ -169,8 +165,8 @@ in ''; }; - timeAction = mkOption { - type = types.ints.unsigned; + timeAction = lib.mkOption { + type = lib.types.ints.unsigned; default = 120; description = '' When `usePercentageForPolicy` is @@ -183,8 +179,8 @@ in ''; }; - criticalPowerAction = mkOption { - type = types.enum [ "PowerOff" "Hibernate" "HybridSleep" ]; + criticalPowerAction = lib.mkOption { + type = lib.types.enum [ "PowerOff" "Hibernate" "HybridSleep" ]; default = "HybridSleep"; description = '' The action to take when `timeAction` or @@ -200,7 +196,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ cfg.package ]; @@ -210,7 +206,7 @@ in systemd.packages = [ cfg.package ]; - environment.etc."UPower/UPower.conf".text = generators.toINI {} { + environment.etc."UPower/UPower.conf".text = lib.generators.toINI {} { UPower = { EnableWattsUpPro = cfg.enableWattsUpPro; NoPollBatteries = cfg.noPollBatteries; From a79aa024ca88447857f43a4b0f11626565e9066b Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:27 +0200 Subject: [PATCH 120/139] nixos/services.usbmuxd: remove `with lib;` --- nixos/modules/services/hardware/usbmuxd.nix | 27 +++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/hardware/usbmuxd.nix b/nixos/modules/services/hardware/usbmuxd.nix index 891619934eb6..c1b76ddce3b7 100644 --- a/nixos/modules/services/hardware/usbmuxd.nix +++ b/nixos/modules/services/hardware/usbmuxd.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let defaultUserGroup = "usbmux"; @@ -14,8 +11,8 @@ in { options.services.usbmuxd = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enable the usbmuxd ("USB multiplexing daemon") service. This daemon is @@ -25,35 +22,35 @@ in ''; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = defaultUserGroup; description = '' The user usbmuxd should use to run after startup. ''; }; - group = mkOption { - type = types.str; + group = lib.mkOption { + type = lib.types.str; default = defaultUserGroup; description = '' The group usbmuxd should use to run after startup. ''; }; - package = mkOption { - type = types.package; + package = lib.mkOption { + type = lib.types.package; default = pkgs.usbmuxd; - defaultText = literalExpression "pkgs.usbmuxd"; + defaultText = lib.literalExpression "pkgs.usbmuxd"; description = "Which package to use for the usbmuxd daemon."; relatedPackages = [ "usbmuxd" "usbmuxd2" ]; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { - users.users = optionalAttrs (cfg.user == defaultUserGroup) { + users.users = lib.optionalAttrs (cfg.user == defaultUserGroup) { ${cfg.user} = { description = "usbmuxd user"; group = cfg.group; @@ -61,7 +58,7 @@ in }; }; - users.groups = optionalAttrs (cfg.group == defaultUserGroup) { + users.groups = lib.optionalAttrs (cfg.group == defaultUserGroup) { ${cfg.group} = { }; }; From e5f14949de8dcbdc265d89676c7adbf6813be029 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:27 +0200 Subject: [PATCH 121/139] nixos/services.matter-server: remove `with lib;` --- .../home-automation/matter-server.nix | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/home-automation/matter-server.nix b/nixos/modules/services/home-automation/matter-server.nix index 08a68db71386..8a59815eec66 100644 --- a/nixos/modules/services/home-automation/matter-server.nix +++ b/nixos/modules/services/home-automation/matter-server.nix @@ -3,9 +3,6 @@ , config , ... }: - -with lib; - let cfg = config.services.matter-server; storageDir = "matter-server"; @@ -16,24 +13,24 @@ in { meta.maintainers = with lib.maintainers; [ leonm1 ]; - options.services.matter-server = with types; { - enable = mkEnableOption "Matter-server"; + options.services.matter-server = with lib.types; { + enable = lib.mkEnableOption "Matter-server"; - package = mkPackageOption pkgs "python-matter-server" { }; + package = lib.mkPackageOption pkgs "python-matter-server" { }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 5580; description = "Port to expose the matter-server service on."; }; - logLevel = mkOption { - type = types.enum [ "critical" "error" "warning" "info" "debug" ]; + logLevel = lib.mkOption { + type = lib.types.enum [ "critical" "error" "warning" "info" "debug" ]; default = "info"; description = "Verbosity of logs from the matter-server"; }; - extraArgs = mkOption { + extraArgs = lib.mkOption { type = listOf str; default = []; description = '' @@ -43,7 +40,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.matter-server = { after = [ "network-online.target" ]; before = [ "home-assistant.service" ]; @@ -52,13 +49,13 @@ in description = "Matter Server"; environment.HOME = storagePath; serviceConfig = { - ExecStart = (concatStringsSep " " [ + ExecStart = (lib.concatStringsSep " " [ "${cfg.package}/bin/matter-server" "--port" (toString cfg.port) "--vendorid" vendorId "--storage-path" storagePath "--log-level" "${cfg.logLevel}" - "${escapeShellArgs cfg.extraArgs}" + "${lib.escapeShellArgs cfg.extraArgs}" ]); # Start with a clean root filesystem, and allowlist what the container # is permitted to access. @@ -103,7 +100,7 @@ in RestrictNamespaces = true; RestrictRealtime = true; RestrictSUIDSGID = true; - SystemCallFilter = concatStringsSep " " [ + SystemCallFilter = lib.concatStringsSep " " [ "~" # Blocklist "@clock" "@cpu-emulation" From 5645a33f6ae6c89f51fb93a2d01c63045a42ffba Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:27 +0200 Subject: [PATCH 122/139] nixos/services.zigbee2mqtt: remove `with lib;` --- .../services/home-automation/zigbee2mqtt.nix | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/nixos/modules/services/home-automation/zigbee2mqtt.nix b/nixos/modules/services/home-automation/zigbee2mqtt.nix index f1d150487379..5a9fb0eaebc1 100644 --- a/nixos/modules/services/home-automation/zigbee2mqtt.nix +++ b/nixos/modules/services/home-automation/zigbee2mqtt.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.zigbee2mqtt; @@ -10,28 +7,28 @@ let in { - meta.maintainers = with maintainers; [ sweber hexa ]; + meta.maintainers = with lib.maintainers; [ sweber hexa ]; imports = [ # Remove warning before the 21.11 release - (mkRenamedOptionModule [ "services" "zigbee2mqtt" "config" ] [ "services" "zigbee2mqtt" "settings" ]) + (lib.mkRenamedOptionModule [ "services" "zigbee2mqtt" "config" ] [ "services" "zigbee2mqtt" "settings" ]) ]; options.services.zigbee2mqtt = { - enable = mkEnableOption "zigbee2mqtt service"; + enable = lib.mkEnableOption "zigbee2mqtt service"; - package = mkPackageOption pkgs "zigbee2mqtt" { }; + package = lib.mkPackageOption pkgs "zigbee2mqtt" { }; - dataDir = mkOption { + dataDir = lib.mkOption { description = "Zigbee2mqtt data directory"; default = "/var/lib/zigbee2mqtt"; - type = types.path; + type = lib.types.path; }; - settings = mkOption { + settings = lib.mkOption { type = format.type; default = { }; - example = literalExpression '' + example = lib.literalExpression '' { homeassistant = config.services.home-assistant.enable; permit_join = true; @@ -48,21 +45,21 @@ in }; }; - config = mkIf (cfg.enable) { + config = lib.mkIf (cfg.enable) { # preset config values services.zigbee2mqtt.settings = { - homeassistant = mkDefault config.services.home-assistant.enable; - permit_join = mkDefault false; + homeassistant = lib.mkDefault config.services.home-assistant.enable; + permit_join = lib.mkDefault false; mqtt = { - base_topic = mkDefault "zigbee2mqtt"; - server = mkDefault "mqtt://localhost:1883"; + base_topic = lib.mkDefault "zigbee2mqtt"; + server = lib.mkDefault "mqtt://localhost:1883"; }; - serial.port = mkDefault "/dev/ttyACM0"; + serial.port = lib.mkDefault "/dev/ttyACM0"; # reference device/group configuration, that is kept in a separate file # to prevent it being overwritten in the units ExecStartPre script - devices = mkDefault "devices.yaml"; - groups = mkDefault "groups.yaml"; + devices = lib.mkDefault "devices.yaml"; + groups = lib.mkDefault "groups.yaml"; }; systemd.services.zigbee2mqtt = { From 5eba86d6f2771675b7f61db8bc553d2c85a3b45a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:28 +0200 Subject: [PATCH 123/139] nixos/services.zwave-js: remove `with lib;` --- .../services/home-automation/zwave-js.nix | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/nixos/modules/services/home-automation/zwave-js.nix b/nixos/modules/services/home-automation/zwave-js.nix index 2138719ec6fa..4ce792624269 100644 --- a/nixos/modules/services/home-automation/zwave-js.nix +++ b/nixos/modules/services/home-automation/zwave-js.nix @@ -1,35 +1,32 @@ {config, pkgs, lib, ...}: - -with lib; - let cfg = config.services.zwave-js; mergedConfigFile = "/run/zwave-js/config.json"; settingsFormat = pkgs.formats.json {}; in { options.services.zwave-js = { - enable = mkEnableOption "the zwave-js server on boot"; + enable = lib.mkEnableOption "the zwave-js server on boot"; - package = mkPackageOption pkgs "zwave-js-server" { }; + package = lib.mkPackageOption pkgs "zwave-js-server" { }; - port = mkOption { - type = types.port; + port = lib.mkOption { + type = lib.types.port; default = 3000; description = '' Port for the server to listen on. ''; }; - serialPort = mkOption { - type = types.path; + serialPort = lib.mkOption { + type = lib.types.path; description = '' Serial port device path for Z-Wave controller. ''; example = "/dev/ttyUSB0"; }; - secretsConfigFile = mkOption { - type = types.path; + secretsConfigFile = lib.mkOption { + type = lib.types.path; description = '' JSON file containing secret keys. A dummy example: @@ -62,14 +59,14 @@ in { example = "/secrets/zwave-js-keys.json"; }; - settings = mkOption { + settings = lib.mkOption { type = lib.types.submodule { freeformType = settingsFormat.type; options = { storage = { - cacheDir = mkOption { - type = types.path; + cacheDir = lib.mkOption { + type = lib.types.path; default = "/var/cache/zwave-js"; readOnly = true; description = "Cache directory"; @@ -94,7 +91,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.zwave-js = let configFile = settingsFormat.generate "zwave-js-config.json" cfg.settings; in { @@ -110,7 +107,7 @@ in { "--config ${mergedConfigFile}" "--port ${toString cfg.port}" cfg.serialPort - (escapeShellArgs cfg.extraFlags) + (lib.escapeShellArgs cfg.extraFlags) ]; Restart = "on-failure"; User = "zwave-js"; From d9a644373a92b4e763d2c6aaa69ca9bcdc4253e3 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:28 +0200 Subject: [PATCH 124/139] nixos/services.SystemdJournal2Gelf: remove `with lib;` --- .../services/logging/SystemdJournal2Gelf.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/logging/SystemdJournal2Gelf.nix b/nixos/modules/services/logging/SystemdJournal2Gelf.nix index 7c50e9e2c42f..5b2f05f8c0f1 100644 --- a/nixos/modules/services/logging/SystemdJournal2Gelf.nix +++ b/nixos/modules/services/logging/SystemdJournal2Gelf.nix @@ -1,22 +1,19 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.SystemdJournal2Gelf; in { options = { services.SystemdJournal2Gelf = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable SystemdJournal2Gelf. ''; }; - graylogServer = mkOption { - type = types.str; + graylogServer = lib.mkOption { + type = lib.types.str; example = "graylog2.example.com:11201"; description = '' Host and port of your graylog2 input. This should be a GELF @@ -24,8 +21,8 @@ in ''; }; - extraOptions = mkOption { - type = types.separatedString " "; + extraOptions = lib.mkOption { + type = lib.types.separatedString " "; default = ""; description = '' Any extra flags to pass to SystemdJournal2Gelf. Note that @@ -33,12 +30,12 @@ in ''; }; - package = mkPackageOption pkgs "systemd-journal2gelf" { }; + package = lib.mkPackageOption pkgs "systemd-journal2gelf" { }; }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.SystemdJournal2Gelf = { description = "SystemdJournal2Gelf"; after = [ "network.target" ]; From e2a2735d4d4ffdaca26229d56c7ce8c8bea026da Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:28 +0200 Subject: [PATCH 125/139] nixos/services.awstats: remove `with lib;` --- nixos/modules/services/logging/awstats.nix | 83 +++++++++++----------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/nixos/modules/services/logging/awstats.nix b/nixos/modules/services/logging/awstats.nix index a5b0e6347b2b..d6d1fd64bd52 100644 --- a/nixos/modules/services/logging/awstats.nix +++ b/nixos/modules/services/logging/awstats.nix @@ -1,29 +1,26 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.awstats; package = pkgs.awstats; configOpts = {name, config, ...}: { options = { - type = mkOption{ - type = types.enum [ "mail" "web" ]; + type = lib.mkOption{ + type = lib.types.enum [ "mail" "web" ]; default = "web"; example = "mail"; description = '' The type of log being collected. ''; }; - domain = mkOption { - type = types.str; + domain = lib.mkOption { + type = lib.types.str; default = name; description = "The domain name to collect stats for."; example = "example.com"; }; - logFile = mkOption { - type = types.str; + logFile = lib.mkOption { + type = lib.types.str; example = "/var/log/nginx/access.log"; description = '' The log file to be scanned. @@ -35,8 +32,8 @@ let ''; }; - logFormat = mkOption { - type = types.str; + logFormat = lib.mkOption { + type = lib.types.str; default = "1"; description = '' The log format being used. @@ -48,8 +45,8 @@ let ''; }; - hostAliases = mkOption { - type = types.listOf types.str; + hostAliases = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; example = [ "www.example.org" ]; description = '' @@ -57,10 +54,10 @@ let ''; }; - extraConfig = mkOption { - type = types.attrsOf types.str; + extraConfig = lib.mkOption { + type = lib.types.attrsOf lib.types.str; default = {}; - example = literalExpression '' + example = lib.literalExpression '' { "ValidHTTPCodes" = "404"; } @@ -69,44 +66,44 @@ let }; webService = { - enable = mkEnableOption "awstats web service"; + enable = lib.mkEnableOption "awstats web service"; - hostname = mkOption { - type = types.str; + hostname = lib.mkOption { + type = lib.types.str; default = config.domain; description = "The hostname the web service appears under."; }; - urlPrefix = mkOption { - type = types.str; + urlPrefix = lib.mkOption { + type = lib.types.str; default = "/awstats"; description = "The URL prefix under which the awstats pages appear."; }; }; }; }; - webServices = filterAttrs (name: value: value.webService.enable) cfg.configs; + webServices = lib.filterAttrs (name: value: value.webService.enable) cfg.configs; in { imports = [ - (mkRemovedOptionModule [ "services" "awstats" "service" "enable" ] "Please enable per domain with `services.awstats.configs..webService.enable`") - (mkRemovedOptionModule [ "services" "awstats" "service" "urlPrefix" ] "Please set per domain with `services.awstats.configs..webService.urlPrefix`") - (mkRenamedOptionModule [ "services" "awstats" "vardir" ] [ "services" "awstats" "dataDir" ]) + (lib.mkRemovedOptionModule [ "services" "awstats" "service" "enable" ] "Please enable per domain with `services.awstats.configs..webService.enable`") + (lib.mkRemovedOptionModule [ "services" "awstats" "service" "urlPrefix" ] "Please set per domain with `services.awstats.configs..webService.urlPrefix`") + (lib.mkRenamedOptionModule [ "services" "awstats" "vardir" ] [ "services" "awstats" "dataDir" ]) ]; options.services.awstats = { - enable = mkEnableOption "awstats, a real-time logfile analyzer"; + enable = lib.mkEnableOption "awstats, a real-time logfile analyzer"; - dataDir = mkOption { - type = types.path; + dataDir = lib.mkOption { + type = lib.types.path; default = "/var/lib/awstats"; description = "The directory where awstats data will be stored."; }; - configs = mkOption { - type = types.attrsOf (types.submodule configOpts); + configs = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule configOpts); default = {}; - example = literalExpression '' + example = lib.literalExpression '' { "mysite" = { domain = "example.com"; @@ -117,8 +114,8 @@ in description = "Attribute set of domains to collect stats for."; }; - updateAt = mkOption { - type = types.nullOr types.str; + updateAt = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; example = "hourly"; description = '' @@ -129,18 +126,18 @@ in }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ package.bin ]; - environment.etc = mapAttrs' (name: opts: - nameValuePair "awstats/awstats.${name}.conf" { + environment.etc = lib.mapAttrs' (name: opts: + lib.nameValuePair "awstats/awstats.${name}.conf" { source = pkgs.runCommand "awstats.${name}.conf" { preferLocalBuild = true; } ('' sed \ '' # set up mail stats - + optionalString (opts.type == "mail") + + lib.optionalString (opts.type == "mail") '' -e 's|^\(LogType\)=.*$|\1=M|' \ -e 's|^\(LevelForBrowsersDetection\)=.*$|\1=0|' \ @@ -187,7 +184,7 @@ in '' + # extra config - concatStringsSep "\n" (mapAttrsToList (n: v: '' + lib.concatStringsSep "\n" (lib.mapAttrsToList (n: v: '' -e 's|^\(${n}\)=.*$|\1="${v}"|' \ '') opts.extraConfig) + @@ -199,11 +196,11 @@ in # create data directory with the correct permissions systemd.tmpfiles.rules = [ "d '${cfg.dataDir}' 755 root root - -" ] ++ - mapAttrsToList (name: opts: "d '${cfg.dataDir}/${name}' 755 root root - -") cfg.configs ++ + lib.mapAttrsToList (name: opts: "d '${cfg.dataDir}/${name}' 755 root root - -") cfg.configs ++ [ "Z '${cfg.dataDir}' 755 root root - -" ]; # nginx options - services.nginx.virtualHosts = mapAttrs'(name: opts: { + services.nginx.virtualHosts = lib.mapAttrs'(name: opts: { name = opts.webService.hostname; value = { locations = { @@ -224,10 +221,10 @@ in }) webServices; # update awstats - systemd.services = mkIf (cfg.updateAt != null) (mapAttrs' (name: opts: - nameValuePair "awstats-${name}-update" { + systemd.services = lib.mkIf (cfg.updateAt != null) (lib.mapAttrs' (name: opts: + lib.nameValuePair "awstats-${name}-update" { description = "update awstats for ${name}"; - script = optionalString (opts.type == "mail") + script = lib.optionalString (opts.type == "mail") '' if [[ -f "${cfg.dataDir}/${name}-cursor" ]]; then CURSOR="$(cat "${cfg.dataDir}/${name}-cursor" | tr -d '\n')" From 4e0ba37569670184e48e6bb5d5ebf345176dbf96 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:29 +0200 Subject: [PATCH 126/139] nixos/services.fluentd: remove `with lib;` --- nixos/modules/services/logging/fluentd.nix | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/nixos/modules/services/logging/fluentd.nix b/nixos/modules/services/logging/fluentd.nix index bbf905eca06b..fed5cacac37e 100644 --- a/nixos/modules/services/logging/fluentd.nix +++ b/nixos/modules/services/logging/fluentd.nix @@ -1,29 +1,26 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.fluentd; - pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins); + pluginArgs = lib.concatStringsSep " " (map (x: "-p ${x}") cfg.plugins); in { ###### interface options = { services.fluentd = { - enable = mkEnableOption "fluentd, a data/log collector"; + enable = lib.mkEnableOption "fluentd, a data/log collector"; - config = mkOption { - type = types.lines; + config = lib.mkOption { + type = lib.types.lines; default = ""; description = "Fluentd config."; }; - package = mkPackageOption pkgs "fluentd" { }; + package = lib.mkPackageOption pkgs "fluentd" { }; - plugins = mkOption { - type = types.listOf types.path; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.path; default = []; description = '' A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files @@ -36,7 +33,7 @@ in { ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.fluentd = with pkgs; { description = "Fluentd Daemon"; wantedBy = [ "multi-user.target" ]; From 83ed6b4d3bda16f629f71d58b368bb8937ce94d7 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:29 +0200 Subject: [PATCH 127/139] nixos/services.graylog: remove `with lib;` --- nixos/modules/services/logging/graylog.nix | 73 +++++++++++----------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/nixos/modules/services/logging/graylog.nix b/nixos/modules/services/logging/graylog.nix index caeac16815f4..ff1860e99a75 100644 --- a/nixos/modules/services/logging/graylog.nix +++ b/nixos/modules/services/logging/graylog.nix @@ -1,17 +1,14 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.graylog; confFile = pkgs.writeText "graylog.conf" '' - is_master = ${boolToString cfg.isMaster} + is_master = ${lib.boolToString cfg.isMaster} node_id_file = ${cfg.nodeIdFile} password_secret = ${cfg.passwordSecret} root_username = ${cfg.rootUsername} root_password_sha2 = ${cfg.rootPasswordSha2} - elasticsearch_hosts = ${concatStringsSep "," cfg.elasticsearchHosts} + elasticsearch_hosts = ${lib.concatStringsSep "," cfg.elasticsearchHosts} message_journal_dir = ${cfg.messageJournalDir} mongodb_uri = ${cfg.mongodbUri} plugin_dir = /var/lib/graylog/plugins @@ -34,49 +31,49 @@ in services.graylog = { - enable = mkEnableOption "Graylog, a log management solution"; + enable = lib.mkEnableOption "Graylog, a log management solution"; - package = mkOption { - type = types.package; - default = if versionOlder config.system.stateVersion "23.05" then pkgs.graylog-3_3 else pkgs.graylog-5_1; - defaultText = literalExpression (if versionOlder config.system.stateVersion "23.05" then "pkgs.graylog-3_3" else "pkgs.graylog-5_1"); + package = lib.mkOption { + type = lib.types.package; + default = if lib.versionOlder config.system.stateVersion "23.05" then pkgs.graylog-3_3 else pkgs.graylog-5_1; + defaultText = lib.literalExpression (if lib.versionOlder config.system.stateVersion "23.05" then "pkgs.graylog-3_3" else "pkgs.graylog-5_1"); description = "Graylog package to use."; }; - user = mkOption { - type = types.str; + user = lib.mkOption { + type = lib.types.str; default = "graylog"; description = "User account under which graylog runs"; }; - isMaster = mkOption { - type = types.bool; + isMaster = lib.mkOption { + type = lib.types.bool; default = true; description = "Whether this is the master instance of your Graylog cluster"; }; - nodeIdFile = mkOption { - type = types.str; + nodeIdFile = lib.mkOption { + type = lib.types.str; default = "/var/lib/graylog/server/node-id"; description = "Path of the file containing the graylog node-id"; }; - passwordSecret = mkOption { - type = types.str; + passwordSecret = lib.mkOption { + type = lib.types.str; description = '' You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters. Generate one by using for example: pwgen -N 1 -s 96 ''; }; - rootUsername = mkOption { - type = types.str; + rootUsername = lib.mkOption { + type = lib.types.str; default = "admin"; description = "Name of the default administrator user"; }; - rootPasswordSha2 = mkOption { - type = types.str; + rootPasswordSha2 = lib.mkOption { + type = lib.types.str; example = "e3c652f0ba0b4801205814f8b6bc49672c4c74e25b497770bb89b22cdeb4e952"; description = '' You MUST specify a hash password for the root user (which you only need to initially set up the @@ -88,40 +85,40 @@ in ''; }; - elasticsearchHosts = mkOption { - type = types.listOf types.str; - example = literalExpression ''[ "http://node1:9200" "http://user:password@node2:19200" ]''; + elasticsearchHosts = lib.mkOption { + type = lib.types.listOf lib.types.str; + example = lib.literalExpression ''[ "http://node1:9200" "http://user:password@node2:19200" ]''; description = "List of valid URIs of the http ports of your elastic nodes. If one or more of your elasticsearch hosts require authentication, include the credentials in each node URI that requires authentication"; }; - dataDir = mkOption { - type = types.str; + dataDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/graylog/data"; description = "Directory used to store Graylog server state."; }; - messageJournalDir = mkOption { - type = types.str; + messageJournalDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/graylog/data/journal"; description = "The directory which will be used to store the message journal. The directory must be exclusively used by Graylog and must not contain any other files than the ones created by Graylog itself"; }; - mongodbUri = mkOption { - type = types.str; + mongodbUri = lib.mkOption { + type = lib.types.str; default = "mongodb://localhost/graylog"; description = "MongoDB connection string. See http://docs.mongodb.org/manual/reference/connection-string/ for details"; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = "Any other configuration options you might want to add"; }; - plugins = mkOption { + plugins = lib.mkOption { description = "Extra graylog plugins"; default = [ ]; - type = types.listOf types.package; + type = lib.types.listOf lib.types.package; }; }; @@ -130,16 +127,16 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { - users.users = mkIf (cfg.user == "graylog") { + users.users = lib.mkIf (cfg.user == "graylog") { graylog = { isSystemUser = true; group = "graylog"; description = "Graylog server daemon user"; }; }; - users.groups = mkIf (cfg.user == "graylog") { graylog = {}; }; + users.groups = lib.mkIf (cfg.user == "graylog") { graylog = {}; }; systemd.tmpfiles.rules = [ "d '${cfg.messageJournalDir}' - ${cfg.user} - - -" From d0885b12f263b1e135a72873d1720d59d1c42d8a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:29 +0200 Subject: [PATCH 128/139] nixos/services.heartbeat: remove `with lib;` --- nixos/modules/services/logging/heartbeat.nix | 25 +++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/logging/heartbeat.nix b/nixos/modules/services/logging/heartbeat.nix index 1a264cebf6a2..a9fa644d550d 100644 --- a/nixos/modules/services/logging/heartbeat.nix +++ b/nixos/modules/services/logging/heartbeat.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.heartbeat; @@ -18,32 +15,32 @@ in services.heartbeat = { - enable = mkEnableOption "heartbeat, uptime monitoring"; + enable = lib.mkEnableOption "heartbeat, uptime monitoring"; - package = mkPackageOption pkgs "heartbeat" { + package = lib.mkPackageOption pkgs "heartbeat" { example = "heartbeat7"; }; - name = mkOption { - type = types.str; + name = lib.mkOption { + type = lib.types.str; default = "heartbeat"; description = "Name of the beat"; }; - tags = mkOption { - type = types.listOf types.str; + tags = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "Tags to place on the shipped log messages"; }; - stateDir = mkOption { - type = types.str; + stateDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/heartbeat"; description = "The state directory. heartbeat's own logs and other data are stored here."; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = '' heartbeat.monitors: - type: http @@ -56,7 +53,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.tmpfiles.rules = [ "d '${cfg.stateDir}' - nobody nogroup - -" From 0470d7f52fbb5740ca129c60a338cd5f36f95b3c Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:30 +0200 Subject: [PATCH 129/139] nixos/services.journalbeat: remove `with lib;` --- .../modules/services/logging/journalbeat.nix | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/nixos/modules/services/logging/journalbeat.nix b/nixos/modules/services/logging/journalbeat.nix index e7d726ab1f61..5c35e84f88e0 100644 --- a/nixos/modules/services/logging/journalbeat.nix +++ b/nixos/modules/services/logging/journalbeat.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.journalbeat; @@ -18,24 +15,24 @@ in services.journalbeat = { - enable = mkEnableOption "journalbeat"; + enable = lib.mkEnableOption "journalbeat"; - package = mkPackageOption pkgs "journalbeat" { }; + package = lib.mkPackageOption pkgs "journalbeat" { }; - name = mkOption { - type = types.str; + name = lib.mkOption { + type = lib.types.str; default = "journalbeat"; description = "Name of the beat"; }; - tags = mkOption { - type = types.listOf types.str; + tags = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = "Tags to place on the shipped log messages"; }; - stateDir = mkOption { - type = types.str; + stateDir = lib.mkOption { + type = lib.types.str; default = "journalbeat"; description = '' Directory below `/var/lib/` to store journalbeat's @@ -44,8 +41,8 @@ in ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = "Any other configuration options you want to add"; }; @@ -53,11 +50,11 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { - assertion = !hasPrefix "/" cfg.stateDir; + assertion = !lib.hasPrefix "/" cfg.stateDir; message = "The option services.journalbeat.stateDir shouldn't be an absolute directory." + " It should be a directory relative to /var/lib/."; From 5bc3fb494999ff0bf6a443271a76093b0b0b6399 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:30 +0200 Subject: [PATCH 130/139] nixos/services.journalwatch: remove `with lib;` --- .../modules/services/logging/journalwatch.nix | 58 +++++++++---------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/nixos/modules/services/logging/journalwatch.nix b/nixos/modules/services/logging/journalwatch.nix index 48fd992ffb65..ab75ed656c19 100644 --- a/nixos/modules/services/logging/journalwatch.nix +++ b/nixos/modules/services/logging/journalwatch.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: -with lib; - let cfg = config.services.journalwatch; user = "journalwatch"; @@ -15,7 +13,7 @@ let priority = ${toString cfg.priority} mail_from = ${cfg.mailFrom} '' - + optionalString (cfg.mailTo != null) '' + + lib.optionalString (cfg.mailTo != null) '' mail_to = ${cfg.mailTo} '' + cfg.extraConfig); @@ -27,7 +25,7 @@ let ''; # empty line at the end needed to to separate the blocks - mkPatterns = filterBlocks: concatStringsSep "\n" (map (block: '' + mkPatterns = filterBlocks: lib.concatStringsSep "\n" (map (block: '' ${block.match} ${block.filters} @@ -48,18 +46,18 @@ let in { options = { services.journalwatch = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' If enabled, periodically check the journal with journalwatch and report the results by mail. ''; }; - package = mkPackageOption pkgs "journalwatch" { }; + package = lib.mkPackageOption pkgs "journalwatch" { }; - priority = mkOption { - type = types.int; + priority = lib.mkOption { + type = lib.types.int; default = 6; description = '' Lowest priority of message to be considered. @@ -73,33 +71,33 @@ in { # HACK: this is a workaround for journalwatch's usage of socket.getfqdn() which always returns localhost if # there's an alias for the localhost on a separate line in /etc/hosts, or take for ages if it's not present and # then return something right-ish in the direction of /etc/hostname. Just bypass it completely. - mailFrom = mkOption { - type = types.str; + mailFrom = lib.mkOption { + type = lib.types.str; default = "journalwatch@${config.networking.hostName}"; - defaultText = literalExpression ''"journalwatch@''${config.networking.hostName}"''; + defaultText = lib.literalExpression ''"journalwatch@''${config.networking.hostName}"''; description = '' Mail address to send journalwatch reports from. ''; }; - mailTo = mkOption { - type = types.nullOr types.str; + mailTo = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' Mail address to send journalwatch reports to. ''; }; - mailBinary = mkOption { - type = types.path; + mailBinary = lib.mkOption { + type = lib.types.path; default = "/run/wrappers/bin/sendmail"; description = '' Sendmail-compatible binary to be used to send the messages. ''; }; - extraConfig = mkOption { - type = types.str; + extraConfig = lib.mkOption { + type = lib.types.str; default = ""; description = '' Extra lines to be added verbatim to the journalwatch/config configuration file. @@ -108,11 +106,11 @@ in { ''; }; - filterBlocks = mkOption { - type = types.listOf (types.submodule { + filterBlocks = lib.mkOption { + type = lib.types.listOf (lib.types.submodule { options = { - match = mkOption { - type = types.str; + match = lib.mkOption { + type = lib.types.str; example = "SYSLOG_IDENTIFIER = systemd"; description = '' Syntax: `field = value` @@ -125,8 +123,8 @@ in { ''; }; - filters = mkOption { - type = types.str; + filters = lib.mkOption { + type = lib.types.str; example = '' (Stopped|Stopping|Starting|Started) .* (Reached target|Stopped target) .* @@ -190,8 +188,8 @@ in { ''; }; - interval = mkOption { - type = types.str; + interval = lib.mkOption { + type = lib.types.str; default = "hourly"; description = '' How often to run journalwatch. @@ -199,8 +197,8 @@ in { The format is described in systemd.time(7). ''; }; - accuracy = mkOption { - type = types.str; + accuracy = lib.mkOption { + type = lib.types.str; default = "10min"; description = '' The time window around the interval in which the journalwatch run will be scheduled. @@ -211,7 +209,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { users.users.${user} = { isSystemUser = true; @@ -242,7 +240,7 @@ in { # requires a relative directory name to create beneath /var/lib StateDirectory = user; StateDirectoryMode = "0750"; - ExecStart = "${getExe cfg.package} mail"; + ExecStart = "${lib.getExe cfg.package} mail"; # lowest CPU and IO priority, but both still in best-effort class to prevent starvation Nice=19; IOSchedulingPriority=7; From e3a59fb4ac5aafe335afe7087ee06bfb298bfa29 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:30 +0200 Subject: [PATCH 131/139] nixos/services.logcheck: remove `with lib;` --- nixos/modules/services/logging/logcheck.nix | 81 ++++++++++----------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/nixos/modules/services/logging/logcheck.nix b/nixos/modules/services/logging/logcheck.nix index bda7f9a607e1..d937a523c866 100644 --- a/nixos/modules/services/logging/logcheck.nix +++ b/nixos/modules/services/logging/logcheck.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.logcheck; @@ -22,7 +19,7 @@ let flags = "-r ${rulesDir} -c ${configFile} -L ${logFiles} -${levelFlag} -m ${cfg.mailTo}"; - levelFlag = getAttrFromPath [cfg.level] + levelFlag = lib.getAttrFromPath [cfg.level] { paranoid = "p"; server = "s"; workstation = "w"; @@ -43,7 +40,7 @@ let }; writeIgnoreCronRule = name: {level, user, regex, cmdline, ...}: - let escapeRegex = escape (stringToCharacters "\\[]{}()^$?*+|."); + let escapeRegex = lib.escape (lib.stringToCharacters "\\[]{}()^$?*+|."); cmdline_ = builtins.unsafeDiscardStringContext cmdline; re = if regex != "" then regex else if cmdline_ == "" then ".*" else escapeRegex cmdline_; in writeIgnoreRule "cron-${name}" { @@ -53,9 +50,9 @@ let ''; }; - levelOption = mkOption { + levelOption = lib.mkOption { default = "server"; - type = types.enum [ "workstation" "server" "paranoid" ]; + type = lib.types.enum [ "workstation" "server" "paranoid" ]; description = '' Set the logcheck level. ''; @@ -65,9 +62,9 @@ let options = { level = levelOption; - regex = mkOption { + regex = lib.mkOption { default = ""; - type = types.str; + type = lib.types.str; description = '' Regex specifying which log lines to ignore. ''; @@ -77,25 +74,25 @@ let ignoreCronOptions = { options = { - user = mkOption { + user = lib.mkOption { default = "root"; - type = types.str; + type = lib.types.str; description = '' User that runs the cronjob. ''; }; - cmdline = mkOption { + cmdline = lib.mkOption { default = ""; - type = types.str; + type = lib.types.str; description = '' Command line for the cron job. Will be turned into a regex for the logcheck ignore rule. ''; }; - timeArgs = mkOption { + timeArgs = lib.mkOption { default = null; - type = types.nullOr (types.str); + type = lib.types.nullOr (lib.types.str); example = "02 06 * * *"; description = '' "min hr dom mon dow" crontab time args, to auto-create a cronjob too. @@ -109,20 +106,20 @@ in { options = { services.logcheck = { - enable = mkEnableOption "logcheck cron job, to mail anomalies in the system logfiles to the administrator"; + enable = lib.mkEnableOption "logcheck cron job, to mail anomalies in the system logfiles to the administrator"; - user = mkOption { + user = lib.mkOption { default = "logcheck"; - type = types.str; + type = lib.types.str; description = '' Username for the logcheck user. ''; }; - timeOfDay = mkOption { + timeOfDay = lib.mkOption { default = "*"; example = "6"; - type = types.str; + type = lib.types.str; description = '' Time of day to run logcheck. A logcheck will be scheduled at xx:02 each day. Leave default (*) to run every hour. Of course when nothing special was logged, @@ -130,68 +127,68 @@ in ''; }; - mailTo = mkOption { + mailTo = lib.mkOption { default = "root"; example = "you@domain.com"; - type = types.str; + type = lib.types.str; description = '' Email address to send reports to. ''; }; - level = mkOption { + level = lib.mkOption { default = "server"; - type = types.str; + type = lib.types.str; description = '' Set the logcheck level. Either "workstation", "server", or "paranoid". ''; }; - config = mkOption { + config = lib.mkOption { default = "FQDN=1"; - type = types.lines; + type = lib.types.lines; description = '' Config options that you would like in logcheck.conf. ''; }; - files = mkOption { + files = lib.mkOption { default = [ "/var/log/messages" ]; - type = types.listOf types.path; + type = lib.types.listOf lib.types.path; example = [ "/var/log/messages" "/var/log/mail" ]; description = '' Which log files to check. ''; }; - extraRulesDirs = mkOption { + extraRulesDirs = lib.mkOption { default = []; example = [ "/etc/logcheck" ]; - type = types.listOf types.path; + type = lib.types.listOf lib.types.path; description = '' Directories with extra rules. ''; }; - ignore = mkOption { + ignore = lib.mkOption { default = {}; description = '' This option defines extra ignore rules. ''; - type = with types; attrsOf (submodule ignoreOptions); + type = with lib.types; attrsOf (submodule ignoreOptions); }; - ignoreCron = mkOption { + ignoreCron = lib.mkOption { default = {}; description = '' This option defines extra ignore rules for cronjobs. ''; - type = with types; attrsOf (submodule ignoreCronOptions); + type = with lib.types; attrsOf (submodule ignoreCronOptions); }; - extraGroups = mkOption { + extraGroups = lib.mkOption { default = []; - type = types.listOf types.str; + type = lib.types.listOf lib.types.str; example = [ "postdrop" "mongodb" ]; description = '' Extra groups for the logcheck user, for example to be able to use sendmail, @@ -202,12 +199,12 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { services.logcheck.extraRulesDirs = - mapAttrsToList writeIgnoreRule cfg.ignore - ++ mapAttrsToList writeIgnoreCronRule cfg.ignoreCron; + lib.mapAttrsToList writeIgnoreRule cfg.ignore + ++ lib.mapAttrsToList writeIgnoreCronRule cfg.ignoreCron; - users.users = optionalAttrs (cfg.user == "logcheck") { + users.users = lib.optionalAttrs (cfg.user == "logcheck") { logcheck = { group = "logcheck"; isSystemUser = true; @@ -216,7 +213,7 @@ in extraGroups = cfg.extraGroups; }; }; - users.groups = optionalAttrs (cfg.user == "logcheck") { + users.groups = lib.optionalAttrs (cfg.user == "logcheck") { logcheck = {}; }; @@ -236,7 +233,7 @@ in mkCron = name: {user, cmdline, timeArgs, ...}: '' ${timeArgs} ${user} ${cmdline} ''; - in mapAttrsToList mkCron (filterAttrs withTime cfg.ignoreCron) + in lib.mapAttrsToList mkCron (lib.filterAttrs withTime cfg.ignoreCron) ++ [ cronJob ]; }; } From 5ba36926e63540cc63ff786e6ae85bd7dfbc115d Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:31 +0200 Subject: [PATCH 132/139] nixos/services.logrotate: remove `with lib;` --- nixos/modules/services/logging/logrotate.nix | 71 ++++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix index 9344277fc1e0..6db1b108cc6c 100644 --- a/nixos/modules/services/logging/logrotate.nix +++ b/nixos/modules/services/logging/logrotate.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, utils, ... }: - -with lib; - let cfg = config.services.logrotate; @@ -10,24 +7,24 @@ let else if builtins.elem n [ "frequency" ] then "${v}\n" else if builtins.elem n [ "firstaction" "lastaction" "prerotate" "postrotate" "preremove" ] then "${n}\n ${v}\n endscript\n" - else if isInt v then "${n} ${toString v}\n" + else if lib.isInt v then "${n} ${toString v}\n" else if v == true then "${n}\n" else if v == false then "no${n}\n" else "${n} ${v}\n"; - generateSection = indent: settings: concatStringsSep (fixedWidthString indent " " "") ( - filter (x: x != null) (mapAttrsToList generateLine settings) + generateSection = indent: settings: lib.concatStringsSep (lib.fixedWidthString indent " " "") ( + lib.filter (x: x != null) (lib.mapAttrsToList generateLine settings) ); # generateSection includes a final newline hence weird closing brace mkConf = settings: if settings.global or false then generateSection 0 settings else '' - ${concatMapStringsSep "\n" (files: ''"${files}"'') (toList settings.files)} { + ${lib.concatMapStringsSep "\n" (files: ''"${files}"'') (lib.toList settings.files)} { ${generateSection 2 settings}} ''; - settings = sortProperties (attrValues (filterAttrs (_: settings: settings.enable) ( - foldAttrs recursiveUpdate { } [ + settings = lib.sortProperties (lib.attrValues (lib.filterAttrs (_: settings: settings.enable) ( + lib.foldAttrs lib.recursiveUpdate { } [ { header = { enable = true; @@ -43,10 +40,10 @@ let ))); configFile = pkgs.writeTextFile { name = "logrotate.conf"; - text = concatStringsSep "\n" ( + text = lib.concatStringsSep "\n" ( map mkConf settings ); - checkPhase = optionalString cfg.checkConfig '' + checkPhase = lib.optionalString cfg.checkConfig '' # logrotate --debug also checks that users specified in config # file exist, but we only have sandboxed users here so brown these # out. according to man page that means su, create and createolddir. @@ -83,24 +80,24 @@ let }; mailOption = - optionalString (foldr (n: a: a || (n.mail or false) != false) false (attrValues cfg.settings)) + lib.optionalString (lib.foldr (n: a: a || (n.mail or false) != false) false (lib.attrValues cfg.settings)) "--mail=${pkgs.mailutils}/bin/mail"; in { imports = [ - (mkRemovedOptionModule [ "services" "logrotate" "config" ] "Modify services.logrotate.settings.header instead") - (mkRemovedOptionModule [ "services" "logrotate" "extraConfig" ] "Modify services.logrotate.settings.header instead") - (mkRemovedOptionModule [ "services" "logrotate" "paths" ] "Add attributes to services.logrotate.settings instead") + (lib.mkRemovedOptionModule [ "services" "logrotate" "config" ] "Modify services.logrotate.settings.header instead") + (lib.mkRemovedOptionModule [ "services" "logrotate" "extraConfig" ] "Modify services.logrotate.settings.header instead") + (lib.mkRemovedOptionModule [ "services" "logrotate" "paths" ] "Add attributes to services.logrotate.settings instead") ]; options = { services.logrotate = { - enable = mkEnableOption "the logrotate systemd service" // { - default = foldr (n: a: a || n.enable) false (attrValues cfg.settings); - defaultText = literalExpression "cfg.settings != {}"; + enable = lib.mkEnableOption "the logrotate systemd service" // { + default = lib.foldr (n: a: a || n.enable) false (lib.attrValues cfg.settings); + defaultText = lib.literalExpression "cfg.settings != {}"; }; - settings = mkOption { + settings = lib.mkOption { default = { }; description = '' logrotate freeform settings: each attribute here will define its own section, @@ -111,7 +108,7 @@ in as logrotate config directives, refer to for details. ''; - example = literalExpression '' + example = lib.literalExpression '' { # global options header = { @@ -138,24 +135,24 @@ in }; }; ''; - type = types.attrsOf (types.submodule ({ name, ... }: { - freeformType = with types; attrsOf (nullOr (oneOf [ int bool str ])); + type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: { + freeformType = with lib.types; attrsOf (nullOr (oneOf [ int bool str ])); options = { - enable = mkEnableOption "setting individual kill switch" // { + enable = lib.mkEnableOption "setting individual kill switch" // { default = true; }; - global = mkOption { - type = types.bool; + global = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether this setting is a global option or not: set to have these settings apply to all files settings with a higher priority. ''; }; - files = mkOption { - type = with types; either str (listOf str); + files = lib.mkOption { + type = with lib.types; either str (listOf str); default = name; defaultText = '' The attrset name if not specified @@ -168,8 +165,8 @@ in ''; }; - frequency = mkOption { - type = types.nullOr types.str; + frequency = lib.mkOption { + type = lib.types.nullOr lib.types.str; default = null; description = '' How often to rotate the logs. Defaults to previously set global setting, @@ -177,8 +174,8 @@ in ''; }; - priority = mkOption { - type = types.int; + priority = lib.mkOption { + type = lib.types.int; default = 1000; description = '' Order of this logrotate block in relation to the others. The semantics are @@ -190,8 +187,8 @@ in })); }; - configFile = mkOption { - type = types.path; + configFile = lib.mkOption { + type = lib.types.path; default = configFile; defaultText = '' A configuration file automatically generated by NixOS. @@ -200,7 +197,7 @@ in Override the configuration file used by logrotate. By default, NixOS generates one automatically from [](#opt-services.logrotate.settings). ''; - example = literalExpression '' + example = lib.literalExpression '' pkgs.writeText "logrotate.conf" ''' missingok "/var/log/*.log" { @@ -211,8 +208,8 @@ in ''; }; - checkConfig = mkOption { - type = types.bool; + checkConfig = lib.mkOption { + type = lib.types.bool; default = true; description = '' Whether the config should be checked at build time. @@ -240,7 +237,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.logrotate = { description = "Logrotate Service"; startAt = "hourly"; From 5b61b700823c3d5af23eb966c617a1ea86ba4017 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:31 +0200 Subject: [PATCH 133/139] nixos/services.logstash: remove `with lib;` --- nixos/modules/services/logging/logstash.nix | 67 ++++++++++----------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/nixos/modules/services/logging/logstash.nix b/nixos/modules/services/logging/logstash.nix index 53e2e91d6212..31f0eef77c46 100644 --- a/nixos/modules/services/logging/logstash.nix +++ b/nixos/modules/services/logging/logstash.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.logstash; ops = lib.optionalString; @@ -38,8 +35,8 @@ in { imports = [ - (mkRenamedOptionModule [ "services" "logstash" "address" ] [ "services" "logstash" "listenAddress" ]) - (mkRemovedOptionModule [ "services" "logstash" "enableWeb" ] "The web interface was removed from logstash") + (lib.mkRenamedOptionModule [ "services" "logstash" "address" ] [ "services" "logstash" "listenAddress" ]) + (lib.mkRemovedOptionModule [ "services" "logstash" "enableWeb" ] "The web interface was removed from logstash") ]; ###### interface @@ -48,23 +45,23 @@ in services.logstash = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = "Enable logstash."; }; - package = mkPackageOption pkgs "logstash" { }; + package = lib.mkPackageOption pkgs "logstash" { }; - plugins = mkOption { - type = types.listOf types.path; + plugins = lib.mkOption { + type = lib.types.listOf lib.types.path; default = [ ]; - example = literalExpression "[ pkgs.logstash-contrib ]"; + example = lib.literalExpression "[ pkgs.logstash-contrib ]"; description = "The paths to find other logstash plugins in."; }; - dataDir = mkOption { - type = types.str; + dataDir = lib.mkOption { + type = lib.types.str; default = "/var/lib/logstash"; description = '' A path to directory writable by logstash that it uses to store data. @@ -72,35 +69,35 @@ in ''; }; - logLevel = mkOption { - type = types.enum [ "debug" "info" "warn" "error" "fatal" ]; + logLevel = lib.mkOption { + type = lib.types.enum [ "debug" "info" "warn" "error" "fatal" ]; default = "warn"; description = "Logging verbosity level."; }; - filterWorkers = mkOption { - type = types.int; + filterWorkers = lib.mkOption { + type = lib.types.int; default = 1; description = "The quantity of filter workers to run."; }; - listenAddress = mkOption { - type = types.str; + listenAddress = lib.mkOption { + type = lib.types.str; default = "127.0.0.1"; description = "Address on which to start webserver."; }; - port = mkOption { - type = types.str; + port = lib.mkOption { + type = lib.types.str; default = "9292"; description = "Port on which to start webserver."; }; - inputConfig = mkOption { - type = types.lines; + inputConfig = lib.mkOption { + type = lib.types.lines; default = "generator { }"; description = "Logstash input configuration."; - example = literalExpression '' + example = lib.literalExpression '' ''' # Read from journal pipe { @@ -111,8 +108,8 @@ in ''; }; - filterConfig = mkOption { - type = types.lines; + filterConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = "logstash filter configuration."; example = '' @@ -129,8 +126,8 @@ in ''; }; - outputConfig = mkOption { - type = types.lines; + outputConfig = lib.mkOption { + type = lib.types.lines; default = "stdout { codec => rubydebug }"; description = "Logstash output configuration."; example = '' @@ -139,8 +136,8 @@ in ''; }; - extraSettings = mkOption { - type = types.lines; + extraSettings = lib.mkOption { + type = lib.types.lines; default = ""; description = "Extra Logstash settings in YAML format."; example = '' @@ -151,8 +148,8 @@ in ''; }; - extraJvmOptions = mkOption { - type = types.lines; + extraJvmOptions = lib.mkOption { + type = lib.types.lines; default = ""; description = "Extra JVM options, one per line (jvm.options format)."; example = '' @@ -167,17 +164,17 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.logstash = { description = "Logstash Daemon"; wantedBy = [ "multi-user.target" ]; path = [ pkgs.bash ]; serviceConfig = { ExecStartPre = ''${pkgs.coreutils}/bin/mkdir -p "${cfg.dataDir}" ; ${pkgs.coreutils}/bin/chmod 700 "${cfg.dataDir}"''; - ExecStart = concatStringsSep " " (filter (s: stringLength s != 0) [ + ExecStart = lib.concatStringsSep " " (lib.filter (s: lib.stringLength s != 0) [ "${cfg.package}/bin/logstash" "-w ${toString cfg.filterWorkers}" - (concatMapStringsSep " " (x: "--path.plugins ${x}") cfg.plugins) + (lib.concatMapStringsSep " " (x: "--path.plugins ${x}") cfg.plugins) "${verbosityFlag}" "-f ${logstashConf}" "--path.settings ${logstashSettingsDir}" From bb1483bbc63e9cb2e4b27a115627dcbc65afc111 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:31 +0200 Subject: [PATCH 134/139] nixos/services.rsyslogd: remove `with lib;` --- nixos/modules/services/logging/rsyslogd.nix | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/nixos/modules/services/logging/rsyslogd.nix b/nixos/modules/services/logging/rsyslogd.nix index 25b6eec5056c..88a8ff840682 100644 --- a/nixos/modules/services/logging/rsyslogd.nix +++ b/nixos/modules/services/logging/rsyslogd.nix @@ -1,7 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.rsyslogd; @@ -36,8 +33,8 @@ in services.rsyslogd = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable syslogd. Note that systemd also logs @@ -45,8 +42,8 @@ in ''; }; - defaultConfig = mkOption { - type = types.lines; + defaultConfig = lib.mkOption { + type = lib.types.lines; default = defaultConf; description = '' The default {file}`syslog.conf` file configures a @@ -55,8 +52,8 @@ in ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = "news.* -/var/log/news"; description = '' @@ -65,8 +62,8 @@ in ''; }; - extraParams = mkOption { - type = types.listOf types.str; + extraParams = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "-m 0" ]; description = '' @@ -81,7 +78,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { environment.systemPackages = [ pkgs.rsyslog ]; From b14d3ec28f8e27ed8280d8b5932122c814b5ea1a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:32 +0200 Subject: [PATCH 135/139] nixos/services.syslog-ng: remove `with lib;` --- nixos/modules/services/logging/syslog-ng.nix | 31 +++++++++----------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/nixos/modules/services/logging/syslog-ng.nix b/nixos/modules/services/logging/syslog-ng.nix index 14e18d3f0eef..d9d4b0cdb94a 100644 --- a/nixos/modules/services/logging/syslog-ng.nix +++ b/nixos/modules/services/logging/syslog-ng.nix @@ -1,7 +1,4 @@ { config, pkgs, lib, ... }: - -with lib; - let cfg = config.services.syslog-ng; @@ -17,7 +14,7 @@ let syslogngOptions = [ "--foreground" - "--module-path=${concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}" + "--module-path=${lib.concatStringsSep ":" (["${cfg.package}/lib/syslog-ng"] ++ cfg.extraModulePaths)}" "--cfgfile=${syslogngConfig}" "--control=${ctrlSocket}" "--persist-file=${persistFile}" @@ -26,23 +23,23 @@ let in { imports = [ - (mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "") - (mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "") + (lib.mkRemovedOptionModule [ "services" "syslog-ng" "serviceName" ] "") + (lib.mkRemovedOptionModule [ "services" "syslog-ng" "listenToJournal" ] "") ]; options = { services.syslog-ng = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable the syslog-ng daemon. ''; }; - package = mkPackageOption pkgs "syslogng" { }; - extraModulePaths = mkOption { - type = types.listOf types.str; + package = lib.mkPackageOption pkgs "syslogng" { }; + extraModulePaths = lib.mkOption { + type = lib.types.listOf lib.types.str; default = []; description = '' A list of paths that should be included in syslog-ng's @@ -50,15 +47,15 @@ in { end in `/lib/syslog-ng` ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; description = '' Configuration added to the end of `syslog-ng.conf`. ''; }; - configHeader = mkOption { - type = types.lines; + configHeader = lib.mkOption { + type = lib.types.lines; default = '' @version: 4.4 @include "scl.conf" @@ -71,7 +68,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.syslog-ng = { description = "syslog-ng daemon"; preStart = "mkdir -p /{var,run}/syslog-ng"; @@ -82,7 +79,7 @@ in { PIDFile = pidFile; StandardOutput = "null"; Restart = "on-failure"; - ExecStart = "${cfg.package}/sbin/syslog-ng ${concatStringsSep " " syslogngOptions}"; + ExecStart = "${cfg.package}/sbin/syslog-ng ${lib.concatStringsSep " " syslogngOptions}"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; }; }; From 12cf354b8384ac6bc7f24bc8fbf85e135a941d72 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:32 +0200 Subject: [PATCH 136/139] nixos/services.syslogd: remove `with lib;` --- nixos/modules/services/logging/syslogd.nix | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/nixos/modules/services/logging/syslogd.nix b/nixos/modules/services/logging/syslogd.nix index 8674fad69658..ad2d09b5a8de 100644 --- a/nixos/modules/services/logging/syslogd.nix +++ b/nixos/modules/services/logging/syslogd.nix @@ -1,13 +1,10 @@ { config, lib, pkgs, ... }: - -with lib; - let cfg = config.services.syslogd; syslogConf = pkgs.writeText "syslog.conf" '' - ${optionalString (cfg.tty != "") "kern.warning;*.err;authpriv.none /dev/${cfg.tty}"} + ${lib.optionalString (cfg.tty != "") "kern.warning;*.err;authpriv.none /dev/${cfg.tty}"} ${cfg.defaultConfig} ${cfg.extraConfig} ''; @@ -36,8 +33,8 @@ in services.syslogd = { - enable = mkOption { - type = types.bool; + enable = lib.mkOption { + type = lib.types.bool; default = false; description = '' Whether to enable syslogd. Note that systemd also logs @@ -45,8 +42,8 @@ in ''; }; - tty = mkOption { - type = types.str; + tty = lib.mkOption { + type = lib.types.str; default = "tty10"; description = '' The tty device on which syslogd will print important log @@ -54,8 +51,8 @@ in ''; }; - defaultConfig = mkOption { - type = types.lines; + defaultConfig = lib.mkOption { + type = lib.types.lines; default = defaultConf; description = '' The default {file}`syslog.conf` file configures a @@ -64,16 +61,16 @@ in ''; }; - enableNetworkInput = mkOption { - type = types.bool; + enableNetworkInput = lib.mkOption { + type = lib.types.bool; default = false; description = '' Accept logging through UDP. Option -r of syslogd(8). ''; }; - extraConfig = mkOption { - type = types.lines; + extraConfig = lib.mkOption { + type = lib.types.lines; default = ""; example = "news.* -/var/log/news"; description = '' @@ -82,8 +79,8 @@ in ''; }; - extraParams = mkOption { - type = types.listOf types.str; + extraParams = lib.mkOption { + type = lib.types.listOf lib.types.str; default = [ ]; example = [ "-m 0" ]; description = '' @@ -98,7 +95,7 @@ in ###### implementation - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { assertions = [ { assertion = !config.services.rsyslogd.enable; @@ -108,7 +105,7 @@ in environment.systemPackages = [ pkgs.sysklogd ]; - services.syslogd.extraParams = optional cfg.enableNetworkInput "-r"; + services.syslogd.extraParams = lib.optional cfg.enableNetworkInput "-r"; # FIXME: restarting syslog seems to break journal logging. systemd.services.syslog = From 640892113aa0a2ff0f2090fd49d0cc7ed8f608ca Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:32 +0200 Subject: [PATCH 137/139] nixos/services.ulogd: remove `with lib;` --- nixos/modules/services/logging/ulogd.nix | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nixos/modules/services/logging/ulogd.nix b/nixos/modules/services/logging/ulogd.nix index 5bd51ef88fe5..9d1d8e61231d 100644 --- a/nixos/modules/services/logging/ulogd.nix +++ b/nixos/modules/services/logging/ulogd.nix @@ -1,6 +1,4 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.ulogd; settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; }; @@ -8,9 +6,9 @@ let in { options = { services.ulogd = { - enable = mkEnableOption "ulogd, a userspace logging daemon for netfilter/iptables related logging"; + enable = lib.mkEnableOption "ulogd, a userspace logging daemon for netfilter/iptables related logging"; - settings = mkOption { + settings = lib.mkOption { example = { global.stack = [ "log1:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,print1:PRINTPKT,emu1:LOGEMU" @@ -35,8 +33,8 @@ in { "Configuration for ulogd. See {file}`/share/doc/ulogd/` in `pkgs.ulogd.doc`."; }; - logLevel = mkOption { - type = types.enum [ 1 3 5 7 8 ]; + logLevel = lib.mkOption { + type = lib.types.enum [ 1 3 5 7 8 ]; default = 5; description = "Log level (1 = debug, 3 = info, 5 = notice, 7 = error, 8 = fatal)"; @@ -44,7 +42,7 @@ in { }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { systemd.services.ulogd = { description = "Ulogd Daemon"; wantedBy = [ "multi-user.target" ]; From 28072b63dde295735a30087e0b293c37531cc256 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:33 +0200 Subject: [PATCH 138/139] nixos/services.vector: remove `with lib;` --- nixos/modules/services/logging/vector.nix | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/nixos/modules/services/logging/vector.nix b/nixos/modules/services/logging/vector.nix index 129a38b1d20f..c68d546bb96c 100644 --- a/nixos/modules/services/logging/vector.nix +++ b/nixos/modules/services/logging/vector.nix @@ -1,24 +1,22 @@ { config, lib, pkgs, ... }: - -with lib; let cfg = config.services.vector; in { options.services.vector = { - enable = mkEnableOption "Vector, a high-performance observability data pipeline"; + enable = lib.mkEnableOption "Vector, a high-performance observability data pipeline"; - package = mkPackageOption pkgs "vector" { }; + package = lib.mkPackageOption pkgs "vector" { }; - journaldAccess = mkOption { - type = types.bool; + journaldAccess = lib.mkOption { + type = lib.types.bool; default = false; description = '' Enable Vector to access journald. ''; }; - settings = mkOption { + settings = lib.mkOption { type = (pkgs.formats.json { }).type; default = { }; description = '' @@ -27,7 +25,7 @@ in }; }; - config = mkIf cfg.enable { + config = lib.mkIf cfg.enable { # for cli usage environment.systemPackages = [ pkgs.vector ]; @@ -49,14 +47,14 @@ in ''; in { - ExecStart = "${getExe cfg.package} --config ${validateConfig conf}"; + ExecStart = "${lib.getExe cfg.package} --config ${validateConfig conf}"; DynamicUser = true; Restart = "always"; StateDirectory = "vector"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; AmbientCapabilities = "CAP_NET_BIND_SERVICE"; # This group is required for accessing journald. - SupplementaryGroups = mkIf cfg.journaldAccess "systemd-journal"; + SupplementaryGroups = lib.mkIf cfg.journaldAccess "systemd-journal"; }; unitConfig = { StartLimitIntervalSec = 10; From 14dad27e70df3eb4ecb4cdc1af80ac09e34e7de4 Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Tue, 27 Aug 2024 20:43:33 +0200 Subject: [PATCH 139/139] nixos/services.prometheus.exporters: remove `with lib;` --- .../monitoring/prometheus/exporters.md | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/nixos/modules/services/monitoring/prometheus/exporters.md b/nixos/modules/services/monitoring/prometheus/exporters.md index d291020d3673..23464b9d315e 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.md +++ b/nixos/modules/services/monitoring/prometheus/exporters.md @@ -83,9 +83,6 @@ example: ```nix # nixpkgs/nixos/modules/services/prometheus/exporters/postfix.nix { config, lib, pkgs, options }: - - with lib; - let # for convenience we define cfg here cfg = config.services.prometheus.exporters.postfix; @@ -97,15 +94,15 @@ example: # (and optional overrides for default options). # Note that this attribute is optional. extraOpts = { - telemetryPath = mkOption { - type = types.str; + telemetryPath = lib.mkOption { + type = lib.types.str; default = "/metrics"; description = '' Path under which to expose metrics. ''; }; - logfilePath = mkOption { - type = types.path; + logfilePath = lib.mkOption { + type = lib.types.path; default = /var/log/postfix_exporter_input.log; example = /var/log/mail.log; description = '' @@ -113,8 +110,8 @@ example: This file will be truncated by this exporter! ''; }; - showqPath = mkOption { - type = types.path; + showqPath = lib.mkOption { + type = lib.types.path; default = /var/spool/postfix/public/showq; example = /var/lib/postfix/queue/public/showq; description = '' @@ -136,7 +133,7 @@ example: ${pkgs.prometheus-postfix-exporter}/bin/postfix_exporter \ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \ --web.telemetry-path ${cfg.telemetryPath} \ - ${concatStringsSep " \\\n " cfg.extraFlags} + ${lib.concatStringsSep " \\\n " cfg.extraFlags} ''; }; }; @@ -156,8 +153,6 @@ information about the change to the exporter definition similar to ```nix { config, lib, pkgs, options }: -with lib; - let cfg = config.services.prometheus.exporters.nginx; in @@ -173,10 +168,10 @@ in }; imports = [ # 'services.prometheus.exporters.nginx.telemetryEndpoint' -> 'services.prometheus.exporters.nginx.telemetryPath' - (mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ]) + (lib.mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ]) # removed option 'services.prometheus.exporters.nginx.insecure' - (mkRemovedOptionModule [ "insecure" ] '' + (lib.mkRemovedOptionModule [ "insecure" ] '' This option was replaced by 'prometheus.exporters.nginx.sslVerify' which defaults to true. '') ({ options.warnings = options.warnings; })