diff --git a/nixos/modules/config/appstream.nix b/nixos/modules/config/appstream.nix index 1712273eff7db..edac18b9ba36c 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" diff --git a/nixos/modules/config/console.nix b/nixos/modules/config/console.nix index 5aadc0836fe76..9beb7dc587034 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. '') diff --git a/nixos/modules/config/debug-info.nix b/nixos/modules/config/debug-info.nix index 05a2fd2ceeea9..9bf3d82ace2a4 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. diff --git a/nixos/modules/config/fonts/fontdir.nix b/nixos/modules/config/fonts/fontdir.nix index 7b21fe30f607a..0181883d6c5c8 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" ]) ]; } diff --git a/nixos/modules/config/fonts/ghostscript.nix b/nixos/modules/config/fonts/ghostscript.nix index 5db7c0ac71799..dd28c72bba76e 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 ]; }; } diff --git a/nixos/modules/config/gtk/gtk-icon-cache.nix b/nixos/modules/config/gtk/gtk-icon-cache.nix index 0898260d4a599..d9d6031956a6a 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 # --------------------------- diff --git a/nixos/modules/config/iproute2.nix b/nixos/modules/config/iproute2.nix index 90f53c0eab695..1fa28a7a4c641 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; diff --git a/nixos/modules/config/locale.nix b/nixos/modules/config/locale.nix index 486246081ec69..2d64f1bce4bc2 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; diff --git a/nixos/modules/config/malloc.nix b/nixos/modules/config/malloc.nix index e414970b0be5a..665cbdd27874c 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} ''; diff --git a/nixos/modules/config/networking.nix b/nixos/modules/config/networking.nix index 72242b263ce01..8665a611e5757 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; }; diff --git a/nixos/modules/config/no-x-libs.nix b/nixos/modules/config/no-x-libs.nix index 2448d08a23997..e3fd0b34ddf4b 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; }; diff --git a/nixos/modules/config/nsswitch.nix b/nixos/modules/config/nsswitch.nix index fe0402ee9e666..71c79eafeb094 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" ]; }; }; } diff --git a/nixos/modules/config/power-management.nix b/nixos/modules/config/power-management.nix index 70f2d199df101..524a23edab64e 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"; diff --git a/nixos/modules/config/resolvconf.nix b/nixos/modules/config/resolvconf.nix index 002a06be39a35..9fee272410dc0 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 ]; diff --git a/nixos/modules/config/system-environment.nix b/nixos/modules/config/system-environment.nix index 3fd4ac730ab9c..ef49701fb4927 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 '' diff --git a/nixos/modules/config/system-path.nix b/nixos/modules/config/system-path.nix index 83353761b7b8a..6757078dbd9fc 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. diff --git a/nixos/modules/config/terminfo.nix b/nixos/modules/config/terminfo.nix index b538d749ffcbf..bf8bc43d6bb57 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 diff --git a/nixos/modules/config/unix-odbc-drivers.nix b/nixos/modules/config/unix-odbc-drivers.nix index 28cf7e84b7bc9..8bf7f3b28af6d 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; }; } diff --git a/nixos/modules/config/vte.nix b/nixos/modules/config/vte.nix index e0b48c3fb4a8b..a86a148b54f98 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; }) ]; diff --git a/nixos/modules/config/xdg/autostart.nix b/nixos/modules/config/xdg/autostart.nix index acdb7cd3adc69..6f33f592cf572 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" ]; diff --git a/nixos/modules/config/xdg/icons.nix b/nixos/modules/config/xdg/icons.nix index 3f198101d3066..9e2b3c2e46e08 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" diff --git a/nixos/modules/config/xdg/menus.nix b/nixos/modules/config/xdg/menus.nix index 8510c2db654eb..a71a46dd36cc4 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" diff --git a/nixos/modules/config/xdg/mime.nix b/nixos/modules/config/xdg/mime.nix index 2cd88be5b0235..9bd1af3970027 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; diff --git a/nixos/modules/config/xdg/portals/lxqt.nix b/nixos/modules/config/xdg/portals/lxqt.nix index 23a1622308bd2..846c9b1994371 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 = [ diff --git a/nixos/modules/config/xdg/portals/wlr.nix b/nixos/modules/config/xdg/portals/wlr.nix index 954830eff2d3a..ed09a31a86d76 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 ]; diff --git a/nixos/modules/config/xdg/sounds.nix b/nixos/modules/config/xdg/sounds.nix index 0aae77fe0107a..e19e23d72a476 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 ]; diff --git a/nixos/modules/hardware/acpilight.nix b/nixos/modules/hardware/acpilight.nix index 2de448a265c79..211d18ceb11a8 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 ]; }; diff --git a/nixos/modules/hardware/all-firmware.nix b/nixos/modules/hardware/all-firmware.nix index abad6e08611f0..6475cfc843d2a 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 ]; }) ]; diff --git a/nixos/modules/hardware/bladeRF.nix b/nixos/modules/hardware/bladeRF.nix index 35b74b8382e3a..877acbbf598c1 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 = {}; }; diff --git a/nixos/modules/hardware/brillo.nix b/nixos/modules/hardware/brillo.nix index 8e36022a9a307..915801c137be9 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 ]; }; diff --git a/nixos/modules/hardware/ckb-next.nix b/nixos/modules/hardware/ckb-next.nix index 1fb97c16d75f2..5de5666d20c96 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"; }; }; diff --git a/nixos/modules/hardware/corectrl.nix b/nixos/modules/hardware/corectrl.nix index 9e8b69cf62778..88b94e12f6b60 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 ]; diff --git a/nixos/modules/hardware/device-tree.nix b/nixos/modules/hardware/device-tree.nix index a29cc76ea8f96..b3feedf1edad1 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); diff --git a/nixos/modules/hardware/flipperzero.nix b/nixos/modules/hardware/flipperzero.nix index 3a6d29d0f9ebf..bda2e2c8e0a56 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 ]; }; diff --git a/nixos/modules/hardware/gkraken.nix b/nixos/modules/hardware/gkraken.nix index 97d15369db0a0..90b0069e80c8a 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 ]; diff --git a/nixos/modules/hardware/gpgsmartcards.nix b/nixos/modules/hardware/gpgsmartcards.nix index cc3f4c7699768..3940efd09e221 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 ]; }; } diff --git a/nixos/modules/hardware/i2c.nix b/nixos/modules/hardware/i2c.nix index b1e5cfd9e025b..4dd7a8ccc5310 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 ]; } diff --git a/nixos/modules/hardware/infiniband.nix b/nixos/modules/hardware/infiniband.nix index 6780aee9f36b7..b09453116cf97 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" diff --git a/nixos/modules/security/polkit.nix b/nixos/modules/security/polkit.nix index 76f623096fb76..eb783179af553 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} diff --git a/nixos/modules/services/admin/salt/master.nix b/nixos/modules/services/admin/salt/master.nix index c447540da1f80..1ffe6b6cb27aa 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 diff --git a/nixos/modules/services/amqp/rabbitmq.nix b/nixos/modules/services/amqp/rabbitmq.nix index b5aebaaf1275a..fba26591e0bae 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 ''} ''; diff --git a/nixos/modules/services/cluster/kubernetes/flannel.nix b/nixos/modules/services/cluster/kubernetes/flannel.nix index 93a460971055f..f0269cd0bc21e 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"; diff --git a/nixos/modules/services/continuous-integration/jenkins/default.nix b/nixos/modules/services/continuous-integration/jenkins/default.nix index a23120739b7fa..95372ec2bbf8f 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"; }; diff --git a/nixos/modules/services/continuous-integration/jenkins/job-builder.nix b/nixos/modules/services/continuous-integration/jenkins/job-builder.nix index 6400da13d3a84..ccad25cb92a73 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; diff --git a/nixos/modules/services/databases/couchdb.nix b/nixos/modules/services/databases/couchdb.nix index e007bfce77abf..22c9cfd918238 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} - -" diff --git a/nixos/modules/services/databases/dgraph.nix b/nixos/modules/services/databases/dgraph.nix index 00a11d6b686e5..20bc56df85a48 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 = { diff --git a/nixos/modules/services/databases/dragonflydb.nix b/nixos/modules/services/databases/dragonflydb.nix index 220605c8b475b..9024b584abc32 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; diff --git a/nixos/modules/services/databases/ferretdb.nix b/nixos/modules/services/databases/ferretdb.nix index ab55e22bf2146..a7e3fa81c48f1 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 }; }; } - diff --git a/nixos/modules/services/databases/firebird.nix b/nixos/modules/services/databases/firebird.nix index 17606218b6330..4b2b34ae7b1de 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]; diff --git a/nixos/modules/services/databases/hbase-standalone.nix b/nixos/modules/services/databases/hbase-standalone.nix index ac37e39329323..d3d2999eaeed5 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} - -" diff --git a/nixos/modules/services/databases/influxdb.nix b/nixos/modules/services/databases/influxdb.nix index 6dd4ca3b71cd6..9bc0b935d08f9 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; }; }; diff --git a/nixos/modules/services/databases/openldap.nix b/nixos/modules/services/databases/openldap.nix index feb974cdf6d37..20b1f03021f0c 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" ]; diff --git a/nixos/modules/services/databases/opentsdb.nix b/nixos/modules/services/databases/opentsdb.nix index e104c42f8b240..90268daec1d70 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"; diff --git a/nixos/modules/services/databases/pgmanage.nix b/nixos/modules/services/databases/pgmanage.nix index c405162ed87e0..fe3d1b5bfb9db 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 = { diff --git a/nixos/modules/services/databases/rethinkdb.nix b/nixos/modules/services/databases/rethinkdb.nix index c764d6c21c6ce..1b85fd1bb7bda 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"; }); diff --git a/nixos/modules/services/databases/surrealdb.nix b/nixos/modules/services/databases/surrealdb.nix index 2118312d5a1b5..b88129ebc6f42 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"; diff --git a/nixos/modules/services/desktops/blueman.nix b/nixos/modules/services/desktops/blueman.nix index 28c2daa7191db..4f02d288e2dfc 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 ]; diff --git a/nixos/modules/services/desktops/cpupower-gui.nix b/nixos/modules/services/desktops/cpupower-gui.nix index f66afc0a3dc17..ceed84da840ea 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 = { diff --git a/nixos/modules/services/desktops/deepin/app-services.nix b/nixos/modules/services/desktops/deepin/app-services.nix index 4702274df3740..7d99bd11802f0 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 = { diff --git a/nixos/modules/services/desktops/deepin/dde-api.nix b/nixos/modules/services/desktops/deepin/dde-api.nix index 36f9881fc766a..89889b3530c93 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 ]; diff --git a/nixos/modules/services/desktops/dleyna-renderer.nix b/nixos/modules/services/desktops/dleyna-renderer.nix index 7f88605f627c1..f36f1fbb1a4ec 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 ]; diff --git a/nixos/modules/services/desktops/dleyna-server.nix b/nixos/modules/services/desktops/dleyna-server.nix index 9a131a5e700f2..812110281ae49 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 ]; diff --git a/nixos/modules/services/desktops/flatpak.nix b/nixos/modules/services/desktops/flatpak.nix index b386bafcfe6f5..da07f602b3a07 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); diff --git a/nixos/modules/services/desktops/gsignond.nix b/nixos/modules/services/desktops/gsignond.nix index 465acd73fa64d..c21d3f0aafd85 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 ]; }; diff --git a/nixos/modules/services/desktops/neard.nix b/nixos/modules/services/desktops/neard.nix index 5459d2e5a1e55..5d67adc09870f 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 ]; diff --git a/nixos/modules/services/desktops/profile-sync-daemon.nix b/nixos/modules/services/desktops/profile-sync-daemon.nix index 6206295272fc5..48b29a59135c9 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 = { diff --git a/nixos/modules/services/desktops/system-config-printer.nix b/nixos/modules/services/desktops/system-config-printer.nix index 55f27b0e65340..6a8ff8dd19c60 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 diff --git a/nixos/modules/services/desktops/telepathy.nix b/nixos/modules/services/desktops/telepathy.nix index b5f6a5fcbcfdd..8f8adf7f4f83d 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 ]; diff --git a/nixos/modules/services/desktops/tumbler.nix b/nixos/modules/services/desktops/tumbler.nix index f5341df2f7a4f..a52767301949c 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 diff --git a/nixos/modules/services/development/distccd.nix b/nixos/modules/services/development/distccd.nix index 916c0905034c8..7eb9789b5c38c 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} ''; }; }; diff --git a/nixos/modules/services/development/hoogle.nix b/nixos/modules/services/development/hoogle.nix index 1747ef3912903..0a09a339e2bee 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; diff --git a/nixos/modules/services/development/jupyter/default.nix b/nixos/modules/services/development/jupyter/default.nix index 561ea86ea18bb..b3991fa4c2688 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"; diff --git a/nixos/modules/services/development/jupyter/kernel-options.nix b/nixos/modules/services/development/jupyter/kernel-options.nix index 8a91125e6cce0..421e1a0cf51dc 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 ''; diff --git a/nixos/modules/services/development/jupyterhub/default.nix b/nixos/modules/services/development/jupyterhub/default.nix index d9a37ad915d43..196d4aafabd4f 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"; diff --git a/nixos/modules/services/development/livebook.nix b/nixos/modules/services/development/livebook.nix index 8590836352013..3861d18e4ab5e 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" ]; diff --git a/nixos/modules/services/development/rstudio-server/default.nix b/nixos/modules/services/development/rstudio-server/default.nix index 0126e105b3d38..70f665b09e317 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"; diff --git a/nixos/modules/services/display-managers/greetd.nix b/nixos/modules/services/display-managers/greetd.nix index 118a3e1df378c..9774b6a4d12e8 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 ]; } diff --git a/nixos/modules/services/editors/emacs.nix b/nixos/modules/services/editors/emacs.nix index 98d8506e67278..ee1951e262228 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; diff --git a/nixos/modules/services/editors/haste.nix b/nixos/modules/services/editors/haste.nix index f2a40e62e718a..cf5bde6a58651 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"; }; }; }; diff --git a/nixos/modules/services/editors/infinoted.nix b/nixos/modules/services/editors/infinoted.nix index 2a7f1d45c2d86..b6e353b637e81 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 < ''; - 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 '') diff --git a/nixos/modules/services/games/crossfire-server.nix b/nixos/modules/services/games/crossfire-server.nix index 314b4bad9a292..91a684873c2aa 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 ]; }; }; diff --git a/nixos/modules/services/games/deliantra-server.nix b/nixos/modules/services/games/deliantra-server.nix index 401a453ba932d..0bb9cea92c7e0 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 ]; }; }; diff --git a/nixos/modules/services/games/freeciv.nix b/nixos/modules/services/games/freeciv.nix index e4c05af3cabae..fc73824e69207 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 ]; diff --git a/nixos/modules/services/games/minecraft-server.nix b/nixos/modules/services/games/minecraft-server.nix index 00af8dce66037..bc56feffb7485 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 ]; diff --git a/nixos/modules/services/games/minetest-server.nix b/nixos/modules/services/games/minetest-server.nix index 7fa687d2c7ed3..98613e4391efe 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"; diff --git a/nixos/modules/services/games/terraria.nix b/nixos/modules/services/games/terraria.nix index 4c32cc92a1b94..144186dc7701f 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 ]; }; diff --git a/nixos/modules/services/hardware/acpid.nix b/nixos/modules/services/hardware/acpid.nix index 581b6cb401362..357f692801b4f 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 = { diff --git a/nixos/modules/services/hardware/auto-cpufreq.nix b/nixos/modules/services/hardware/auto-cpufreq.nix index f61fa38be1759..ed24c656c5438 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 = { diff --git a/nixos/modules/services/hardware/bolt.nix b/nixos/modules/services/hardware/bolt.nix index 729273f94f12f..f005d24e08835 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 ]; diff --git a/nixos/modules/services/hardware/brltty.nix b/nixos/modules/services/hardware/brltty.nix index bdec5d79be967..c4ded927345d1 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"; diff --git a/nixos/modules/services/hardware/fancontrol.nix b/nixos/modules/services/hardware/fancontrol.nix index f9fc8593f8520..06c217b4d3c9b 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 ]; } diff --git a/nixos/modules/services/hardware/freefall.nix b/nixos/modules/services/hardware/freefall.nix index 4ac7c54d4d8a6..fe017bb17f7e4 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 ]; diff --git a/nixos/modules/services/hardware/fwupd.nix b/nixos/modules/services/hardware/fwupd.nix index bdbd0ac2440b2..09a55ad280527 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; diff --git a/nixos/modules/services/hardware/illum.nix b/nixos/modules/services/hardware/illum.nix index 7f7a850002342..61ab24a5de7c7 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"; diff --git a/nixos/modules/services/hardware/interception-tools.nix b/nixos/modules/services/hardware/interception-tools.nix index e69c05841ee01..d60e7ca595478 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; diff --git a/nixos/modules/services/hardware/irqbalance.nix b/nixos/modules/services/hardware/irqbalance.nix index c79e0eb83ecea..42878725cca3a 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 ]; diff --git a/nixos/modules/services/hardware/joycond.nix b/nixos/modules/services/hardware/joycond.nix index 106c19243c496..b6d2b8328af71 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 ]; diff --git a/nixos/modules/services/hardware/kanata.nix b/nixos/modules/services/hardware/kanata.nix index 60fb33881f256..67bcac6fe4432 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 ]; } diff --git a/nixos/modules/services/hardware/keyd.nix b/nixos/modules/services/hardware/keyd.nix index 2aee7817c6f3c..92b62fe2e9775 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 ) diff --git a/nixos/modules/services/hardware/lirc.nix b/nixos/modules/services/hardware/lirc.nix index 8103dbeb2d489..9942b9a97513a 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"; diff --git a/nixos/modules/services/hardware/openrgb.nix b/nixos/modules/services/hardware/openrgb.nix index 4dc521aa97800..0e06f9720ac10 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 ]; diff --git a/nixos/modules/services/hardware/pcscd.nix b/nixos/modules/services/hardware/pcscd.nix index 17bab2c5bf20c..df98c1fd208d1 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 ]; diff --git a/nixos/modules/services/hardware/pommed.nix b/nixos/modules/services/hardware/pommed.nix index 9cdb2d4d1af8a..c5efb76d6eece 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 = diff --git a/nixos/modules/services/hardware/rasdaemon.nix b/nixos/modules/services/hardware/rasdaemon.nix index 3fe75984b3fbe..ac3c675a7fbed 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 ]; } diff --git a/nixos/modules/services/hardware/ratbagd.nix b/nixos/modules/services/hardware/ratbagd.nix index 4398e8d582eaa..c7a6e9093b478 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 ]; diff --git a/nixos/modules/services/hardware/sane.nix b/nixos/modules/services/hardware/sane.nix index b6b36b6b60f46..98207ada78c39 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" ]; }; }) ]; diff --git a/nixos/modules/services/hardware/spacenavd.nix b/nixos/modules/services/hardware/spacenavd.nix index 69ca6f102efe7..c094393569988 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" ]; diff --git a/nixos/modules/services/hardware/tcsd.nix b/nixos/modules/services/hardware/tcsd.nix index e414b9647c9bb..24bb20b0146de 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 = {}; }; }; } diff --git a/nixos/modules/services/hardware/thermald.nix b/nixos/modules/services/hardware/thermald.nix index fb7cf3735a7ea..d7f706f1ef052 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 ''; diff --git a/nixos/modules/services/hardware/thinkfan.nix b/nixos/modules/services/hardware/thinkfan.nix index 37c9fef03d78d..9dd4c54342119 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"; diff --git a/nixos/modules/services/hardware/throttled.nix b/nixos/modules/services/hardware/throttled.nix index 143dc83a1d8b4..30f10b3361a60 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"; }; } diff --git a/nixos/modules/services/hardware/tlp.nix b/nixos/modules/services/hardware/tlp.nix index 148a88e2030f0..53e232a329125 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"; }; diff --git a/nixos/modules/services/hardware/triggerhappy.nix b/nixos/modules/services/hardware/triggerhappy.nix index 89f8754c0e686..d2137971b3a79 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*"; }; }; diff --git a/nixos/modules/services/hardware/tuxedo-rs.nix b/nixos/modules/services/hardware/tuxedo-rs.nix index 506454c1cadff..cfdc1c64d1183 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 ]; } diff --git a/nixos/modules/services/hardware/udev.nix b/nixos/modules/services/hardware/udev.nix index 67956fdd6c763..e3f356ade6788 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" ]) ]; } diff --git a/nixos/modules/services/hardware/udisks2.nix b/nixos/modules/services/hardware/udisks2.nix index 46a72b961501d..e52aa5a58df2d 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" ''; diff --git a/nixos/modules/services/hardware/undervolt.nix b/nixos/modules/services/hardware/undervolt.nix index 23bc848b2398f..1fce225db3669 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" ]; diff --git a/nixos/modules/services/hardware/upower.nix b/nixos/modules/services/hardware/upower.nix index 3d0edb0467ea7..bcc768cc05d3f 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; diff --git a/nixos/modules/services/hardware/usbmuxd.nix b/nixos/modules/services/hardware/usbmuxd.nix index 891619934eb6e..c1b76ddce3b71 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} = { }; }; diff --git a/nixos/modules/services/home-automation/matter-server.nix b/nixos/modules/services/home-automation/matter-server.nix index 08a68db71386e..8a59815eec66d 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" diff --git a/nixos/modules/services/home-automation/zigbee2mqtt.nix b/nixos/modules/services/home-automation/zigbee2mqtt.nix index f1d150487379d..5a9fb0eaebc10 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 = { diff --git a/nixos/modules/services/home-automation/zwave-js.nix b/nixos/modules/services/home-automation/zwave-js.nix index 2138719ec6fab..4ce7926242697 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"; diff --git a/nixos/modules/services/logging/SystemdJournal2Gelf.nix b/nixos/modules/services/logging/SystemdJournal2Gelf.nix index 7c50e9e2c42f5..5b2f05f8c0f15 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" ]; diff --git a/nixos/modules/services/logging/awstats.nix b/nixos/modules/services/logging/awstats.nix index a5b0e6347b2b8..d6d1fd64bd52a 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')" diff --git a/nixos/modules/services/logging/fluentd.nix b/nixos/modules/services/logging/fluentd.nix index bbf905eca06b2..fed5cacac37e3 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" ]; diff --git a/nixos/modules/services/logging/graylog.nix b/nixos/modules/services/logging/graylog.nix index caeac16815f42..ff1860e99a757 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} - - -" diff --git a/nixos/modules/services/logging/heartbeat.nix b/nixos/modules/services/logging/heartbeat.nix index 1a264cebf6a22..a9fa644d550df 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 - -" diff --git a/nixos/modules/services/logging/journalbeat.nix b/nixos/modules/services/logging/journalbeat.nix index e7d726ab1f612..5c35e84f88e09 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/."; diff --git a/nixos/modules/services/logging/journalwatch.nix b/nixos/modules/services/logging/journalwatch.nix index 48fd992ffb65a..ab75ed656c190 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; diff --git a/nixos/modules/services/logging/logcheck.nix b/nixos/modules/services/logging/logcheck.nix index bda7f9a607e14..d937a523c8661 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 ]; }; } diff --git a/nixos/modules/services/logging/logrotate.nix b/nixos/modules/services/logging/logrotate.nix index 9344277fc1e02..6db1b108cc6cd 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"; diff --git a/nixos/modules/services/logging/logstash.nix b/nixos/modules/services/logging/logstash.nix index 53e2e91d6212e..31f0eef77c461 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}" diff --git a/nixos/modules/services/logging/rsyslogd.nix b/nixos/modules/services/logging/rsyslogd.nix index 25b6eec5056ca..88a8ff840682e 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 ]; diff --git a/nixos/modules/services/logging/syslog-ng.nix b/nixos/modules/services/logging/syslog-ng.nix index 14e18d3f0eefd..d9d4b0cdb94a8 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"; }; }; diff --git a/nixos/modules/services/logging/syslogd.nix b/nixos/modules/services/logging/syslogd.nix index 8674fad69658c..ad2d09b5a8de6 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 = diff --git a/nixos/modules/services/logging/ulogd.nix b/nixos/modules/services/logging/ulogd.nix index 5bd51ef88fe53..9d1d8e61231dc 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" ]; diff --git a/nixos/modules/services/logging/vector.nix b/nixos/modules/services/logging/vector.nix index 129a38b1d20f0..c68d546bb96cd 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; diff --git a/nixos/modules/services/monitoring/prometheus/exporters.md b/nixos/modules/services/monitoring/prometheus/exporters.md index d291020d36733..23464b9d315ef 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; })