1 { config, lib, options, pkgs, ...}:
3 cfg = config.services.hadoop;
4 opt = options.services.hadoop;
8 imports = [ ./yarn.nix ./hdfs.nix ./hbase.nix ];
10 options.services.hadoop = {
13 type = types.attrsOf types.anything;
14 example = literalExpression ''
16 "fs.defaultFS" = "hdfs://localhost";
20 Hadoop core-site.xml definition
21 <https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/core-default.xml>
24 coreSiteInternal = mkOption {
26 type = types.attrsOf types.anything;
29 Internal option to add configs to core-site.xml based on module options
33 hdfsSiteDefault = mkOption {
35 "dfs.namenode.rpc-bind-host" = "0.0.0.0";
36 "dfs.namenode.http-address" = "0.0.0.0:9870";
37 "dfs.namenode.servicerpc-bind-host" = "0.0.0.0";
38 "dfs.namenode.http-bind-host" = "0.0.0.0";
40 type = types.attrsOf types.anything;
42 Default options for hdfs-site.xml
47 type = types.attrsOf types.anything;
48 example = literalExpression ''
50 "dfs.nameservices" = "namenode1";
54 Additional options and overrides for hdfs-site.xml
55 <https://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/hdfs-default.xml>
58 hdfsSiteInternal = mkOption {
60 type = types.attrsOf types.anything;
63 Internal option to add configs to hdfs-site.xml based on module options
67 mapredSiteDefault = mkOption {
69 "mapreduce.framework.name" = "yarn";
70 "yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
71 "mapreduce.map.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
72 "mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=${cfg.package}";
74 defaultText = literalExpression ''
76 "mapreduce.framework.name" = "yarn";
77 "yarn.app.mapreduce.am.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
78 "mapreduce.map.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
79 "mapreduce.reduce.env" = "HADOOP_MAPRED_HOME=''${config.${opt.package}}";
82 type = types.attrsOf types.anything;
84 Default options for mapred-site.xml
87 mapredSite = mkOption {
89 type = types.attrsOf types.anything;
90 example = literalExpression ''
92 "mapreduce.map.java.opts" = "-Xmx900m -XX:+UseParallelGC";
96 Additional options and overrides for mapred-site.xml
97 <https://hadoop.apache.org/docs/current/hadoop-mapreduce-client/hadoop-mapreduce-client-core/mapred-default.xml>
101 yarnSiteDefault = mkOption {
103 "yarn.nodemanager.admin-env" = "PATH=$PATH";
104 "yarn.nodemanager.aux-services" = "mapreduce_shuffle";
105 "yarn.nodemanager.aux-services.mapreduce_shuffle.class" = "org.apache.hadoop.mapred.ShuffleHandler";
106 "yarn.nodemanager.bind-host" = "0.0.0.0";
107 "yarn.nodemanager.container-executor.class" = "org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor";
108 "yarn.nodemanager.env-whitelist" = "JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_HOME,LANG,TZ";
109 "yarn.nodemanager.linux-container-executor.group" = "hadoop";
110 "yarn.nodemanager.linux-container-executor.path" = "/run/wrappers/yarn-nodemanager/bin/container-executor";
111 "yarn.nodemanager.log-dirs" = "/var/log/hadoop/yarn/nodemanager";
112 "yarn.resourcemanager.bind-host" = "0.0.0.0";
113 "yarn.resourcemanager.scheduler.class" = "org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler";
115 type = types.attrsOf types.anything;
117 Default options for yarn-site.xml
120 yarnSite = mkOption {
122 type = types.attrsOf types.anything;
123 example = literalExpression ''
125 "yarn.resourcemanager.hostname" = "''${config.networking.hostName}";
129 Additional options and overrides for yarn-site.xml
130 <https://hadoop.apache.org/docs/current/hadoop-yarn/hadoop-yarn-common/yarn-default.xml>
133 yarnSiteInternal = mkOption {
135 type = types.attrsOf types.anything;
138 Internal option to add configs to yarn-site.xml based on module options
142 httpfsSite = mkOption {
144 type = types.attrsOf types.anything;
145 example = literalExpression ''
147 "hadoop.http.max.threads" = 500;
151 Hadoop httpfs-site.xml definition
152 <https://hadoop.apache.org/docs/current/hadoop-hdfs-httpfs/httpfs-default.html>
156 log4jProperties = mkOption {
157 default = "${cfg.package}/etc/hadoop/log4j.properties";
158 defaultText = literalExpression ''
159 "''${config.${opt.package}}/etc/hadoop/log4j.properties"
162 example = literalExpression ''
163 "''${pkgs.hadoop}/etc/hadoop/log4j.properties";
165 description = "log4j.properties file added to HADOOP_CONF_DIR";
168 containerExecutorCfg = mkOption {
170 # must be the same as yarn.nodemanager.linux-container-executor.group in yarnSite
171 "yarn.nodemanager.linux-container-executor.group"="hadoop";
173 "feature.terminal.enabled"=1;
174 "feature.mount-cgroup.enabled" = 1;
176 type = types.attrsOf types.anything;
177 example = literalExpression ''
178 options.services.hadoop.containerExecutorCfg.default // {
179 "feature.terminal.enabled" = 0;
183 Yarn container-executor.cfg definition
184 <https://hadoop.apache.org/docs/r2.7.2/hadoop-yarn/hadoop-yarn-site/SecureContainer.html>
188 extraConfDirs = mkOption {
190 type = types.listOf types.path;
191 example = literalExpression ''
197 description = "Directories containing additional config files to be added to HADOOP_CONF_DIR";
200 gatewayRole.enable = mkEnableOption "gateway role for deploying hadoop configs";
202 package = mkPackageOption pkgs "hadoop" { };
206 config = mkIf cfg.gatewayRole.enable {
207 users.groups.hadoop = {
208 gid = config.ids.gids.hadoop;
211 systemPackages = [ cfg.package ];
212 etc."hadoop-conf".source = let
213 hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/";
215 variables.HADOOP_CONF_DIR = "/etc/hadoop-conf/";