{ hadoop, pkgs }:
let
propertyXml = name: value: ''
${name}
${builtins.toString value}
'';
siteXml = fileName: properties: pkgs.writeTextDir fileName ''
${builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList propertyXml properties)}
'';
userFunctions = ''
hadoop_verify_logdir() {
echo Skipping verification of log directory
}
'';
in
pkgs.buildEnv {
name = "hadoop-conf";
paths = [
(siteXml "core-site.xml" hadoop.coreSite)
(siteXml "hdfs-site.xml" hadoop.hdfsSite)
(siteXml "mapred-site.xml" hadoop.mapredSite)
(siteXml "yarn-site.xml" hadoop.yarnSite)
(pkgs.writeTextDir "hadoop-user-functions.sh" userFunctions)
];
}