default.nix 4.04 KB
Newer Older
Valentin Reis's avatar
Valentin Reis committed
1
{
2 3 4 5 6 7 8 9 10
  argopkgs-src ?
   let
      hostPkgs = import <nixpkgs> {};
      pinnedVersion = hostPkgs.lib.importJSON ./pin.json;
    in
      hostPkgs.fetchgit {
        inherit (pinnedVersion) url rev sha256;
      },
  pkgs ? import argopkgs-src {},
11 12 13
  nrm-src ? pkgs.nodelevel.nrm.src,
  containers-src ? pkgs.nodelevel.containers.src,
  libnrm-src ? pkgs.nodelevel.libnrm.src
Valentin Reis's avatar
Valentin Reis committed
14 15
}:
let
Valentin Reis's avatar
Valentin Reis committed
16 17
  filterHdevTools = builtins.filterSource (path: type: baseNameOf path != ".hdevtools.sock");

18 19
  hpkgs = pkgs.haskellPackages.override {
        overrides = self: super: rec {
20
        argo = self.callCabal2nix "argo" (filterHdevTools ./argo) {};
Valentin Reis's avatar
Valentin Reis committed
21
        argotk = self.callCabal2nix "argotk" (filterHdevTools ./argotk) {};
22 23
    };
  };
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

  devInputs = with hpkgs; with pkgs; [
    sysstat
  ];

  devHPackages = with hpkgs; [
    cabal-install
    apply-refact
    hdevtools
    hindent
    hlint
    shake
    brittany
    ghcid
  ];

  shellHook = ''
Valentin Reis's avatar
Valentin Reis committed
41
    source ${./completion/argotk.sh}
42 43 44
    echo "Installed bash completion."
  '';

Valentin Reis's avatar
Valentin Reis committed
45
in rec
Valentin Reis's avatar
Valentin Reis committed
46
{
47 48 49 50 51 52
  nrm = pkgs.nodelevel.nrm.overrideAttrs (old: { src =  nrm-src; });
  libnrm = pkgs.nodelevel.libnrm.overrideAttrs (old: { src =  libnrm-src; });
  containers = pkgs.nodelevel.containers.overrideAttrs (old: { src =  containers-src; });

  amg = pkgs.applications.nrm.amg;

Valentin Reis's avatar
Valentin Reis committed
53
  inherit(hpkgs) argo argotk;
54

Valentin Reis's avatar
Valentin Reis committed
55
  hack-argo = hpkgs.shellFor {
56
    packages = p: with p; [ argo ];
57
    withHoogle = true;
58
    buildInputs = devInputs ++ devHPackages;
59 60
  };

Valentin Reis's avatar
Valentin Reis committed
61 62 63 64 65 66
  hack-argotk = hpkgs.shellFor {
    packages = p: with p; [ argotk ];
    withHoogle = true;
    buildInputs = devInputs ++ devHPackages;
  };

67 68
  manifests = ./manifests;

Valentin Reis's avatar
Valentin Reis committed
69
  argotkp = pkgs.stdenv.mkDerivation rec {
70
    name = "env";
71
    env = pkgs.buildEnv { name = name; paths = buildInputs ++ propagatedBuildInputs; };
72
    src = filterHdevTools ./argotk;
73 74 75 76 77 78
    installPhase =''
      mkdir -p $out/bin
      mkdir -p $out/share
      cp argotk.hs $out/bin
      cp ${manifests}/* $out/share/
      '';
79
    buildInputs = [
80
      (hpkgs.ghcWithPackages (p: [p.argo ]))
81
    ];
82
    propagatedBuildInputs = [
83
      (hpkgs.ghcWithPackages (p: [p.argo ]))
84
      pkgs.coreutils
85
      pkgs.utillinux
86 87
    ];
    inherit shellHook;
88 89
  };

90 91 92
  test = pkgs.stdenv.mkDerivation rec {
    name = "env";
    env = pkgs.buildEnv { name = name; paths = buildInputs; };
93
    buildInputs =  [
Valentin Reis's avatar
Valentin Reis committed
94
      argotkp
95
      pkgs.coreutils
96
      pkgs.utillinux
97 98 99 100
      containers
      amg
      nrm
    ];
101
    inherit shellHook;
102
    MANIFESTS = ./manifests;
Valentin Reis's avatar
Valentin Reis committed
103
  };
104

105 106 107 108 109 110 111 112
  hack = pkgs.stdenv.mkDerivation rec {
    name = "env";
    env = pkgs.buildEnv { name = name; paths = buildInputs; };
    buildInputs =  [
      containers
      amg
      nrm
      (hpkgs.ghcWithPackages (p: devHPackages ++ [
113 114
      argotk
      argo
115 116 117 118 119 120
     (pkgs.haskell.lib.doJailbreak p.panpipe)
      p.turtle]))
    ];
    inherit shellHook;
    MANIFESTS = ./manifests;
  };
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

  test-list =
    let
    showSource = s: pkgs.runCommand "source" {} "echo '${builtins.toJSON s}' | ${pkgs.jq}/bin/jq > $out";
    tests = import ./tests/default.nix {};
    showTest = name: content: ''
      ##### TEST NAME: ${name} #####
      argotest: source with type ${content.argotest.type} pointing to ${content.argotest.rev}". Detailed source info:
      ${builtins.readFile (showSource content.argotest.args)}
      nrm: source with type ${content.nrm.type} pointing to ${content.nrm.rev}". Detailed source info:
      ${builtins.readFile (showSource content.nrm.args)}
      libnrm: source with type ${content.libnrm.type} pointing to ${content.libnrm.rev}". Detailed source info:
      ${builtins.readFile (showSource content.libnrm.args)}
      containers: source with type ${content.containers.type} pointing to ${content.containers.rev}". Detailed source info:
      ${builtins.readFile (showSource content.containers.args)}
    '';
    in pkgs.writeText "test-list" (''
      Available test provenance configurations:
     ''+(builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList showTest tests)));

  #testsRepresentations = pkgs.lib.mapAttrsToList (name: value: name ) tests;
  #output = builtins.concatStringsSep "\n" testsRepresentations;
Valentin Reis's avatar
Valentin Reis committed
143
}