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

, # versioned nixpkgs
  pkgs            ? import (hostPkgs.nix-update-source.fetch ./pkgs.json).src {}

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

, #source overrides: core nrm components
Valentin Reis's avatar
Valentin Reis committed
11 12 13 14
  aml-src         ? fetched aml/pin.json
, 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
15 16

, #source overrides: applications
Valentin Reis's avatar
Valentin Reis committed
17 18 19 20 21
  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
22 23

, #source overrides :tooling
24 25 26 27 28 29
  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;}

, #used for hardware experiments.
  sudoPath ? null
Valentin Reis's avatar
.  
Valentin Reis committed
30 31
}:
let
Valentin Reis's avatar
Valentin Reis committed
32
  callPackage = pkgs.lib.callPackageWith (pkgs // argopkgs);
33

Valentin Reis's avatar
Valentin Reis committed
34
  argopkgs = rec {
35
    # library of nix expressions
Valentin Reis's avatar
Valentin Reis committed
36
    argolib     = import ../lib/utils.nix;
37
    # Argo components (source overridabel via argument)
38 39 40 41
    aml        = callPackage ./aml        {src=aml-src;};
    nrm        = callPackage ./nrm        {src=nrm-src;};
    containers = callPackage ./containers {src=containers-src;};
    libnrm     = callPackage ./libnrm     {src=libnrm-src;};
Valentin Reis's avatar
Valentin Reis committed
42 43 44 45
    libnrm-pmpi = libnrm.overrideAttrs (oldAttrs: rec {
      configureFlags = "--enable-pmpi";
      buildInputs = oldAttrs.buildInputs ++ [ pkgs.mpich2 ];
    });
46

47
    # applications (source overridable via argument)
48 49 50 51 52
    amg     = callPackage ./amg     {nrmSupport=true;src=amg-src;};
    qmcpack = callPackage ./qmcpack {nrmSupport=true;src=qmcpack-src;};
    openmc  = callPackage ./openmc  {nrmSupport=true;src=openmc-src;};
    stream  = callPackage ./stream  {nrmSupport=true;src=stream-src;};
    lammps  = callPackage ./lammps  {nrmSupport=true;src=lammps-src;};
Valentin Reis's avatar
Valentin Reis committed
53

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

57 58 59 60
    # tools
    zymake = callPackage ./zymake {
      inherit (pkgs.ocamlPackages) findlib ocamlbuild topkg batteries;
    };
Valentin Reis's avatar
Valentin Reis committed
61 62
    haskellPackages = pkgs.haskellPackages.override {
      overrides = self: super: with pkgs.haskell.lib;
Valentin Reis's avatar
Valentin Reis committed
63
      rec {
Valentin Reis's avatar
Valentin Reis committed
64
        panpipe        = (pkgs.haskell.lib.doJailbreak super.panpipe);
Valentin Reis's avatar
Valentin Reis committed
65
        spdx           = (pkgs.haskell.lib.doJailbreak super.spdx);
Valentin Reis's avatar
Valentin Reis committed
66
        generic-pretty = doJailbreak super.generic-pretty;
Valentin Reis's avatar
Valentin Reis committed
67

Valentin Reis's avatar
Valentin Reis committed
68 69 70 71 72
        #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
73 74 75
        argotk = (self.callCabal2nix "argotk" argotk-src) {};
        argonix = (self.callCabal2nix "argonix" argonix-src) {};
        repoquality = (self.callCabal2nix "repoquality" repoquality-src) {};
76
      };
Valentin Reis's avatar
Valentin Reis committed
77
    };
Valentin Reis's avatar
Valentin Reis committed
78

79
    # re-export from hpkgs and add non-haskell build rule specialization
Valentin Reis's avatar
Valentin Reis committed
80 81 82
    inherit (haskellPackages) repoquality;

    argotk = haskellPackages.argotk.overrideAttrs (old:{
Valentin Reis's avatar
Valentin Reis committed
83 84 85 86 87 88 89 90 91 92 93 94
        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
95 96 97 98 99 100 101 102
      });

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

104
    # fix for nrm
Valentin Reis's avatar
Valentin Reis committed
105
    pyzmq = pkgs.pythonPackages.pyzmq.override { zeromq3 = pkgs.zeromq; };
Valentin Reis's avatar
Valentin Reis committed
106

107
    # archived for sake of the simplicity of this file
Valentin Reis's avatar
Valentin Reis committed
108
    #zmcat = pkgs-stable.haskellPackages.callPackage ./tools/zmcat {};
109

110
    # ci/experimental environments
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
    testBuildInputs =  [
      # 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
127 128
    test = pkgs.stdenv.mkDerivation rec {
      name = "testEnv";
129

130 131
      buildInputs = testBuildInputs ++ [ stream ];

Valentin Reis's avatar
Valentin Reis committed
132
      #required to be able to build the drv.
133
      installPhase = "mkdir $out";
Valentin Reis's avatar
Valentin Reis committed
134
      unpackPhase = "true";
Valentin Reis's avatar
Valentin Reis committed
135

136 137 138 139 140 141 142
      __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."
143
        source ${argotk}/share/argotk.sh # bash completion
144
        echo ""
145
      '';
146
      #argotk uses this environment variable.
147
      ARGOTK_SHARE = "${argotk}/share";
Valentin Reis's avatar
Valentin Reis committed
148
    };
Valentin Reis's avatar
Valentin Reis committed
149

Valentin Reis's avatar
Valentin Reis committed
150
    expe = test.overrideAttrs (old:{
151 152 153 154 155 156 157 158 159
      buildInputs = testBuildInputs ++ [
        #debug tools
        pkgs.which

        #experiment tools
        zymake

        #applications
        (stream.override {iterationCount = "20000";})
160 161 162 163 164 165
        amg
        lammps
        qmcpack
        openmc
        openmc-data
      ];
Valentin Reis's avatar
Valentin Reis committed
166 167 168
      OPENMC_CROSS_SECTIONS = "${openmc-data}/cross_sections.xml";
      OPENMC_PWD = "${argotk}/share/openmc";
    });
Valentin Reis's avatar
Valentin Reis committed
169

Valentin Reis's avatar
Valentin Reis committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
    analysis =
    pkgs.rWrapper.override{ packages = with pkgs.rPackages; [
      docopt
      formatR
      purrr
      knitr
      cowplot
      plotly
      lubridate
      dplyr
      ggplot2
      xtable
      ggthemes
      data_table
    ];};

186 187 188 189 190 191 192 193 194 195 196
    jupyter =
      let
        jupyter = import (fetched jupyter/pin.json) {};
      in
       (jupyter.jupyterlabWith {
          kernels = [
            (jupyter.kernels.juniperWith {
              name = "analysis";
              packages = p: with p; [ ggplot2
                  pkgs.which
                  docopt
Valentin Reis's avatar
Valentin Reis committed
197
                  purrr
198 199
                  knitr
                  cowplot
Valentin Reis's avatar
Valentin Reis committed
200
                  plotly
201 202 203 204 205 206 207 208 209 210 211
                  lubridate
                  dplyr
                  ggplot2
                  xtable
                  ggthemes
                  data_table
              ];
            })
          ];
         }).env;

Valentin Reis's avatar
Valentin Reis committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225
    doArgotk = command: test.overrideAttrs (old:{
      buildPhase = "argotk "+command;
      installPhase = ''
        mkdir $out
        cp _output/* $out/
      '';
    });
    testHello       = doArgotk "TestHello";
    testListen      = doArgotk "TestListen";
    testPerfwrapper = doArgotk "TestPerfwrapper";
    testPower       = doArgotk "TestPower";
    testSTREAM      = doArgotk "TestSTREAM";
    testAll         = doArgotk "tests";

226
  };
227
# re-exporting a full nixpkgs-like package set
228
in pkgs // argopkgs