default.nix 3.82 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) {};
21 22
    };
  };
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39

  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
40
    source ${./completion/argotk.sh}
41 42 43
    echo "Installed bash completion."
  '';

Valentin Reis's avatar
Valentin Reis committed
44
in rec
Valentin Reis's avatar
Valentin Reis committed
45
{
46 47 48 49 50 51
  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;

52
  inherit(hpkgs) argo;
53

54
  dev-lib = hpkgs.shellFor {
55
    packages = p: with p; [ argo ];
56
    withHoogle = true;
57
    buildInputs = devInputs ++ devHPackages;
58 59
  };

60 61 62
  manifests = ./manifests;

  argotk = pkgs.stdenv.mkDerivation rec {
63
    name = "env";
64
    env = pkgs.buildEnv { name = name; paths = buildInputs ++ propagatedBuildInputs; };
65
    src = filterHdevTools ./argotk;
66 67 68 69 70 71
    installPhase =''
      mkdir -p $out/bin
      mkdir -p $out/share
      cp argotk.hs $out/bin
      cp ${manifests}/* $out/share/
      '';
72
    buildInputs = [
73
      (hpkgs.ghcWithPackages (p: [p.argo ]))
74
    ];
75
    propagatedBuildInputs = [
76
      (hpkgs.ghcWithPackages (p: [p.argo ]))
77
      pkgs.coreutils
78
      pkgs.utillinux
79 80
    ];
    inherit shellHook;
81 82
  };

83 84 85
  test = pkgs.stdenv.mkDerivation rec {
    name = "env";
    env = pkgs.buildEnv { name = name; paths = buildInputs; };
86 87 88
    buildInputs =  [
      argotk
      pkgs.coreutils
89
      pkgs.utillinux
90 91 92 93
      containers
      amg
      nrm
    ];
94
    inherit shellHook;
95
    MANIFESTS = ./manifests;
Valentin Reis's avatar
Valentin Reis committed
96
  };
97

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

  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
136
}