Add callCabal2nix to haskell packages
Closes https://github.com/NixOS/nixpkgs/pull/22191.
This commit is contained in:
parent
dd934beb9f
commit
05ee54782e
@ -55,18 +55,26 @@ 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/".*$//' ${all-cabal-hashes}/${name}/${version}/${name}.json)
|
||||
cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} --sha256=$hash ${all-cabal-hashes}/${name}/${version}/${name}.cabal >$out/default.nix
|
||||
'';
|
||||
haskellSrc2nix = { name, src, sha256 ? null }:
|
||||
let
|
||||
sha256Arg = if isNull sha256 then "" else ''--sha256="${sha256}"'';
|
||||
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";
|
||||
};
|
||||
|
||||
in
|
||||
@ -76,6 +84,12 @@ let
|
||||
|
||||
callHackage = name: version: self.callPackage (hackage2nix name version);
|
||||
|
||||
# Creates a Haskell package from a source package by calling cabal2nix on the source.
|
||||
callCabal2nix = src: self.callPackage (haskellSrc2nix {
|
||||
inherit src;
|
||||
name = src.name;
|
||||
});
|
||||
|
||||
ghcWithPackages = selectFrom: withPackages (selectFrom self);
|
||||
|
||||
ghcWithHoogle = selectFrom:
|
||||
|
Loading…
Reference in New Issue
Block a user