Nixexpr.hs 3.31 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1
2
3
4
5
6
7
{-# LANGUAGE QuasiQuotes #-}

module Nixexpr where

import           Data.Text                      (  Text)
import           NeatInterpolation

Valentin Reis's avatar
Valentin Reis committed
8
-- Bunch of disgusting nix code for source overrides and environments.
Valentin Reis's avatar
Valentin Reis committed
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
nixExpression :: Text
nixExpression =
  [text|
    let
      hostPkgs = import <nixpkgs> {};
      argopkgs-src = builtins.fetchGit {
          url = https://xgitlab.cels.anl.gov/argo/argopkgs.git;
          rev = "";
      };
    in
      {
        argopkgs             ? import argopkgs-src {},
        argotk-src           ? argopkgs.argotk.src,
        nrm-src              ? argopkgs.nodelevel.nrm.src,
        containers-src       ? argopkgs.nodelevel.containers.src,
        libnrm-src           ? argopkgs.nodelevel.libnrm.src,
        amg-src              ? argopkgs.applications.nrm.amg.src,
        lammps-src           ? argopkgs.applications.nrm.lammps.src,
        qmcpack-src          ? argopkgs.applications.nrm.qmcpack.src,
        stream-src           ? argopkgs.applications.nrm.stream.src,
        dgemm_randomwalk-src ? argopkgs.applications.nrm.dgemm_randomwalk.src,
      }:
      rec {
        argotk           = argopkgs.argotk.overrideAttrs                    (old: {src = argotk-src;}     );
        nrm              = argopkgs.nodelevel.nrm.overrideAttrs             (old: {src = nrm-src;}        );
        libnrm           = argopkgs.nodelevel.libnrm.overrideAttrs          (old: {src = libnrm-src;}     );
        containers       = argopkgs.nodelevel.containers.overrideAttrs      (old: {src = containers-src;} );
        amg              = (argopkgs.applications.nrm.amg.overrideAttrs     (old: {src = amg-src;}        )).override {libnrm = libnrm;};
        qmcpack          = (argopkgs.applications.nrm.qmcpack.overrideAttrs (old: {src = qmcpack-src;}    )).override {libnrm = libnrm;};
        stream-test      = (argopkgs.applications.nrm.stream.overrideAttrs  (old: {src = stream-src;}     )).override {libnrm = libnrm; iterationCount = "20";};
39
        stream           = (argopkgs.applications.nrm.stream.overrideAttrs  (old: {src = stream-src;}     )).override {libnrm = libnrm; iterationCount = "2000";};
Valentin Reis's avatar
Valentin Reis committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
        lammps           = (argopkgs.applications.nrm.lammps.overrideAttrs  (old: {src = lammps-src;}     )).override {libnrm = libnrm;};

        test = argopkgs.stdenv.mkDerivation rec {
          name = "testEnv";
          installPhase = "mkdir $$out";
          unpackPhase = "true";
          buildInputs =  [
            argopkgs.coreutils
            argopkgs.utillinux
            argopkgs.mpich2
            argotk
            containers
            stream-test
            nrm
          ];
          shellHook = ''
            source $${argotk}/share/argotk.sh
            echo "Installed bash completion."
          '';
Valentin Reis's avatar
Valentin Reis committed
59
          ARGONIX_SHARE = "$${argopkgs.argonix}/share";
Valentin Reis's avatar
Valentin Reis committed
60
61
62
63
64
65
66
67
        };

        expe = test.overrideAttrs (old:{
            buildInputs = old.buildInputs ++ [amg lammps qmcpack stream];
          }
        );
      }
  |]
Valentin Reis's avatar
Valentin Reis committed
68
69
70
71
72
73
74
75
76
77

-- Small bunch of disgusting nix code for source filtering.
filterSource :: Text -> Text
filterSource p = [text|
  (builtins.filterSource (path: type:
    (baseNameOf path != ".hdevtools.sock") &&
    (baseNameOf path != ".ghc.environment.x86_64-linux-8.4.4") &&
    (baseNameOf path != "_output") &&
    (baseNameOf path != "result") &&
    (baseNameOf path != "dist")) $p ) |]