@@ -0,0 +1,86 @@
1+{ mkStackPkgSet, callStackToNix, importAndFilterProject
2+, stdenv, gmp6, openssl, zlib, libffi
10+ stack-pkgs = (importAndFilterProject (callStackToNix {
14+ # Grab the compiler name from stack-to-nix output.
15+ # compiler = (stack-pkgs.extras {}).compiler.nix-name;
16+ compiler = "ghc865"; # fixme
18+ pkgSet = { gpl ? true }: mkStackPkgSet {
22+ # Musl libc fully static build
26+ (openssl.override { static = true; }).out
27+ (libffi.overrideAttrs (oldAttrs: {
28+ dontDisableStatic = true;
29+ configureFlags = (oldAttrs.configureFlags or []) ++ [
34+ ] ++ optional gpl (gmp6.override { withStatic = true; });
38+ optionals stdenv.hostPlatform.isMusl ([
39+ "--disable-executable-dynamic"
41+ "--ghc-option=-optl=-pthread"
42+ "--ghc-option=-optl=-static"
43+ ] ++ map (drv: "--ghc-option=-optl=-L${drv}/lib") staticLibs);
46+ # Select a non-GMP compiler, usually for software licensing reasons.
47+ ghc.package = mkIf (stdenv.hostPlatform.isMusl && !gpl)
48+ buildPackages.haskell.compiler.integer-simple.${compiler};
50+ # Add GHC flags and libraries for fully static build
51+ packages.pandoc.components.exes.pandoc = withFullyStatic;
55+ packagesGmp = (pkgSet { gpl = true; }).config.hsPkgs;
56+ packagesIntegerSimple = (pkgSet { gpl = false; }).config.hsPkgs;
58+ stdenv.mkDerivation {
59+ name = "fully-static-test";
61+ depsBuildBuild = [ buildPackages.file ];
63+ buildCommand = flip concatMapStrings
64+ [ packagesGmp /* packagesIntegerSimple */ ]
66+ exe="${packages.pandoc.components.exes.pandoc}/bin/pandoc"
68+ printf "checking whether executable runs... " >& 2
71+ '' + optionalString stdenv.hostPlatform.isMusl ''
72+ printf "checking whether executable is static... " >& 2
74+ file $exe | grep "statically linked"
78+ meta.platforms = platforms.all;
81+ # Attributes used for debugging with nix repl
82+ inherit pkgSet buildPackages stack-pkgs;
83+ pandoc-gmp = packagesGmp.pandoc.components.exes.pandoc;
84+ pandoc-integer-simple = packagesIntegerSimple.pandoc.components.exes.pandoc;