From c1109e87b0539bba328f36117e5993f99c0fdb6f Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Sun, 8 Dec 2024 13:18:23 +0100 Subject: [PATCH] nixos/services.hadoop.yarn: remove `with lib;` --- .../modules/services/cluster/hadoop/yarn.nix | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/cluster/hadoop/yarn.nix b/nixos/modules/services/cluster/hadoop/yarn.nix index 0a7b4b7e67b0..77eb99636073 100644 --- a/nixos/modules/services/cluster/hadoop/yarn.nix +++ b/nixos/modules/services/cluster/hadoop/yarn.nix @@ -1,10 +1,9 @@ { config, lib, pkgs, ...}: -with lib; let cfg = config.services.hadoop; hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/"; - restartIfChanged = mkOption { - type = types.bool; + restartIfChanged = lib.mkOption { + type = lib.types.bool; description = '' Automatically restart the service on config change. This can be set to false to defer restarts on clusters running critical applications. @@ -13,8 +12,8 @@ let ''; default = false; }; - extraFlags = mkOption{ - type = with types; listOf str; + extraFlags = lib.mkOption{ + type = with lib.types; listOf str; default = []; description = "Extra command line flags to pass to the service"; example = [ @@ -22,8 +21,8 @@ let "-Dcom.sun.management.jmxremote.port=8010" ]; }; - extraEnv = mkOption{ - type = with types; attrsOf str; + extraEnv = lib.mkOption{ + type = with lib.types; attrsOf str; default = {}; description = "Extra environment variables"; }; @@ -31,11 +30,11 @@ in { options.services.hadoop.yarn = { resourcemanager = { - enable = mkEnableOption "Hadoop YARN ResourceManager"; + enable = lib.mkEnableOption "Hadoop YARN ResourceManager"; inherit restartIfChanged extraFlags extraEnv; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Open firewall ports for resourcemanager @@ -43,56 +42,56 @@ in }; }; nodemanager = { - enable = mkEnableOption "Hadoop YARN NodeManager"; + enable = lib.mkEnableOption "Hadoop YARN NodeManager"; inherit restartIfChanged extraFlags extraEnv; resource = { - cpuVCores = mkOption { + cpuVCores = lib.mkOption { description = "Number of vcores that can be allocated for containers."; - type = with types; nullOr ints.positive; + type = with lib.types; nullOr ints.positive; default = null; }; - maximumAllocationVCores = mkOption { + maximumAllocationVCores = lib.mkOption { description = "The maximum virtual CPU cores any container can be allocated."; - type = with types; nullOr ints.positive; + type = with lib.types; nullOr ints.positive; default = null; }; - memoryMB = mkOption { + memoryMB = lib.mkOption { description = "Amount of physical memory, in MB, that can be allocated for containers."; - type = with types; nullOr ints.positive; + type = with lib.types; nullOr ints.positive; default = null; }; - maximumAllocationMB = mkOption { + maximumAllocationMB = lib.mkOption { description = "The maximum physical memory any container can be allocated."; - type = with types; nullOr ints.positive; + type = with lib.types; nullOr ints.positive; default = null; }; }; - useCGroups = mkOption { - type = types.bool; + useCGroups = lib.mkOption { + type = lib.types.bool; default = true; description = '' Use cgroups to enforce resource limits on containers ''; }; - localDir = mkOption { + localDir = lib.mkOption { description = "List of directories to store localized files in."; - type = with types; nullOr (listOf path); + type = with lib.types; nullOr (listOf path); example = [ "/var/lib/hadoop/yarn/nm" ]; default = null; }; - addBinBash = mkOption { - type = types.bool; + addBinBash = lib.mkOption { + type = lib.types.bool; default = true; description = '' Add /bin/bash. This is needed by the linux container executor's launch script. ''; }; - openFirewall = mkOption { - type = types.bool; + openFirewall = lib.mkOption { + type = lib.types.bool; default = false; description = '' Open firewall ports for nodemanager. @@ -102,8 +101,8 @@ in }; }; - config = mkMerge [ - (mkIf cfg.gatewayRole.enable { + config = lib.mkMerge [ + (lib.mkIf cfg.gatewayRole.enable { users.users.yarn = { description = "Hadoop YARN user"; group = "hadoop"; @@ -111,7 +110,7 @@ in }; }) - (mkIf cfg.yarn.resourcemanager.enable { + (lib.mkIf cfg.yarn.resourcemanager.enable { systemd.services.yarn-resourcemanager = { description = "Hadoop YARN ResourceManager"; wantedBy = [ "multi-user.target" ]; @@ -122,14 +121,14 @@ in User = "yarn"; SyslogIdentifier = "yarn-resourcemanager"; ExecStart = "${cfg.package}/bin/yarn --config ${hadoopConf} " + - " resourcemanager ${escapeShellArgs cfg.yarn.resourcemanager.extraFlags}"; + " resourcemanager ${lib.escapeShellArgs cfg.yarn.resourcemanager.extraFlags}"; Restart = "always"; }; }; services.hadoop.gatewayRole.enable = true; - networking.firewall.allowedTCPPorts = (mkIf cfg.yarn.resourcemanager.openFirewall [ + networking.firewall.allowedTCPPorts = (lib.mkIf cfg.yarn.resourcemanager.openFirewall [ 8088 # resourcemanager.webapp.address 8030 # resourcemanager.scheduler.address 8031 # resourcemanager.resource-tracker.address @@ -138,11 +137,11 @@ in ]); }) - (mkIf cfg.yarn.nodemanager.enable { + (lib.mkIf cfg.yarn.nodemanager.enable { # Needed because yarn hardcodes /bin/bash in container start scripts # These scripts can't be patched, they are generated at runtime systemd.tmpfiles.rules = [ - (mkIf cfg.yarn.nodemanager.addBinBash "L /bin/bash - - - - /run/current-system/sw/bin/bash") + (lib.mkIf cfg.yarn.nodemanager.addBinBash "L /bin/bash - - - - /run/current-system/sw/bin/bash") ]; systemd.services.yarn-nodemanager = { @@ -171,7 +170,7 @@ in SyslogIdentifier = "yarn-nodemanager"; PermissionsStartOnly = true; ExecStart = "${cfg.package}/bin/yarn --config ${hadoopConf} " + - " nodemanager ${escapeShellArgs cfg.yarn.nodemanager.extraFlags}"; + " nodemanager ${lib.escapeShellArgs cfg.yarn.nodemanager.extraFlags}"; Restart = "always"; }; }; @@ -192,7 +191,7 @@ in })]; networking.firewall.allowedTCPPortRanges = [ - (mkIf (cfg.yarn.nodemanager.openFirewall) {from = 1024; to = 65535;}) + (lib.mkIf (cfg.yarn.nodemanager.openFirewall) {from = 1024; to = 65535;}) ]; })