on iko/ghcjs-patch-master help sign in
tests: Add test case with fully static build of pandoc (#256)
e4a572bRodney Lorrimar
@@ -24,6 +24,7 @@ in pkgs.recurseIntoAttrs {
24 buildable = haskell.callPackage ./buildable {};
24 buildable = haskell.callPackage ./buildable {};
25 project-flags-cabal = haskell.callPackage ./project-flags/cabal.nix {};
25 project-flags-cabal = haskell.callPackage ./project-flags/cabal.nix {};
26 project-flags-stack = haskell.callPackage ./project-flags/stack.nix {};
26 project-flags-stack = haskell.callPackage ./project-flags/stack.nix {};
27+ fully-static = haskell.callPackage ./fully-static { inherit (pkgs) buildPackages; };
27 ghc-options-cabal = haskell.callPackage ./ghc-options/cabal.nix {};
28 ghc-options-cabal = haskell.callPackage ./ghc-options/cabal.nix {};
28 ghc-options-stack = haskell.callPackage ./ghc-options/stack.nix {};
29 ghc-options-stack = haskell.callPackage ./ghc-options/stack.nix {};
29
30
test/fully-static/cross.nixnew file+15
@@ -0,0 +1,15 @@
1+{ pkgs ? import nixpkgs { }
2+, nixpkgs ? ../../nixpkgs
3+}:
4+
5+let
6+ pkgs' = pkgs.pkgsCross.musl64;
7+ haskellMusl64 = pkgs.callPackage ../../. { pkgs = pkgs'; };
8+
9+ test = haskellMusl64.callPackage ./default.nix {
10+ inherit (pkgs') buildPackages;
11+ };
12+
13+in {
14+ inherit (test) pandoc-gmp pandoc-integer-simple;
15+}
test/fully-static/default.nixnew file+86
@@ -0,0 +1,86 @@
1+{ mkStackPkgSet, callStackToNix, importAndFilterProject
2+, stdenv, gmp6, openssl, zlib, libffi
3+, buildPackages
4+}:
5+
6+with stdenv.lib;
7+
8+let
9+ # IFD stack-to-nix
10+ stack-pkgs = (importAndFilterProject (callStackToNix {
11+ src = ./.;
12+ })).pkgs;
13+
14+ # Grab the compiler name from stack-to-nix output.
15+ # compiler = (stack-pkgs.extras {}).compiler.nix-name;
16+ compiler = "ghc865"; # fixme
17+
18+ pkgSet = { gpl ? true }: mkStackPkgSet {
19+ inherit stack-pkgs;
20+ pkg-def-extras = [];
21+ modules = [
22+ # Musl libc fully static build
23+ (let
24+ staticLibs = [
25+ zlib.static
26+ (openssl.override { static = true; }).out
27+ (libffi.overrideAttrs (oldAttrs: {
28+ dontDisableStatic = true;
29+ configureFlags = (oldAttrs.configureFlags or []) ++ [
30+ "--enable-static"
31+ "--disable-shared"
32+ ];
33+ }))
34+ ] ++ optional gpl (gmp6.override { withStatic = true; });
35+
36+ withFullyStatic = {
37+ configureFlags =
38+ optionals stdenv.hostPlatform.isMusl ([
39+ "--disable-executable-dynamic"
40+ "--disable-shared"
41+ "--ghc-option=-optl=-pthread"
42+ "--ghc-option=-optl=-static"
43+ ] ++ map (drv: "--ghc-option=-optl=-L${drv}/lib") staticLibs);
44+ };
45+ in {
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};
49+
50+ # Add GHC flags and libraries for fully static build
51+ packages.pandoc.components.exes.pandoc = withFullyStatic;
52+ })
53+ ];
54+ };
55+ packagesGmp = (pkgSet { gpl = true; }).config.hsPkgs;
56+ packagesIntegerSimple = (pkgSet { gpl = false; }).config.hsPkgs;
57+in
58+ stdenv.mkDerivation {
59+ name = "fully-static-test";
60+
61+ depsBuildBuild = [ buildPackages.file ];
62+
63+ buildCommand = flip concatMapStrings
64+ [ packagesGmp /* packagesIntegerSimple */ ]
65+ (packages: ''
66+ exe="${packages.pandoc.components.exes.pandoc}/bin/pandoc"
67+
68+ printf "checking whether executable runs... " >& 2
69+ $exe --version
70+
71+ '' + optionalString stdenv.hostPlatform.isMusl ''
72+ printf "checking whether executable is static... " >& 2
73+ file $exe
74+ file $exe | grep "statically linked"
75+
76+ '') + "touch $out";
77+
78+ meta.platforms = platforms.all;
79+
80+ passthru = {
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;
85+ };
86+ }
test/fully-static/stack.yamlnew file+6
@@ -0,0 +1,6 @@
1+resolver: lts-13.26
2+
3+extra-deps:
4+ - pandoc-2.7.3
5+ - hslua-module-system-0.2.1
6+ - ipynb-0.1