@@ -1,119 +1,56 @@
1−hackage:
2−{ cabalexpr, pkgs, compiler ? "Ghc", version, os ? "Osx", arch ? "X86_64" }:
3−assert (builtins.elem compiler ["Ghc" "Ghcjs" "Nhc" "Yhc" "Hugs" "Hbc" "Helium" "Jhc" "Lhc" "Uhc" "Eta"]);
4−assert (builtins.elem os ["Linux" "Windows" "Osx" "FreeBSD" "OpenBSD" "NetBSD" "DragonFly" "Solaris" "AIX" "HPUX" "IRIX" "HaLVM" "Hurd" "IOS" "Android" "Ghcjs"]);
5−assert (builtins.elem arch ["I386" "X86_64" "PPC" "PPC64" "Sparc" "Arm" "Aarch64" "Mips" "SH" "IA64" "S390" "Alpha" "Hppa" "Rs6000" "M68k" "Vax" "JavaScript"]);
6−
7−with rec {
1+{ lib, expr, mkDerivation }:
2+let
83 # utilities
9− collectAttr = a: s: pkgs.lib.lists.fold (e: acc: (if e ? ${a} then e.${a} else []) ++ acc) [] (builtins.attrValues s);
4+ collectAttr = a: s: lib.lists.fold (e: acc: (if e ? ${a} then e.${a} else []) ++ acc) [] (builtins.attrValues s);
105
116 # resolver for cabal license to nix license
12− resolve = { license = stdenv: license: (import ./cabal-licenses.nix stdenv).${license}; };
13−
14− # cabal os, arch and compilers.
15− cabal = import ./cabal-os-arch-comp.nix;
16−
17− expr0 = flags: extraHsPkgs: let e = cabalexpr {
18− inherit flags;
19− # null out self references. Tests, Benchmarks, ...
20− # naturally depend on the package (as a library), but
21− # we don't want those dependencies.
22− hsPkgs = pkgs.haskellPackages
23− // { ${e.package.identifier.name} = null; }
24− // extraHsPkgs;
25− # We also need to do some system pkgs -> haskell pkgs
26− # resolution.
27− pkgs = pkgs
28− # fetchgit should always come from the buildPackages
29− # if it comes from the targetPackages we won't even
30− # be able to execute it.
31− // { fetchgit = pkgs.buildPackages.fetchgit; }
32− # haskell lib -> nix lib mapping
33− // { crypto = pkgs.openssl;
34− "c++" = null; # no libc++
35− "stdc++" = null; "stdc++-6" = null;
36− ssl = pkgs.openssl;
37− z = pkgs.zlib;
38− pthread = null; # available by default
39− }
40− # -- windows
41− // { advapi32 = null; gdi32 = null; imm32 = null; msimg32 = null;
42− shell32 = null; shfolder = null; shlwapi = null; user32 = null;
43− winmm = null;
44− kernel32 = null; ws2_32 = null;
45−
46− # this should be bundled with gcc.
47− # if it's not we have more severe
48− # issues anyway.
49− gcc_s_seh-1 = null;
50−
51− ssl32 = null; eay32 = pkgs.openssl;
52−
53− iphlpapi = null; # IP Help API
54−
55− msvcrt = null; # this is the libc
56−
57− Crypt32 = null;
58− }
59− # -- os x
60− // pkgs.darwin.apple_sdk.frameworks;
61−
62− # package-conf mappings.
63− # pkgconfig name -> nix package
64− pkgconfPkgs = { libpcre = pkgs.pcre; };
65−
66− compiler = cabal.compiler // {
67− "is${compiler}" = true;
68− version = rec {
69− eq = v: builtins.compareVersions version v == 0;
70− lt = v: builtins.compareVersions version v == -1;
71− gt = v: builtins.compareVersions version v == 1;
72− le = v: eq v || lt v;
73− ge = v: eq v || gt v;
74− };
75− };
76− system = cabal.os // { "is${os}" = true; }
77− // cabal.arch // { "is${arch}" = true; };
78− }; in e;
79−};
7+ resolve = { license = lib: license: (import ../lib/cabal-licenses.nix lib).${license}; };
8+#in mkDerivation ({
809# These are the keys that <pkg>.override can override.
8110# the ... is used to allow to override all potential
8211# other keys, that the builder understands.
83−{ mkDerivation, stdenv, flags ? {}, hsPkgs ? {}, ... }@args:
84−let expr = expr0 flags hsPkgs;
12+# { mkDerivation, stdenv, flags ? {}, hsPkgs ? {}, ... }@args:
13+#let
8514 pname = expr.package.identifier.name;
8615 pversion = expr.package.identifier.version;
8716 builderArgs = {
8817 inherit pname;
8918 version = pversion;
90− sha256 = hackage.hashes.${pname}.${pversion} or null;
91−
19+
9220 isLibrary = builtins.hasAttr pname expr.components;
9321 isExecutable = builtins.hasAttr "exes" expr.components;
94−
22+
9523 homepage = expr.package.homepage;
9624 description = expr.package.synopsis;
97− license = resolve.license stdenv expr.package.license;
98−
99− configureFlags = pkgs.lib.mapAttrsToList (flag: enabled: (if enabled then "-f" else "-f-") + flag) expr.flags;
100− } // pkgs.lib.optionalAttrs (builtins.hasAttr pname expr.components) {
25+ license = resolve.license lib expr.package.license;
26+
27+ configureFlags = lib.mapAttrsToList (flag: enabled: (if enabled then "-f" else "-f-") + flag) expr.flags;
28+
29+ } // lib.optionalAttrs (expr ? revision) {
30+ revision = "${toString expr.revision}";
31+ editedCabalFile = expr.revisionSha256;
32+ } // lib.optionalAttrs (expr ? sha256) {
33+ inherit (expr) sha256;
34+ } // lib.optionalAttrs (builtins.hasAttr pname expr.components) {
10135 libraryHaskellDepends = expr.components.${pname}.depends or [];
10236 libraryPkgconfigDepends = expr.components.${pname}.pkgconfig or [];
103− librarySystemDepends = (expr.components.${pname}.libs or []) ++ pkgs.lib.optionals (os == "Osx") (expr.components.${pname}.frameworks or []);
37+ librarySystemDepends = (expr.components.${pname}.libs or []); # ++ lib.optionals (os == "Osx") (expr.components.${pname}.frameworks or []);
10438 libraryToolDepends = expr.components.${pname}.build-tools or [];
105− } // pkgs.lib.optionalAttrs (builtins.hasAttr "exes" expr.components) {
39+ } // lib.optionalAttrs (builtins.hasAttr "exes" expr.components) {
10640 executableHaskellDepends = collectAttr "depends" expr.components.exes;
10741 executableToolDepends = collectAttr "build-tools" expr.components.exes;
108− } // pkgs.lib.optionalAttrs (builtins.hasAttr "tests" expr.components) {
42+ } // lib.optionalAttrs (builtins.hasAttr "tests" expr.components) {
10943 testHaskellDepends = collectAttr "depends" expr.components.tests;
110− } // pkgs.lib.optionalAttrs (builtins.hasAttr "benchmarks" expr.components) {
44+ } // lib.optionalAttrs (builtins.hasAttr "benchmarks" expr.components) {
11145 benchmarkHaskellDepends = collectAttr "depends" expr.components.benchmarks;
112− } // pkgs.lib.optionalAttrs (builtins.hasAttr "src" expr) {
46+ } // lib.optionalAttrs (expr ? src) {
11347 inherit (expr) src;
114− } // pkgs.lib.optionalAttrs (builtins.hasAttr "postUnpack" expr) {
48+ } // lib.optionalAttrs (expr ? postUnpack) {
11549 inherit (expr) postUnpack;
116− } // builtins.removeAttrs args [ "mkDerivation" "stdenv" "flags" "hsPkgs" ];
117−in mkDerivation (builderArgs // pkgs.lib.optionalAttrs (expr.cabal-generator or "" == "hpack")
118− { preConfigure = "hpack;" + (builderArgs.preConfigure or "");
119− libraryToolDepends = builderArgs.libraryToolDepends ++ [ pkgs.haskellPackages.hpack ]; })
50+ }
51+ #// builtins.removeAttrs args [ "mkDerivation" "stdenv" "flags" "hsPkgs" ];
52+ ;
53+in mkDerivation (builderArgs)
54+#// lib.optionalAttrs (expr.cabal-generator or "" == "hpack")
55+# { preConfigure = "hpack;" + (builderArgs.preConfigure or "");
56+# libraryToolDepends = builderArgs.libraryToolDepends ++ [ pkgs.haskellPackages.hpack ]; })