default.nix 9.28 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1
{ # host package set (unused except for fetching nixpkgs)
Valentin Reis's avatar
Valentin Reis committed
2
  hostPkgs         ? import <nixpkgs> {}
Valentin Reis's avatar
Valentin Reis committed
3
4

, # versioned nixpkgs
Valentin Reis's avatar
Valentin Reis committed
5
  pkgs             ? import (hostPkgs.nix-update-source.fetch ./pkgs.json).src {}
Valentin Reis's avatar
Valentin Reis committed
6

Valentin Reis's avatar
Valentin Reis committed
7
, # versioned nixpkgs-older version for zmcat
Valentin Reis's avatar
Valentin Reis committed
8
  pkgs-old         ? import (hostPkgs.nix-update-source.fetch ./pkgs-old.json).src {}
Valentin Reis's avatar
Valentin Reis committed
9

Valentin Reis's avatar
Valentin Reis committed
10
, # fetcher alias for the remaining arguments
Valentin Reis's avatar
Valentin Reis committed
11
  fetched          ? s: (pkgs.nix-update-source.fetch s).src
Valentin Reis's avatar
Valentin Reis committed
12
13

, #source overrides: core nrm components
Valentin Reis's avatar
Valentin Reis committed
14
  aml-src          ? fetched aml/pin.json
Valentin Reis's avatar
Valentin Reis committed
15
, numabench-src    ? fetched numabench/pin.json
Valentin Reis's avatar
Valentin Reis committed
16
17
18
, libnrm-src       ? fetched libnrm/pin.json
, nrm-src          ? fetched nrm/pin.json
, containers-src   ? fetched containers/pin.json
Valentin Reis's avatar
Valentin Reis committed
19
20

, #source overrides: applications
Valentin Reis's avatar
Valentin Reis committed
21
22
23
24
25
  amg-src          ? fetched amg/pin.json
, qmcpack-src      ? fetched qmcpack/pin.json
, openmc-src       ? fetched openmc/pin.json
, stream-src       ? fetched stream/pin.json
, lammps-src       ? fetched lammps/pin.json
Valentin Reis's avatar
Valentin Reis committed
26

Valentin Reis's avatar
Valentin Reis committed
27
, #source overrides: tooling
28
29
30
  argotk-src       ? builtins.fetchGit {inherit (fetched argotk/pin.json) url rev;}
, repoquality-src  ? builtins.fetchGit {inherit (fetched repoquality/pin.json) url rev;}
, argonix-src      ? builtins.fetchGit {inherit (fetched argonix/pin.json) url rev;}
Valentin Reis's avatar
Valentin Reis committed
31
, experiments-src  ? fetched experiments/pin.json
32
33

, #used for hardware experiments.
Valentin Reis's avatar
Valentin Reis committed
34
  sudoPath         ? null
Valentin Reis's avatar
Valentin Reis committed
35

Valentin Reis's avatar
Valentin Reis committed
36
37
, #whether to graft apps on libnrm.
  graftLibnrm      ? false
Valentin Reis's avatar
.  
Valentin Reis committed
38
39
}:
let
Valentin Reis's avatar
Valentin Reis committed
40
  callPackage = pkgs.lib.callPackageWith (pkgs // argopkgs);
41

Valentin Reis's avatar
Valentin Reis committed
42
  argopkgs = rec {
43
    # library of nix expressions
Valentin Reis's avatar
style.    
Valentin Reis committed
44
    argolib       = import ../lib/utils.nix;
45
    # Argo components (source overridabel via argument)
Valentin Reis's avatar
Valentin Reis committed
46
    aml           = callPackage ./aml        {src=aml-src;};
Valentin Reis's avatar
Valentin Reis committed
47
    numabench     = callPackage ./numabench  {src=numabench-src; hwloc = hwloc2;};
Valentin Reis's avatar
Valentin Reis committed
48
49
50
51
52
    nrm           = callPackage ./nrm        {src=nrm-src;};
    containers    = callPackage ./containers {src=containers-src;};
    libnrm        = callPackage ./libnrm     {src=libnrm-src;};
    libnrm-pinned = callPackage ./libnrm     {src=fetched libnrm/pin.json;};
    libnrm-pmpi   = libnrm.overrideAttrs (oldAttrs: rec {
Valentin Reis's avatar
Valentin Reis committed
53
54
55
      configureFlags = "--enable-pmpi";
      buildInputs = oldAttrs.buildInputs ++ [ pkgs.mpich2 ];
    });
56

Valentin Reis's avatar
Valentin Reis committed
57
58
59
    # applications with replaceDependency for libnrm.
    repLibnrm = path: src: extra:
    let
Valentin Reis's avatar
Valentin Reis committed
60
      drv = callPackage path ({
Valentin Reis's avatar
style.    
Valentin Reis committed
61
62
63
        nrmSupport = true;
        src = src;
        libnrm = libnrm-pinned;
Valentin Reis's avatar
Valentin Reis committed
64
      }//extra);
Valentin Reis's avatar
style.    
Valentin Reis committed
65
      rebuilt = drv.override {libnrm = libnrm;};
Valentin Reis's avatar
Valentin Reis committed
66
67
68
69
70
71
      grafted = pkgs.replaceDependency {
        drv = drv;
        oldDependency = libnrm-pinned;
        newDependency = libnrm;
      };
    in if graftLibnrm then grafted else rebuilt;
Valentin Reis's avatar
Valentin Reis committed
72
73
74
75
    amg          = repLibnrm ./amg     amg-src     {};
    qmcpack      = repLibnrm ./qmcpack qmcpack-src {};
    openmc       = repLibnrm ./openmc  openmc-src  {};
    lammps       = repLibnrm ./lammps  lammps-src  {};
Valentin Reis's avatar
Valentin Reis committed
76
    stream       = repLibnrm ./stream  stream-src  {iterationCount="2000";};
Valentin Reis's avatar
Valentin Reis committed
77

78
    # data (static, non source overridable via arguments)
Valentin Reis's avatar
Valentin Reis committed
79
    openmc-data = fetched openmc/data.json;
Valentin Reis's avatar
Valentin Reis committed
80

81
82
83
84
    # tools
    zymake = callPackage ./zymake {
      inherit (pkgs.ocamlPackages) findlib ocamlbuild topkg batteries;
    };
Valentin Reis's avatar
Valentin Reis committed
85
86
    haskellPackages = pkgs.haskellPackages.override {
      overrides = self: super: with pkgs.haskell.lib;
Valentin Reis's avatar
Valentin Reis committed
87
      rec {
Valentin Reis's avatar
Valentin Reis committed
88
        panpipe        = (pkgs.haskell.lib.doJailbreak super.panpipe);
Valentin Reis's avatar
Valentin Reis committed
89
        spdx           = (pkgs.haskell.lib.doJailbreak super.spdx);
Valentin Reis's avatar
Valentin Reis committed
90
        generic-pretty = doJailbreak super.generic-pretty;
Valentin Reis's avatar
Valentin Reis committed
91

Valentin Reis's avatar
Valentin Reis committed
92
93
94
95
96
        #minor cabal and version fix
        panhandle    = (self.callCabal2nix "panhandle" (builtins.fetchGit {
                      inherit (panhandle-src) url rev; })) {};

        #argo tools
Valentin Reis's avatar
Valentin Reis committed
97
98
99
        argotk = (self.callCabal2nix "argotk" argotk-src) {};
        argonix = (self.callCabal2nix "argonix" argonix-src) {};
        repoquality = (self.callCabal2nix "repoquality" repoquality-src) {};
100
      };
Valentin Reis's avatar
Valentin Reis committed
101
    };
Valentin Reis's avatar
Valentin Reis committed
102

103
    # re-export from hpkgs and add non-haskell build rule specialization
Valentin Reis's avatar
Valentin Reis committed
104
105
106
    inherit (haskellPackages) repoquality;

    argotk = haskellPackages.argotk.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
107
108
109
110
111
112
113
114
115
116
117
118
        buildInputs=old.buildInputs ++ [pkgs.hwloc];
        installPhase = old.installPhase + ''
          mkdir $out/share/
          ARGOTK_SHARE=share $out/bin/argotk --bash-completion-script argotk > $out/share/argotk.sh
          cp -r share/* $out/share/
          substituteInPlace $out/share/simple-H2O.xml --replace \
                H2O.HF.wfs.xml $out/share/H2O.HF.wfs.xml
          substituteInPlace $out/share/simple-H2O.xml --replace \
                O.BFD.xml $out/share/O.BFD.xml
          substituteInPlace $out/share/simple-H2O.xml --replace \
                H.BFD.xml $out/share/H.BFD.xml
        '';
Valentin Reis's avatar
Valentin Reis committed
119
120
121
122
123
124
125
126
      });

    argonix = haskellPackages.argonix.overrideAttrs (old:{
        installPhase = old.installPhase + ''
          mkdir $out/share/
          $out/bin/argonix --bash-completion-script argonix > $out/share/argonix.sh
        '';
      });
127

128
    # fix for nrm
Valentin Reis's avatar
Valentin Reis committed
129
    pyzmq = pkgs.pythonPackages.pyzmq.override { zeromq3 = pkgs.zeromq; };
Valentin Reis's avatar
Valentin Reis committed
130

Valentin Reis's avatar
Valentin Reis committed
131
132
133
134
135
136
137
    hwloc2 = pkgs.hwloc.overrideAttrs (old:{
      src = pkgs.fetchurl {
        url = "https://download.open-mpi.org/release/hwloc/v2.0/hwloc-2.0.3.tar.gz";
        sha256 = "0707ml34ylrr8zwwhddp64q6q57248m9646f27jadcx5m93g5pk4";
      };
    });

138
    # archived for sake of the simplicity of this file
Valentin Reis's avatar
Valentin Reis committed
139
140
    zmcat = pkgs-old.haskellPackages.callPackage ./zmcat {};
    zmqat = pkgs-old.haskellPackages.zmqat;
141

142
    # ci/experimental environments
Valentin Reis's avatar
Valentin Reis committed
143
144
    test = pkgs.stdenv.mkDerivation rec {
      name = "testEnv";
145

Valentin Reis's avatar
Valentin Reis committed
146
147
148
149
150
151
152
153
154
155
156
157
158
159
      buildInputs = [
        # argotk runs mpiexec:
        pkgs.mpich2
        # argotk uses hwloc to choose CPU counts:
        pkgs.hwloc
        # these are needed for some reason:
        pkgs.coreutils
        pkgs.utillinux
        pkgs.git
        # argo tools
        argotk
        # argo components
        containers
        nrm
Valentin Reis's avatar
Valentin Reis committed
160
      ];
161

Valentin Reis's avatar
Valentin Reis committed
162
      #required to be able to build the drv.
163
      installPhase = "mkdir $out";
Valentin Reis's avatar
Valentin Reis committed
164
      unpackPhase = "true";
Valentin Reis's avatar
Valentin Reis committed
165

166
167
168
169
170
171
172
      __noChroot = true;
      shellHook =''
        echo ""
        echo "ENTERING ENVIRONMENT: Sources of impurity for this build are: /tmp/ /etc/argo/ /var/run/ /var/lock/".
        echo "ENTERING ENVIRONMENT: Moreover, sandboxing is disabled, in particular because of:"
        echo "ENTERING ENVIRONMENT: /tmp/nrm-* sockets, /etc/argo, /var/run/, /var/lock/ which all need read access. "
        echo "ENTERING ENVIRONMENT: until these components are patched to allow for alternative paths, no sandbox use is possible."
173
        source ${argotk}/share/argotk.sh # bash completion
174
        echo ""
175
      '';
176
      #argotk uses this environment variable.
177
      ARGOTK_SHARE = "${argotk}/share";
Valentin Reis's avatar
Valentin Reis committed
178
179
      OPENMC_CROSS_SECTIONS = "${openmc-data}/cross_sections.xml";
      OPENMC_PWD = "${argotk}/share/openmc";
Valentin Reis's avatar
Valentin Reis committed
180
    };
Valentin Reis's avatar
Valentin Reis committed
181

Valentin Reis's avatar
Valentin Reis committed
182
    testApplications = test.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
183
      name = "testEnv-with-applications";
184
      buildInputs = old.buildInputs ++ [
Valentin Reis's avatar
Valentin Reis committed
185
186
187
188
189
190
191
192
        lammps
        qmcpack
        openmc
        stream
        amg
        openmc-data
      ];
    });
Valentin Reis's avatar
Valentin Reis committed
193

194
    powerexpe = testApplications.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
195
196
      name = "power-experiments";
      buildInputs = old.buildInputs ++ [
197
198
        #debug tools
        pkgs.which
Valentin Reis's avatar
Valentin Reis committed
199
        #pkgs.sudo
Valentin Reis's avatar
Valentin Reis committed
200
        zmcat
201
202
203

        #experiment tools
        zymake
204
      ];
Valentin Reis's avatar
Valentin Reis committed
205
      buildPhase = "zymake ${experiments-src}/experiments/zymakefile";
Valentin Reis's avatar
Valentin Reis committed
206
207
208
209
      installPhase = ''
        mkdir -p $out
        cp -r o/* $out
      '';
Valentin Reis's avatar
Valentin Reis committed
210
    });
Valentin Reis's avatar
Valentin Reis committed
211

Valentin Reis's avatar
Valentin Reis committed
212
213
214
215
216
    analysis = pkgs.stdenv.mkDerivation rec {
      name = "analysis";
      src = experiments-src;

      #required to be able to build the drv.
Valentin Reis's avatar
Valentin Reis committed
217
218
219
      installPhase = ''
        mkdir -p $out
      '';
Valentin Reis's avatar
Valentin Reis committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
      unpackPhase = "true";

      buildInputs = [
        (pkgs.rWrapper.override{ packages = with pkgs.rPackages; [
          pkgs.rlwrap
          pkgs.pandoc
          docopt
          formatR
          purrr
          knitr
          cowplot
          plotly
          lubridate
          dplyr
          ggplot2
          xtable
          ggthemes
          data_table
        ];})
      ];
    };

    report = analysis.overrideAttrs (old:{
      buildPhase = ''
244
245
        echo "analysis/zymakefolder.R ${powerexpe}"
        analysis/zymakefolder.R ${powerexpe}
Valentin Reis's avatar
Valentin Reis committed
246
247
248
249
250
251
      '';
      installPhase = ''
        mkdir -p $out
        cp -r index* $out
      '';
    });
252

253
    doArgotk = drv: command: drv.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
254
      buildPhase = "argotk "+command+" --verbose";
Valentin Reis's avatar
Valentin Reis committed
255
      installPhase = ''
Valentin Reis's avatar
Valentin Reis committed
256
        mkdir -p $out
Valentin Reis's avatar
Valentin Reis committed
257
258
259
        cp _output/* $out/
      '';
    });
260
261
262
263
    testHello       = doArgotk test "TestHello";
    testListen      = doArgotk test "TestListen";
    testPerfwrapper = doArgotk test "TestPerfwrapper";
    testPower       = doArgotk test "TestPower";
264
265
266
267
268
    testSTREAM      = doArgotk (test.overrideAttrs (old:{buildInputs=old.buildInputs++[ stream ];})) "TestSTREAM";
    testAMG         = doArgotk (test.overrideAttrs (old:{buildInputs=old.buildInputs++[ amg ];})) "TestAMG";
    testOpenMC      = doArgotk (test.overrideAttrs (old:{buildInputs=old.buildInputs++[ openmc ];})) "TestOpenMC";
    testLAMMPS      = doArgotk (test.overrideAttrs (old:{buildInputs=old.buildInputs++[ lammps ];})) "TestLAMMPS";
    testQMCPack     = doArgotk (test.overrideAttrs (old:{buildInputs=old.buildInputs++[ qmcpack ];})) "TestQMCPack";
269
    testAll         = doArgotk test "tests";
Valentin Reis's avatar
Valentin Reis committed
270

271
  };
272
# re-exporting a full nixpkgs-like package set
273
in pkgs // argopkgs