Skip to content

Commit

Permalink
callHackage: generate expressions for the appropriate target system a…
Browse files Browse the repository at this point in the history
…nd compiler
  • Loading branch information
peti committed Jun 13, 2016
1 parent 322fe54 commit 8d86c82
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
23 changes: 21 additions & 2 deletions pkgs/development/haskell-modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 // {

Expand Down
21 changes: 0 additions & 21 deletions pkgs/development/haskell-modules/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
'';
};

}

0 comments on commit 8d86c82

Please sign in to comment.