at 25.11-pre 1.9 kB view raw
1{ 2 cfg, 3 pkgs, 4 lib, 5}: 6let 7 propertyXml = 8 name: value: 9 lib.optionalString (value != null) '' 10 <property> 11 <name>${name}</name> 12 <value>${builtins.toString value}</value> 13 </property> 14 ''; 15 siteXml = 16 fileName: properties: 17 pkgs.writeTextDir fileName '' 18 <?xml version="1.0" encoding="UTF-8" standalone="no"?> 19 <!-- generated by NixOS --> 20 <configuration> 21 ${builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList propertyXml properties)} 22 </configuration> 23 ''; 24 cfgLine = name: value: '' 25 ${name}=${builtins.toString value} 26 ''; 27 cfgFile = 28 fileName: properties: 29 pkgs.writeTextDir fileName '' 30 # generated by NixOS 31 ${builtins.concatStringsSep "" (pkgs.lib.mapAttrsToList cfgLine properties)} 32 ''; 33 userFunctions = '' 34 hadoop_verify_logdir() { 35 echo Skipping verification of log directory 36 } 37 ''; 38 hadoopEnv = '' 39 export HADOOP_LOG_DIR=/tmp/hadoop/$USER 40 ''; 41in 42pkgs.runCommand "hadoop-conf" { } ( 43 with cfg; 44 '' 45 mkdir -p $out/ 46 cp ${siteXml "core-site.xml" (coreSite // coreSiteInternal)}/* $out/ 47 cp ${siteXml "hdfs-site.xml" (hdfsSiteDefault // hdfsSite // hdfsSiteInternal)}/* $out/ 48 cp ${siteXml "hbase-site.xml" (hbaseSiteDefault // hbaseSite // hbaseSiteInternal)}/* $out/ 49 cp ${siteXml "mapred-site.xml" (mapredSiteDefault // mapredSite)}/* $out/ 50 cp ${siteXml "yarn-site.xml" (yarnSiteDefault // yarnSite // yarnSiteInternal)}/* $out/ 51 cp ${siteXml "httpfs-site.xml" httpfsSite}/* $out/ 52 cp ${cfgFile "container-executor.cfg" containerExecutorCfg}/* $out/ 53 cp ${pkgs.writeTextDir "hadoop-user-functions.sh" userFunctions}/* $out/ 54 cp ${pkgs.writeTextDir "hadoop-env.sh" hadoopEnv}/* $out/ 55 cp ${log4jProperties} $out/log4j.properties 56 ${lib.concatMapStringsSep "\n" (dir: "cp -f -r ${dir}/* $out/") extraConfDirs} 57 '' 58)