summaryrefslogtreecommitdiffstats
path: root/env.nix
blob: a98b5188136f65b42beaf5318155e00e5dba84fc (plain)
1
2
3
4
5
6
7
8
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ nixpkgs ? import <nixpkgs> {} }:

let
  name = "much";
  version = "1";

  buildInputs = with pkgs; [
    hsEnv
  ];

  extraCmds = with pkgs; ''
    export MANPATH=$(ls -d $(echo "$PATH" | tr : \\n | sed -n 's:\(^/nix/store/[^/]\+\).*:\1/share/man:p') 2>/dev/null | tr \\n :)
    $(grep export ${hsEnv.outPath}/bin/ghc)
    ${mkExports staticPkgs}
  '';

  # ghcWithPackagesOld b/c terminfo collision
  hsEnv = hsPkgs.ghcWithPackagesOld (self: with self;
    terminfo.nativeBuildInputs ++
    [
      cabalInstall
      dataDefault
      vtyUi

      # for NotmuchCmd
      aeson
      #blazeHtml
      caseInsensitive
      #conduit
      #conduitExtra
      process
      rosezipper
      safe
    ]
  );

  hsPkgs = pkgs.haskellPackages_ghc783_profiling.override {
    extension = self: super: with self; {
      #vty = callPackage ./nixpkgs/vty-5.2.5.nix { #{{{
      #}; #}}}
    };
  };

  pkgs = nixpkgs // staticPkgs;
  staticPkgs = with nixpkgs; {
  };

  #{{{ mkExports : set -> string
  # Create shell script that exports a set's attributes.
  mkExports = set: with builtins; with pkgs.lib.strings;
    let
      # XXX attribute names are not escaped, they have to be sane
      # XXX the value should not contain <newline>
      mkExport = k: "export ${k}=${escapeSh (getAttr k set)}";
      escapeSh = stringAsChars (c: "\\${c}");
    in
      concatStringsSep "\n" (map mkExport (attrNames set));
  #}}}

in pkgs.myEnvFun {
  name = "${name}-${version}";
  inherit buildInputs extraCmds;
}
# vim: set fdm=marker :