9 cfg = config.services.hadoop;
10 opt = options.services.hadoop;
19 options.services.hadoop = {
20 coreSite = lib.mkOption {
22 type = lib.types.attrsOf lib.types.anything;
23 example = lib.literalExpression ''
25 "fs.defaultFS" = "hdfs://localhost";
29 Hadoop core-site.xml definition
30 <https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/core-default.xml>
33 coreSiteInternal = lib.mkOption {
35 type = lib.types.attrsOf lib.types.anything;
38 Internal option to add configs to core-site.xml based on module options
42 hdfsSiteDefault = lib.mkOption {
44 "dfs.namenode.rpc-bind-host" = "0.0.0.0";
45 "dfs.namenode.http-address" = "0.0.0.0:9870";
46 "dfs.namenode.servicerpc-bind-host" = "0.0.0.0";
47 "dfs.namenode.http-bind-host" = "0.0.0.0";
49 type = lib.types.attrsOf lib.types.anything;
51 Default options for hdfs-site.xml
54 hdfsSite = lib.mkOption {
56 type = lib.types.attrsOf lib.types.anything;
57 example = lib.literalExpression ''
59 "dfs.nameservices" = "namenode1";
63 Additional options and overrides for hdfs-site.xml
64 <https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml>
67 hdfsSiteInternal = lib.mkOption {
69 type = lib.types.attrsOf lib.types.anything;
72 Internal option to add configs to hdfs-site.xml based on module options
76 mapredSiteDefault = lib.mkOption {
78 "mapreduce.framework.name" = "yarn";
79 "yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
80 "mapreduce.map.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
81 "mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
83 defaultText = lib.literalExpression ''
85 "mapreduce.framework.name" = "yarn";
86 "yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
87 "mapreduce.map.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
88 "mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
91 type = lib.types.attrsOf lib.types.anything;
93 Default options for mapred-site.xml
96 mapredSite = lib.mkOption {
98 type = lib.types.attrsOf lib.types.anything;
99 example = lib.literalExpression ''
101 "mapreduce.map.java.opts" = "-Xmx900m -XX:+UseParallelGC";
105 Additional options and overrides for mapred-site.xml
106 <https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml>
110 yarnSiteDefault = lib.mkOption {
112 "yarn.nodemanager.admin-env" = "PATH=$PATH";
113 "yarn.nodemanager.aux-services" = "mapreduce_shuffle";
114 "yarn.nodemanager.aux-services.mapreduce_shuffle.class" = "org.apache.hadoop.mapred.ShuffleHandler";
115 "yarn.nodemanager.bind-host" = "0.0.0.0";
116 "yarn.nodemanager.container-executor.class" =
117 "org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor";
118 "yarn.nodemanager.env-whitelist" =
119 "JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,LANG,TZ";
120 "yarn.nodemanager.linux-container-executor.group" = "hadoop";
121 "yarn.nodemanager.linux-container-executor.path" =
122 "/run/wrappers/yarn-nodemanager/bin/container-executor";
123 "yarn.nodemanager.log-dirs" = "/var/log/hadoop/yarn/nodemanager";
124 "yarn.resourcemanager.bind-host" = "0.0.0.0";
125 "yarn.resourcemanager.scheduler.class" =
126 "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler";
128 type = lib.types.attrsOf lib.types.anything;
130 Default options for yarn-site.xml
133 yarnSite = lib.mkOption {
135 type = lib.types.attrsOf lib.types.anything;
136 example = lib.literalExpression ''
138 "yarn.resourcemanager.hostname" = "''${config.networking.hostName}";
142 Additional options and overrides for yarn-site.xml
143 <https://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-common/yarn-default.xml>
146 yarnSiteInternal = lib.mkOption {
148 type = lib.types.attrsOf lib.types.anything;
151 Internal option to add configs to yarn-site.xml based on module options
155 httpfsSite = lib.mkOption {
157 type = lib.types.attrsOf lib.types.anything;
158 example = lib.literalExpression ''
160 "hadoop.http.max.threads" = 500;
164 Hadoop httpfs-site.xml definition
165 <https://hadoop.apache.org/docs/current/hadoop-hdfs-httpfs/httpfs-default.html>
169 log4jProperties = lib.mkOption {
170 default = "${cfg.package}/etc/hadoop/log4j.properties";
171 defaultText = lib.literalExpression ''
172 "''${config.${opt.package}}/etc/hadoop/log4j.properties"
174 type = lib.types.path;
175 example = lib.literalExpression ''
176 "''${pkgs.hadoop}/etc/hadoop/log4j.properties";
178 description = "log4j.properties file added to HADOOP_CONF_DIR";
181 containerExecutorCfg = lib.mkOption {
183 # must be the same as yarn.nodemanager.linux-container-executor.group in yarnSite
184 "yarn.nodemanager.linux-container-executor.group" = "hadoop";
185 "min.user.id" = 1000;
186 "feature.terminal.enabled" = 1;
187 "feature.mount-cgroup.enabled" = 1;
189 type = lib.types.attrsOf lib.types.anything;
190 example = lib.literalExpression ''
191 options.services.hadoop.containerExecutorCfg.default // {
192 "feature.terminal.enabled" = 0;
196 Yarn container-executor.cfg definition
197 <https://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/SecureContainer.html>
201 extraConfDirs = lib.mkOption {
203 type = lib.types.listOf lib.types.path;
204 example = lib.literalExpression ''
210 description = "Directories containing additional config files to be added to HADOOP_CONF_DIR";
213 gatewayRole.enable = lib.mkEnableOption "gateway role for deploying hadoop configs";
215 package = lib.mkPackageOption pkgs "hadoop" { };
218 config = lib.mkIf cfg.gatewayRole.enable {
219 users.groups.hadoop = {
220 gid = config.ids.gids.hadoop;
223 systemPackages = [ cfg.package ];
224 etc."hadoop-conf".source =
226 hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/";
229 variables.HADOOP_CONF_DIR = "/etc/hadoop-conf/";