default.nix 12.7 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
, excit-src        ? fetched excit/pin.json
Valentin Reis's avatar
Valentin Reis committed
17
18
19
, 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
20
21

, #source overrides: applications
Valentin Reis's avatar
Valentin Reis committed
22
23
24
25
26
  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
27

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

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

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

Valentin Reis's avatar
Valentin Reis committed
44
  argopkgs = rec {
45
    # library of nix expressions
Valentin Reis's avatar
style.    
Valentin Reis committed
46
    argolib       = import ../lib/utils.nix;
47
    # Argo components (source overridabel via argument)
Valentin Reis's avatar
Valentin Reis committed
48
    aml           = callPackage ./aml        {src=aml-src; inherit excit; inherit numabench;};
Valentin Reis's avatar
Valentin Reis committed
49
    numabench     = callPackage ./numabench  {src=numabench-src; hwloc = hwloc2;};
Valentin Reis's avatar
Valentin Reis committed
50
    excit         = callPackage ./excit      {src=excit-src;};
Valentin Reis's avatar
Valentin Reis committed
51
52
53
54
55
    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
56
57
58
      configureFlags = "--enable-pmpi";
      buildInputs = oldAttrs.buildInputs ++ [ pkgs.mpich2 ];
    });
59

Valentin Reis's avatar
Valentin Reis committed
60
61
    numabench-check = numabench.overrideAttrs(old: {
      buildPhase = "make check";
62
      installPhase =''
63
64
65
        mkdir -p $out/tests
        cp ./tests/*.log $out/tests
        cp ./tests/*.trs $out/tests
Valentin Reis's avatar
Valentin Reis committed
66
        cp -r ./tests/tmp $out/tests
67
        '';
Valentin Reis's avatar
Valentin Reis committed
68
69
70
71
72
    });
    excit-check = excit.overrideAttrs(old: {
      buildPhase = "make check";
    });

Valentin Reis's avatar
Valentin Reis committed
73
74
75
    # applications with replaceDependency for libnrm.
    repLibnrm = path: src: extra:
    let
Valentin Reis's avatar
Valentin Reis committed
76
      drv = callPackage path ({
Valentin Reis's avatar
style.    
Valentin Reis committed
77
78
79
        nrmSupport = true;
        src = src;
        libnrm = libnrm-pinned;
Valentin Reis's avatar
Valentin Reis committed
80
      }//extra);
Valentin Reis's avatar
style.    
Valentin Reis committed
81
      rebuilt = drv.override {libnrm = libnrm;};
Valentin Reis's avatar
Valentin Reis committed
82
83
84
85
86
87
      grafted = pkgs.replaceDependency {
        drv = drv;
        oldDependency = libnrm-pinned;
        newDependency = libnrm;
      };
    in if graftLibnrm then grafted else rebuilt;
Valentin Reis's avatar
Valentin Reis committed
88
89
90
91
    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
92
    stream       = repLibnrm ./stream  stream-src  {iterationCount="2000";};
Valentin Reis's avatar
Valentin Reis committed
93

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

97
    # tools
98
    checkpatch = callPackage ./checkpatch {src=pkgs.linux_testing.src;};
99
100
101
    zymake = callPackage ./zymake {
      inherit (pkgs.ocamlPackages) findlib ocamlbuild topkg batteries;
    };
Valentin Reis's avatar
Valentin Reis committed
102
103
    haskellPackages = pkgs.haskellPackages.override {
      overrides = self: super: with pkgs.haskell.lib;
Valentin Reis's avatar
Valentin Reis committed
104
      rec {
Valentin Reis's avatar
Valentin Reis committed
105
        panpipe        = (pkgs.haskell.lib.doJailbreak super.panpipe);
Valentin Reis's avatar
Valentin Reis committed
106
        spdx           = (pkgs.haskell.lib.doJailbreak super.spdx);
Valentin Reis's avatar
Valentin Reis committed
107
        monad-mock     = (pkgs.haskell.lib.doJailbreak super.monad-mock);
Valentin Reis's avatar
Valentin Reis committed
108
        generic-pretty = doJailbreak super.generic-pretty;
Valentin Reis's avatar
Valentin Reis committed
109

Valentin Reis's avatar
Valentin Reis committed
110
111
112
        #minor cabal and version fix
        panhandle    = (self.callCabal2nix "panhandle" (builtins.fetchGit {
                      inherit (panhandle-src) url rev; })) {};
Valentin Reis's avatar
Valentin Reis committed
113
114
115
        inline-r = dontCheck super.inline-r;
        argonix     = (self.callCabal2nix "argonix"     argonix-src     ) {};
        repoquality = (self.callCabal2nix "repoquality" repoquality-src ) {};
Valentin Reis's avatar
Valentin Reis committed
116
        dhrun       = (self.callCabal2nix "dhrun"       dhrun-src ) {};
Valentin Reis's avatar
Valentin Reis committed
117
118
        powerplots  = (self.callCabal2nix "powerplots"  powerplots-src  ) {};

119
      };
Valentin Reis's avatar
Valentin Reis committed
120
    };
Valentin Reis's avatar
Valentin Reis committed
121

122
    # re-export from hpkgs and add non-haskell build rule specialization
Valentin Reis's avatar
Valentin Reis committed
123
    inherit (haskellPackages) repoquality;
Valentin Reis's avatar
Valentin Reis committed
124

Valentin Reis's avatar
Valentin Reis committed
125
    dhrun = haskellPackages.dhrun.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
126
        installPhase = old.installPhase + ''
Valentin Reis's avatar
Valentin Reis committed
127
128
          mkdir -p $out/share/
          cp -r resources $out/share/
Valentin Reis's avatar
Valentin Reis committed
129
        '';
Valentin Reis's avatar
Valentin Reis committed
130
131
132
133
      });

    argonix = haskellPackages.argonix.overrideAttrs (old:{
        installPhase = old.installPhase + ''
Valentin Reis's avatar
Valentin Reis committed
134
          mkdir -p $out/share/
Valentin Reis's avatar
Valentin Reis committed
135
136
137
          $out/bin/argonix --bash-completion-script argonix > $out/share/argonix.sh
        '';
      });
138

Valentin Reis's avatar
Valentin Reis committed
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
    powerplots =
    let
      pkl = with pkgs.rPackages; [ docopt pracma tidyr readr magrittr formatR
          purrr wrapr knitr cowplot plotly lubridate dplyr ggplot2 fpp2
          prospectr gridExtra zoo xtable ggthemes data_table
        ];
      myR = (pkgs.rWrapper.override{ packages = [pkl];});
    in
    haskellPackages.powerplots.overrideDerivation (drv: rec {
      buildInputs = (drv.buildInputs or []) ++ [
        pkgs.makeWrapper
        myR
      ];

      installPhase = drv.installPhase + ''
        wrapProgram "$out/bin/powerplots" \
          --set R_LIBS_SITE `Rscript -e "Sys.getenv(\"R_LIBS_SITE\")"`
      '';

    });

160
    # fix for nrm
Valentin Reis's avatar
Valentin Reis committed
161
    pyzmq = pkgs.pythonPackages.pyzmq.override { zeromq3 = pkgs.zeromq; };
Valentin Reis's avatar
Valentin Reis committed
162

Valentin Reis's avatar
Valentin Reis committed
163
164
165
166
167
168
169
    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";
      };
    });

170
    # archived for sake of the simplicity of this file
Valentin Reis's avatar
Valentin Reis committed
171
172
    zmcat = pkgs-old.haskellPackages.callPackage ./zmcat {};
    zmqat = pkgs-old.haskellPackages.zmqat;
173

174
    # ci/experimental environments
Valentin Reis's avatar
Valentin Reis committed
175
176
    test = pkgs.stdenv.mkDerivation rec {
      name = "testEnv";
177

Valentin Reis's avatar
Valentin Reis committed
178
      buildInputs = [
Valentin Reis's avatar
Valentin Reis committed
179
        # tooling may run mpiexec or hwloc:
Valentin Reis's avatar
Valentin Reis committed
180
181
182
183
184
185
186
        pkgs.mpich2
        pkgs.hwloc
        # these are needed for some reason:
        pkgs.coreutils
        pkgs.utillinux
        pkgs.git
        # argo tools
Valentin Reis's avatar
Valentin Reis committed
187
        dhrun
Valentin Reis's avatar
Valentin Reis committed
188
189
190
        # argo components
        containers
        nrm
Valentin Reis's avatar
Valentin Reis committed
191
      ];
192

Valentin Reis's avatar
Valentin Reis committed
193
      #required to be able to build the drv.
194
      installPhase = "mkdir $out";
Valentin Reis's avatar
Valentin Reis committed
195
      unpackPhase = "true";
Valentin Reis's avatar
Valentin Reis committed
196

197
198
199
200
201
202
203
204
      __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."
        echo ""
205
      '';
206
      #argotk uses this environment variable.
Valentin Reis's avatar
Valentin Reis committed
207
      #OPENMC_PWD = "${argotk}/share/openmc";
Valentin Reis's avatar
Valentin Reis committed
208
    };
Valentin Reis's avatar
Valentin Reis committed
209

Valentin Reis's avatar
Valentin Reis committed
210
    testApplications = test.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
211
      name = "testEnv-with-applications";
212
      buildInputs = old.buildInputs ++ [
Valentin Reis's avatar
Valentin Reis committed
213
        lammps
214
        qmcpack
Valentin Reis's avatar
Valentin Reis committed
215
216
217
218
219
220
        openmc
        stream
        amg
        openmc-data
      ];
    });
Valentin Reis's avatar
Valentin Reis committed
221

222
    powerexpe = testApplications.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
223
224
      name = "power-experiments";
      buildInputs = old.buildInputs ++ [
225
226
        #debug tools
        pkgs.which
Valentin Reis's avatar
Valentin Reis committed
227
        zmcat
228
229
        #experiment tools
        zymake
230
      ];
Valentin Reis's avatar
Valentin Reis committed
231
      buildPhase = "zymake ${experiments-src}/experiments/zymakefile";
Valentin Reis's avatar
Valentin Reis committed
232
233
234
235
      installPhase = ''
        mkdir -p $out
        cp -r o/* $out
      '';
Valentin Reis's avatar
Valentin Reis committed
236
    });
Valentin Reis's avatar
Valentin Reis committed
237

Valentin Reis's avatar
Valentin Reis committed
238
239
240
241
242
    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
243
244
245
      installPhase = ''
        mkdir -p $out
      '';
Valentin Reis's avatar
Valentin Reis committed
246
247
248
      unpackPhase = "true";

      buildInputs = [
249
        pkgs.pandoc
Valentin Reis's avatar
Valentin Reis committed
250
251
252
253
        (pkgs.rWrapper.override{ packages = with pkgs.rPackages; [
          pkgs.rlwrap
          pkgs.pandoc
          docopt
254
255
256
257
          pracma
          tidyr
          readr
          magrittr
Valentin Reis's avatar
Valentin Reis committed
258
259
          formatR
          purrr
260
          wrapr
Valentin Reis's avatar
Valentin Reis committed
261
262
263
264
265
266
          knitr
          cowplot
          plotly
          lubridate
          dplyr
          ggplot2
267
268
269
270
          fpp2
          prospectr
          gridExtra
          zoo
Valentin Reis's avatar
Valentin Reis committed
271
272
273
274
275
276
277
          xtable
          ggthemes
          data_table
        ];})
      ];
    };

278
279
    hanalysis = analysis.overrideAttrs (old:{
      buildInputs = old.buildInputs ++ [
Valentin Reis's avatar
Valentin Reis committed
280
281
282
283
284
        (haskellPackages.ghcWithPackages(p:[
          p.protolude
          p.optparse-applicative
          (p.inline-r.overrideAttrs(old:{doCheck=false;}))
        ]))
285
286
287
      ];
    });

Valentin Reis's avatar
Valentin Reis committed
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
    f = { mkDerivation, base, protolude, data-default
    , optparse-applicative, typed-process, inline-r
    , R, stdenv }:
    mkDerivation {
      pname = "hsr";
      version = "1.0.0";
      src = "";
      isLibrary = true;
      isExecutable = false;
      libraryHaskellDepends = [
        base
        protolude
        inline-r
        typed-process
        optparse-applicative
        data-default
      ];
      librarySystemDepends = [
        pkgs.pandoc
        R
        pkgs.rPackages.docopt
        pkgs.rPackages.pracma
        pkgs.rPackages.tidyr
        pkgs.rPackages.readr
        pkgs.rPackages.magrittr
        pkgs.rPackages.formatR
        pkgs.rPackages.purrr
        pkgs.rPackages.wrapr
        pkgs.rPackages.knitr
        pkgs.rPackages.cowplot
        pkgs.rPackages.plotly
        pkgs.rPackages.lubridate
        pkgs.rPackages.dplyr
        pkgs.rPackages.ggplot2
        pkgs.rPackages.fpp2
        pkgs.rPackages.prospectr
        pkgs.rPackages.gridExtra
        pkgs.rPackages.zoo
        pkgs.rPackages.xtable
        pkgs.rPackages.ggthemes
        pkgs.rPackages.data_table
      ];
      license = stdenv.lib.licenses.bsd3;
    };
    hanal = argolib.getHackEnv (pkgs//argopkgs)
      haskellPackages (haskellPackages.callPackage f {});

Valentin Reis's avatar
Valentin Reis committed
335
336
    report = analysis.overrideAttrs (old:{
      buildPhase = ''
337
338
        echo "analysis/zymakefolder.R ${powerexpe}"
        analysis/zymakefolder.R ${powerexpe}
Valentin Reis's avatar
Valentin Reis committed
339
340
341
342
343
344
      '';
      installPhase = ''
        mkdir -p $out
        cp -r index* $out
      '';
    });
345

Valentin Reis's avatar
Valentin Reis committed
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
    dhrunSpecs = pkgs.stdenv.mkDerivation rec {
      name = "dhrunSpecs";
      src = ../dhrun ;
      installPhase = ''
        mkdir -p $out
        cp -r $src/* $out
        substituteInPlace $out/assets/simple-H2O.xml --replace \
          H2O.HF.wfs.xml $out/assets/H2O.HF.wfs.xml
        substituteInPlace $out/assets/simple-H2O.xml --replace \
          O.BFD.xml $out/assets/O.BFD.xml
        substituteInPlace $out/assets/simple-H2O.xml --replace \
          H.BFD.xml $out/assets/H.BFD.xml
        substituteInPlace $out/lib.dh --replace \
          "dataDir = \"./\"" "dataDir = \"$out/\""
        substituteInPlace $out/lib.dh --replace \
          "https://xgitlab.cels.anl.gov/argo/dhrun/raw/master/" "${dhrun}/share/"
        '';
      unpackPhase = "true";
    };

    doDhrun = drv: command: drv.overrideAttrs (old:{
      buildPhase = ''
        dhrun run $DHRUNSPECS/tests/${command}.dh
      '';
      DHRUNSPECS = "${dhrunSpecs}";
Valentin Reis's avatar
Valentin Reis committed
371
      installPhase = ''
Valentin Reis's avatar
Valentin Reis committed
372
        mkdir -p $out
Valentin Reis's avatar
Valentin Reis committed
373
374
375
376
        cp _output/* $out/
      '';
    });

Valentin Reis's avatar
Valentin Reis committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
    testHello       = doDhrun test "hello";
    testListen      = doDhrun test "listen";
    testPerfwrapper = doDhrun test "performance";
    testPower       = doDhrun test "power";
    testSTREAM      = doDhrun (test.overrideAttrs
      (old:{buildInputs=old.buildInputs++[ stream  ];})) "stream";
    testAMG         = doDhrun (test.overrideAttrs
      (old:{buildInputs=old.buildInputs++[ amg     ];})) "amg";
    testOpenMC      = doDhrun (test.overrideAttrs
    (old:{buildInputs=old.buildInputs++[ openmc  ];
           OPENMC_CROSS_SECTIONS = "${openmc-data}/cross_sections.xml";
         })) "openmc";
    testLAMMPS      = doDhrun (test.overrideAttrs
      (old:{buildInputs=old.buildInputs++[ lammps  ];})) "lammps";
    testQMCPack     = doDhrun (test.overrideAttrs
      (old:{buildInputs=old.buildInputs++[ qmcpack ];})) "qmcpack";
    testAll         = doDhrun (test.overrideAttrs
      (old:{OPENMC_CROSS_SECTIONS = "${openmc-data}/cross_sections.xml";})) "tests";
395
  };
396
# re-exporting a full nixpkgs-like package set
397
in pkgs // argopkgs