cabal2nix: split into a lightweight version and a wrapper
Current, the `cabal2nix` derivation contains both the executable, and a wrapper that adds `nix` and `nix-prefetch-scripts`, which are required for some features. However, when calling `callCabal2nix` to create a derivation from a cabal file at evaluation time, these features are not actually used, but the huge closure of `nix-prefetch-scripts` (which includes multiple vcs, as well as python and perl) still needs to be fetched. This commit splits cabal2nix into a lightweight version that is a standalone static binary (`cabal2nix-unwrapped`), and a wrapper that includes the proper dependencies in the path for full usage of the command line utility (`cabal2nix`). This commit also switches to the default ghc, to reduce the likelyhood of building a different ghc when calling `callCabal2nix`.
This commit is contained in:
parent
c2dcdea8c6
commit
2645e1a1eb
|
@ -124,7 +124,7 @@ let
|
||||||
sha256Arg = if sha256 == null then "--sha256=" else ''--sha256="${sha256}"'';
|
sha256Arg = if sha256 == null then "--sha256=" else ''--sha256="${sha256}"'';
|
||||||
in buildPackages.stdenv.mkDerivation {
|
in buildPackages.stdenv.mkDerivation {
|
||||||
name = "cabal2nix-${name}";
|
name = "cabal2nix-${name}";
|
||||||
nativeBuildInputs = [ buildPackages.cabal2nix ];
|
nativeBuildInputs = [ buildPackages.cabal2nix-unwrapped ];
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
allowSubstitutes = false;
|
allowSubstitutes = false;
|
||||||
phases = ["installPhase"];
|
phases = ["installPhase"];
|
||||||
|
|
|
@ -1342,19 +1342,17 @@ in
|
||||||
|
|
||||||
cue2pops = callPackage ../tools/cd-dvd/cue2pops { };
|
cue2pops = callPackage ../tools/cd-dvd/cue2pops { };
|
||||||
|
|
||||||
cabal2nix = haskell.lib.overrideCabal (haskell.lib.generateOptparseApplicativeCompletion "cabal2nix" haskell.packages.ghc881.cabal2nix) (drv: {
|
cabal2nix-unwrapped = haskell.lib.justStaticExecutables (haskell.lib.generateOptparseApplicativeCompletion "cabal2nix" haskellPackages.cabal2nix);
|
||||||
isLibrary = false;
|
|
||||||
enableSharedExecutables = false;
|
cabal2nix = symlinkJoin {
|
||||||
executableToolDepends = (drv.executableToolDepends or []) ++ [ makeWrapper ];
|
inherit (cabal2nix-unwrapped) name meta;
|
||||||
postInstall = ''
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
exe=$out/libexec/${drv.pname}-${drv.version}/${drv.pname}
|
paths = [ cabal2nix-unwrapped ];
|
||||||
install -D $out/bin/${drv.pname} $exe
|
postBuild = ''
|
||||||
rm -rf $out/{bin,lib,share}
|
wrapProgram $out/bin/cabal2nix \
|
||||||
makeWrapper $exe $out/bin/${drv.pname} \
|
--prefix PATH ":" "${lib.makeBinPath [ nix nix-prefetch-scripts ]}"
|
||||||
--prefix PATH ":" "${nix}/bin" \
|
'';
|
||||||
--prefix PATH ":" "${nix-prefetch-scripts}/bin"
|
};
|
||||||
'' + (drv.postInstall or "");
|
|
||||||
});
|
|
||||||
|
|
||||||
stack2nix = with haskell.lib; overrideCabal (justStaticExecutables haskellPackages.stack2nix) (drv: {
|
stack2nix = with haskell.lib; overrideCabal (justStaticExecutables haskellPackages.stack2nix) (drv: {
|
||||||
executableToolDepends = [ makeWrapper ];
|
executableToolDepends = [ makeWrapper ];
|
||||||
|
|
Loading…
Reference in New Issue