callHackage: generate expressions for the appropriate target system and compiler

This commit is contained in:
Peter Simons 2016-06-13 18:32:44 +02:00
parent 322fe543b6
commit 8d86c8274f
2 changed files with 21 additions and 23 deletions

View file

@ -6,9 +6,14 @@
let
inherit (stdenv.lib) fix' extends;
allCabalFiles = pkgs.fetchFromGitHub {
owner = "commercialhaskell";
repo = "all-cabal-hashes";
rev = "461610ab6f0cf581e186643c037f1981755792d9";
sha256 = "0x2577lfd5cbbaivl72273kw93gcmxvbjybk7w4h2ic3zvs1fnvm";
};
inherit (import ./lib.nix { inherit pkgs; }) hackage2nix;
inherit (stdenv.lib) fix' extends;
haskellPackages = self:
let
@ -54,6 +59,20 @@ let
inherit packages;
};
hackage2nix = name: version: pkgs.stdenv.mkDerivation {
name = "cabal2nix-${name}-${version}";
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 $out
hash=$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' ${allCabalFiles}/${name}/${version}/${name}.json)
cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} --sha256=$hash ${allCabalFiles}/${name}/${version}/${name}.cabal >$out/default.nix
'';
};
in
import ./hackage-packages.nix { inherit pkgs stdenv callPackage; } self // {

View file

@ -85,25 +85,4 @@ rec {
triggerRebuild = drv: i: overrideCabal drv (drv: { postUnpack = ": trigger rebuild ${toString i}"; });
allCabalFiles = pkgs.fetchFromGitHub {
owner = "commercialhaskell";
repo = "all-cabal-hashes";
rev = "461610ab6f0cf581e186643c037f1981755792d9";
sha256 = "0x2577lfd5cbbaivl72273kw93gcmxvbjybk7w4h2ic3zvs1fnvm";
};
hackage2nix = name: version: pkgs.stdenv.mkDerivation {
name = "cabal2nix-${name}-${version}";
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 $out
hash=$(sed -e 's/.*"SHA256":"//' -e 's/".*$//' ${allCabalFiles}/${name}/${version}/${name}.json)
cabal2nix --sha256=$hash ${allCabalFiles}/${name}/${version}/${name}.cabal >$out/default.nix
'';
};
}