forked from mirrors/nixpkgs
f031f3105a
-split-sections replaced -split-objs with following upsides: 1) -split-objs adds considerable overhead to compile time 2) combined with stripping, it causes issues when cross-compiling For upstream see https://ghc.haskell.org/trac/ghc/ticket/8405 This is supported only for Linux/Windows using ld linker. GHC master also turns on -split-sections by default. Example using stack: Without splitting $ du /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2 4 /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share/bash-completion/completions 4 /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share/bash-completion 4 /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/share 23416 /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2/bin 23420 /nix/store/5paayhibayr73zqfaj458g4k4mv108jn-stack-1.3.2 With -split-objs $ du /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2 20632 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/bin 4 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share/bash-completion/completions 4 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share/bash-completion 4 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2/share 20636 /nix/store/fypymm529adpx71gdzm0851xz42wdbz0-stack-1.3.2 With -split-sections $ du /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2 4 /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share/bash-completion/completions 4 /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share/bash-completion 4 /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/share 20672 /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2/bin 20676 /nix/store/40l6krinx1zx41lr87c4m12hxj4ldf3x-stack-1.3.2 Note: you currently need following overrides to build stack on 802: vector-algorithms = dontCheck super.vector-algorithms; path-io = doJailbreak super.path-io; stack = doJailbreak super.stack; Note: Should also work on GHC 8.0.1, but I'm being careful here. We could backport later on.
91 lines
4.2 KiB
Nix
91 lines
4.2 KiB
Nix
{ pkgs }:
|
|
|
|
rec {
|
|
|
|
overrideCabal = drv: f: (drv.override (args: args // {
|
|
mkDerivation = drv: args.mkDerivation (drv // f drv);
|
|
})) // {
|
|
overrideScope = scope: overrideCabal (drv.overrideScope scope) f;
|
|
};
|
|
|
|
doHaddock = drv: overrideCabal drv (drv: { doHaddock = true; });
|
|
dontHaddock = drv: overrideCabal drv (drv: { doHaddock = false; });
|
|
|
|
doJailbreak = drv: overrideCabal drv (drv: { jailbreak = true; });
|
|
dontJailbreak = drv: overrideCabal drv (drv: { jailbreak = false; });
|
|
|
|
doCheck = drv: overrideCabal drv (drv: { doCheck = true; });
|
|
dontCheck = drv: overrideCabal drv (drv: { doCheck = false; });
|
|
|
|
doDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = drv.platforms or ["i686-linux" "x86_64-linux" "x86_64-darwin"]; });
|
|
dontDistribute = drv: overrideCabal drv (drv: { hydraPlatforms = []; });
|
|
|
|
appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
|
|
removeConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = pkgs.stdenv.lib.remove x (drv.configureFlags or []); });
|
|
|
|
addBuildTool = drv: x: addBuildTools drv [x];
|
|
addBuildTools = drv: xs: overrideCabal drv (drv: { buildTools = (drv.buildTools or []) ++ xs; });
|
|
|
|
addExtraLibrary = drv: x: addExtraLibraries drv [x];
|
|
addExtraLibraries = drv: xs: overrideCabal drv (drv: { extraLibraries = (drv.extraLibraries or []) ++ xs; });
|
|
|
|
addBuildDepend = drv: x: addBuildDepends drv [x];
|
|
addBuildDepends = drv: xs: overrideCabal drv (drv: { buildDepends = (drv.buildDepends or []) ++ xs; });
|
|
|
|
addPkgconfigDepend = drv: x: addPkgconfigDepends drv [x];
|
|
addPkgconfigDepends = drv: xs: overrideCabal drv (drv: { pkgconfigDepends = (drv.pkgconfigDepends or []) ++ xs; });
|
|
|
|
enableCabalFlag = drv: x: appendConfigureFlag (removeConfigureFlag drv "-f-${x}") "-f${x}";
|
|
disableCabalFlag = drv: x: appendConfigureFlag (removeConfigureFlag drv "-f${x}") "-f-${x}";
|
|
|
|
markBroken = drv: overrideCabal drv (drv: { broken = true; });
|
|
markBrokenVersion = version: drv: assert drv.version == version; markBroken drv;
|
|
|
|
enableLibraryProfiling = drv: overrideCabal drv (drv: { enableLibraryProfiling = true; });
|
|
disableLibraryProfiling = drv: overrideCabal drv (drv: { enableLibraryProfiling = false; });
|
|
|
|
enableSharedExecutables = drv: overrideCabal drv (drv: { enableSharedExecutables = true; });
|
|
disableSharedExecutables = drv: overrideCabal drv (drv: { enableSharedExecutables = false; });
|
|
|
|
enableSharedLibraries = drv: overrideCabal drv (drv: { enableSharedLibraries = true; });
|
|
disableSharedLibraries = drv: overrideCabal drv (drv: { enableSharedLibraries = false; });
|
|
|
|
enableDeadCodeElimination = drv: overrideCabal drv (drv: { enableDeadCodeElimination = true; });
|
|
disableDeadCodeElimination = drv: overrideCabal drv (drv: { enableDeadCodeElimination = false; });
|
|
|
|
enableStaticLibraries = drv: overrideCabal drv (drv: { enableStaticLibraries = true; });
|
|
disableStaticLibraries = drv: overrideCabal drv (drv: { enableStaticLibraries = false; });
|
|
|
|
appendPatch = drv: x: appendPatches drv [x];
|
|
appendPatches = drv: xs: overrideCabal drv (drv: { patches = (drv.patches or []) ++ xs; });
|
|
|
|
doHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = true; });
|
|
dontHyperlinkSource = drv: overrideCabal drv (drv: { hyperlinkSource = false; });
|
|
|
|
disableHardening = drv: flags: overrideCabal drv (drv: { hardeningDisable = flags; });
|
|
|
|
sdistTarball = pkg: pkgs.lib.overrideDerivation pkg (drv: {
|
|
name = "${drv.pname}-source-${drv.version}";
|
|
buildPhase = "./Setup sdist";
|
|
haddockPhase = ":";
|
|
checkPhase = ":";
|
|
installPhase = "install -D dist/${drv.pname}-*.tar.gz $out/${drv.pname}-${drv.version}.tar.gz";
|
|
fixupPhase = ":";
|
|
});
|
|
|
|
buildFromSdist = pkg: pkgs.lib.overrideDerivation pkg (drv: {
|
|
unpackPhase = let src = sdistTarball pkg; tarname = "${pkg.pname}-${pkg.version}"; in ''
|
|
echo "Source tarball is at ${src}/${tarname}.tar.gz"
|
|
tar xf ${src}/${tarname}.tar.gz
|
|
cd ${pkg.pname}-*
|
|
'';
|
|
});
|
|
|
|
buildStrictly = pkg: buildFromSdist (appendConfigureFlag pkg "--ghc-option=-Wall --ghc-option=-Werror");
|
|
|
|
buildStackProject = pkgs.callPackage ./generic-stack-builder.nix { };
|
|
|
|
triggerRebuild = drv: i: overrideCabal drv (drv: { postUnpack = ": trigger rebuild ${toString i}"; });
|
|
|
|
}
|