summary refs log tree commit diff
path: root/nixos/modules/services/cluster/hadoop/conf.nix
blob: 0caec5cfc203f90e6bfcc6ff921409d665e7f7b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{ cfg, pkgs, lib }:
let
  propertyXml = name: value: ''
    <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>
  '';
  cfgLine = name: value: ''
    ${name}=${builtins.toString value}
  '';
  cfgFile = fileName: properties: pkgs.writeTextDir fileName ''
    # generated by NixOS
    ${builtins.concatStringsSep "" (pkgs.lib.mapAttrsToList cfgLine properties)}
  '';
  userFunctions = ''
    hadoop_verify_logdir() {
      echo Skipping verification of log directory
    }
  '';
  hadoopEnv = ''
    export HADOOP_LOG_DIR=/tmp/hadoop/$USER
  '';
in
pkgs.runCommand "hadoop-conf" {} ''
  mkdir -p $out/
  cp ${siteXml "core-site.xml" cfg.coreSite}/* $out/
  cp ${siteXml "hdfs-site.xml" cfg.hdfsSite}/* $out/
  cp ${siteXml "mapred-site.xml" cfg.mapredSite}/* $out/
  cp ${siteXml "yarn-site.xml" cfg.yarnSite}/* $out/
  cp ${siteXml "httpfs-site.xml" cfg.httpfsSite}/* $out/
  cp ${cfgFile "container-executor.cfg" cfg.containerExecutorCfg}/* $out/
  cp ${pkgs.writeTextDir "hadoop-user-functions.sh" userFunctions}/* $out/
  cp ${pkgs.writeTextDir "hadoop-env.sh" hadoopEnv}/* $out/
  cp ${cfg.log4jProperties} $out/log4j.properties
  ${lib.concatMapStringsSep "\n" (dir: "cp -r ${dir}/* $out/") cfg.extraConfDirs}
''