2016-11-01 20:29:43 +03:00
|
|
|
{ pkgs, stdenv, ghc, all-cabal-hashes
|
2015-09-16 10:19:56 +03:00
|
|
|
, compilerConfig ? (self: super: {})
|
2015-01-07 22:31:32 +03:00
|
|
|
, packageSetConfig ? (self: super: {})
|
|
|
|
, overrides ? (self: super: {})
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
2017-02-28 11:14:50 +03:00
|
|
|
inherit (stdenv.lib) fix' extends makeOverridable makeExtensible;
|
2017-02-10 08:04:17 +03:00
|
|
|
inherit (import ./lib.nix { inherit pkgs; }) overrideCabal;
|
2016-06-11 20:21:19 +03:00
|
|
|
|
2015-01-07 22:31:32 +03:00
|
|
|
haskellPackages = self:
|
|
|
|
let
|
|
|
|
|
2017-02-10 08:04:17 +03:00
|
|
|
mkDerivationImpl = pkgs.callPackage ./generic-builder.nix {
|
2015-01-10 14:50:43 +03:00
|
|
|
inherit stdenv;
|
2015-01-07 22:31:32 +03:00
|
|
|
inherit (pkgs) fetchurl pkgconfig glibcLocales coreutils gnugrep gnused;
|
2017-03-25 07:23:01 +03:00
|
|
|
nodejs = pkgs.nodejs-slim;
|
2017-01-11 21:25:50 +03:00
|
|
|
jailbreak-cabal = if (self.ghc.cross or null) != null
|
|
|
|
then self.ghc.bootPkgs.jailbreak-cabal
|
|
|
|
else self.jailbreak-cabal;
|
|
|
|
inherit (self) ghc;
|
2015-01-07 22:31:32 +03:00
|
|
|
hscolour = overrideCabal self.hscolour (drv: {
|
|
|
|
isLibrary = false;
|
2015-01-18 13:04:38 +03:00
|
|
|
doHaddock = false;
|
2015-01-07 22:31:32 +03:00
|
|
|
hyperlinkSource = false; # Avoid depending on hscolour for this build.
|
|
|
|
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
|
|
});
|
2015-01-14 00:15:29 +03:00
|
|
|
cpphs = overrideCabal (self.cpphs.overrideScope (self: super: {
|
|
|
|
mkDerivation = drv: super.mkDerivation (drv // {
|
|
|
|
enableSharedExecutables = false;
|
|
|
|
enableSharedLibraries = false;
|
2015-01-18 13:04:38 +03:00
|
|
|
doHaddock = false;
|
2015-01-14 00:15:29 +03:00
|
|
|
useCpphs = false;
|
|
|
|
});
|
|
|
|
})) (drv: {
|
|
|
|
isLibrary = false;
|
|
|
|
postFixup = "rm -rf $out/lib $out/share $out/nix-support";
|
|
|
|
});
|
2015-01-07 22:31:32 +03:00
|
|
|
};
|
|
|
|
|
2017-02-10 08:04:17 +03:00
|
|
|
mkDerivation = makeOverridable mkDerivationImpl;
|
2015-01-07 22:31:32 +03:00
|
|
|
|
2015-01-08 20:29:37 +03:00
|
|
|
callPackageWithScope = scope: drv: args: (stdenv.lib.callPackageWith scope drv args) // {
|
2015-11-24 15:06:58 +03:00
|
|
|
overrideScope = f: callPackageWithScope (mkScope (fix' (extends f scope.__unfix__))) drv args;
|
2015-01-08 20:29:37 +03:00
|
|
|
};
|
|
|
|
|
2016-09-12 00:24:51 +03:00
|
|
|
mkScope = scope: pkgs // pkgs.xorg // pkgs.gnome2 // scope;
|
2015-05-18 11:55:29 +03:00
|
|
|
defaultScope = mkScope self;
|
|
|
|
callPackage = drv: args: callPackageWithScope defaultScope drv args;
|
2015-01-07 22:31:32 +03:00
|
|
|
|
2015-08-17 22:45:13 +03:00
|
|
|
withPackages = packages: callPackage ./with-packages-wrapper.nix {
|
|
|
|
inherit (self) llvmPackages;
|
|
|
|
haskellPackages = self;
|
|
|
|
inherit packages;
|
|
|
|
};
|
|
|
|
|
2017-01-27 05:22:06 +03:00
|
|
|
haskellSrc2nix = { name, src, sha256 ? null }:
|
|
|
|
let
|
2017-03-04 21:18:14 +03:00
|
|
|
sha256Arg = if isNull sha256 then "--sha256=" else ''--sha256="${sha256}"'';
|
2017-01-27 05:22:06 +03:00
|
|
|
in pkgs.stdenv.mkDerivation {
|
|
|
|
name = "cabal2nix-${name}";
|
|
|
|
buildInputs = [ pkgs.cabal2nix ];
|
|
|
|
phases = ["installPhase"];
|
|
|
|
LANG = "en_US.UTF-8";
|
|
|
|
LOCALE_ARCHIVE = pkgs.lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
|
|
|
|
installPhase = ''
|
|
|
|
export HOME="$TMP"
|
|
|
|
mkdir -p "$out"
|
|
|
|
cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} ${sha256Arg} "${src}" > "$out/default.nix"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
hackage2nix = name: version: haskellSrc2nix {
|
|
|
|
name = "${name}-${version}";
|
|
|
|
sha256 = ''$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' "${all-cabal-hashes}/${name}/${version}/${name}.json")'';
|
|
|
|
src = "${all-cabal-hashes}/${name}/${version}/${name}.cabal";
|
2016-06-13 19:32:44 +03:00
|
|
|
};
|
|
|
|
|
2015-01-07 22:31:32 +03:00
|
|
|
in
|
|
|
|
import ./hackage-packages.nix { inherit pkgs stdenv callPackage; } self // {
|
|
|
|
|
2017-04-03 14:55:49 +03:00
|
|
|
inherit mkDerivation callPackage haskellSrc2nix hackage2nix;
|
2015-01-07 22:31:32 +03:00
|
|
|
|
2017-04-03 14:55:49 +03:00
|
|
|
callHackage = name: version: self.callPackage (self.hackage2nix name version);
|
2016-06-11 20:21:19 +03:00
|
|
|
|
2017-01-27 05:22:06 +03:00
|
|
|
# Creates a Haskell package from a source package by calling cabal2nix on the source.
|
2017-04-03 14:55:49 +03:00
|
|
|
callCabal2nix = name: src: self.callPackage (self.haskellSrc2nix { inherit src name; });
|
2017-01-27 05:22:06 +03:00
|
|
|
|
2015-08-17 22:45:13 +03:00
|
|
|
ghcWithPackages = selectFrom: withPackages (selectFrom self);
|
2015-01-07 22:31:32 +03:00
|
|
|
|
2015-08-17 22:45:13 +03:00
|
|
|
ghcWithHoogle = selectFrom:
|
|
|
|
let
|
|
|
|
packages = selectFrom self;
|
2016-09-03 17:35:19 +03:00
|
|
|
hoogle = callPackage ./hoogle.nix {
|
|
|
|
inherit packages;
|
|
|
|
};
|
2015-08-17 22:45:13 +03:00
|
|
|
in withPackages (packages ++ [ hoogle ]);
|
|
|
|
|
|
|
|
ghc = ghc // {
|
|
|
|
withPackages = self.ghcWithPackages;
|
|
|
|
withHoogle = self.ghcWithHoogle;
|
|
|
|
};
|
2015-01-10 14:50:43 +03:00
|
|
|
|
2015-01-07 22:31:32 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
commonConfiguration = import ./configuration-common.nix { inherit pkgs; };
|
2017-02-02 18:49:28 +03:00
|
|
|
nixConfiguration = import ./configuration-nix.nix { inherit pkgs; };
|
2015-01-07 22:31:32 +03:00
|
|
|
|
|
|
|
in
|
|
|
|
|
2017-02-26 01:38:38 +03:00
|
|
|
makeExtensible
|
2015-11-24 15:06:58 +03:00
|
|
|
(extends overrides
|
|
|
|
(extends packageSetConfig
|
|
|
|
(extends compilerConfig
|
2017-02-02 18:49:28 +03:00
|
|
|
(extends commonConfiguration
|
|
|
|
(extends nixConfiguration haskellPackages)))))
|