2021-10-28 06:52:43 +00:00
|
|
|
{ cfg, pkgs, lib }:
|
2020-04-24 23:36:52 +00:00
|
|
|
let
|
2022-03-30 09:31:56 +00:00
|
|
|
propertyXml = name: value: lib.optionalString (value != null) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
<property>
|
|
|
|
<name>${name}</name>
|
|
|
|
<value>${builtins.toString value}</value>
|
|
|
|
</property>
|
|
|
|
'';
|
|
|
|
siteXml = fileName: properties: pkgs.writeTextDir fileName ''
|
|
|
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
|
|
<!-- generated by NixOS -->
|
|
|
|
<configuration>
|
|
|
|
${builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList propertyXml properties)}
|
|
|
|
</configuration>
|
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
cfgLine = name: value: ''
|
|
|
|
${name}=${builtins.toString value}
|
|
|
|
'';
|
|
|
|
cfgFile = fileName: properties: pkgs.writeTextDir fileName ''
|
|
|
|
# generated by NixOS
|
|
|
|
${builtins.concatStringsSep "" (pkgs.lib.mapAttrsToList cfgLine properties)}
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
userFunctions = ''
|
|
|
|
hadoop_verify_logdir() {
|
|
|
|
echo Skipping verification of log directory
|
|
|
|
}
|
|
|
|
'';
|
2021-10-28 06:52:43 +00:00
|
|
|
hadoopEnv = ''
|
|
|
|
export HADOOP_LOG_DIR=/tmp/hadoop/$USER
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
2022-03-30 09:31:56 +00:00
|
|
|
pkgs.runCommand "hadoop-conf" {} (with cfg; ''
|
2021-10-28 06:52:43 +00:00
|
|
|
mkdir -p $out/
|
2022-03-30 09:31:56 +00:00
|
|
|
cp ${siteXml "core-site.xml" (coreSite // coreSiteInternal)}/* $out/
|
|
|
|
cp ${siteXml "hdfs-site.xml" (hdfsSiteDefault // hdfsSite // hdfsSiteInternal)}/* $out/
|
|
|
|
cp ${siteXml "mapred-site.xml" (mapredSiteDefault // mapredSite)}/* $out/
|
|
|
|
cp ${siteXml "yarn-site.xml" (yarnSiteDefault // yarnSite // yarnSiteInternal)}/* $out/
|
|
|
|
cp ${siteXml "httpfs-site.xml" httpfsSite}/* $out/
|
|
|
|
cp ${cfgFile "container-executor.cfg" containerExecutorCfg}/* $out/
|
2021-10-28 06:52:43 +00:00
|
|
|
cp ${pkgs.writeTextDir "hadoop-user-functions.sh" userFunctions}/* $out/
|
|
|
|
cp ${pkgs.writeTextDir "hadoop-env.sh" hadoopEnv}/* $out/
|
2022-03-30 09:31:56 +00:00
|
|
|
cp ${log4jProperties} $out/log4j.properties
|
|
|
|
${lib.concatMapStringsSep "\n" (dir: "cp -r ${dir}/* $out/") extraConfDirs}
|
|
|
|
'')
|