Skip to content

Commit 63232fc

Browse files
committed
Fix more packages. workingStackageExecutables builds on top of nixos-23.05.
Only minimal patches are put on top of the `nixos-23.05` branch to support more of Stackage. All have nixpkgs PRs. nix-build --no-link survey/default.nix -A workingStackageExecutables | wc -l 368
1 parent 5793932 commit 63232fc

File tree

3 files changed

+68
-5
lines changed

3 files changed

+68
-5
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ Until Stack 2.3, the official static build of `stack` itself was built using thi
104104
The [`static-stack`](./static-stack) directory shows how Stack itself can be built statically with static-haskell-nix.
105105
`stack` is a big package with many dependencies, demonstrating that it works also for large projects.
106106

107+
## Related important open issues
108+
109+
You can contribute to these to help static Haskell executables:
110+
111+
* https://github.com/haskell/cabal/issues/8455
112+
107113
## FAQ
108114

109115
* I get `cannot find section .dynamic`. Is this an error?
@@ -116,6 +122,13 @@ The [`static-stack`](./static-stack) directory shows how Stack itself can be bui
116122
then `/nix/store/dax3wjbjfrcwj6r3mafxj5fx6wcg5zbp-stack-2.3.0.1` is your final output _store path_ whose `/bin` directory contains your static executable.
117123
* I get `stack2nix: user error (No such package mypackage-1.2.3 in the cabal database. Did you run cabal update?)`.
118124
* You most likely have to bump the date like `hackageSnapshot = "2019-05-08T00:00:00Z";` to a newer date (past the time that package-version was added to Hackage).
125+
* I get a linker error.
126+
What's a good way to investigate what the linker invocation is?
127+
* Pass `-v` to Cabal, and to GHC itself:
128+
```sh
129+
nix-build --expr '(import ./survey/default.nix {}).haskellPackages.YOURPACKAGE.overrideAttrs (old: { configureFlags = (old.configureFlags or []) ++ ["-v" "--ghc-options=-v"]; })'
130+
```
131+
Look for `*** Linker:` in the GHC output.
119132
* Can I build Stack projects with resolvers that are too old to be supported by Stack >= 2?
120133
* No. For that you need need to use an old `static-haskell-nix` version: The one before [this PR](https://github.com/nh2/static-haskell-nix/pull/98) was merged.
121134
* I get some other error. Can I just file an issue and have you help me with it?

nixpkgs

survey/default.nix

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,9 @@ let
719719

720720
openblas = (previous.openblas.override { enableStatic = true; });
721721

722+
libusb1 = previous.libusb1.override { withStatic = true; enableUdev = false; };
723+
libusb-compat-0_1 = previous.libusb-compat-0_1.overrideAttrs (old: { dontDisableStatic = true; });
724+
722725
openssl = previous.openssl.override { static = true; };
723726

724727
zstd = previous.zstd.override { enableStatic = true; };
@@ -737,14 +740,35 @@ let
737740
staticOnly = true;
738741
};
739742

740-
# Brotli can currently build only static or shared libraries,
741-
# see https://github.com/google/brotli/pull/655#issuecomment-864395830
742-
brotli = previous.brotli.override { staticOnly = true; };
743+
# For unclear reasons, brotli builds its `.a` files by default, but adds a `-static`
744+
# infix to their names:
745+
#
746+
# libbrotlicommon-static.a
747+
# libbrotlidec-static.a
748+
# libbrotlienc-static.a
749+
#
750+
# Its pkg-config `.pc` file thus does not support static linking. See:
751+
# https://github.com/google/brotli/issues/795#issuecomment-1373595520
752+
# and
753+
# https://github.com/google/brotli/pull/655#issuecomment-864395830
754+
#
755+
# In my opinion this is rather pointless, because `.a` files are always "static".
756+
#
757+
# We correct it here by renaming the files accordingly.
758+
brotli = previous.brotli.overrideAttrs (old: {
759+
postInstall = ''
760+
for f in "$lib"/lib/*-static.a; do
761+
ln -s --verbose "$f" "$(dirname "$f")/$(basename "$f" '-static.a').a"
762+
done
763+
'';
764+
});
743765

744766
# woff2 currently builds against the `brotli` static libs only with a patch
745767
# that's enabled by its `static` argument.
746768
woff2 = previous.woff2.override { static = true; };
747769

770+
libnfc = previous.libnfc.override { static = true; };
771+
748772
# See comments on `statify_curl_including_exe` for the interaction with krb5!
749773
# As mentioned in [Packages that cause bootstrap compiler recompilation], we can't
750774
# override zlib to have static libs, so we have to pass in `zlib_both` explicitly
@@ -890,6 +914,11 @@ let
890914
# putting `curl_static` into `libraryPkgconfigDepends` is enough
891915
# and the manual modification of `configureFlags` is not necessary.
892916
libraryPkgconfigDepends = (old.libraryPkgconfigDepends or []) ++ pkgConfigNixPackages;
917+
# `generic-builder.nix` already adds `pkg-config` as a `nativeBuildInput`
918+
# e.g. if `libraryPkgconfigDepends` is not empty, but if it was, and we
919+
# override it here, it does not notice, so we add `pkg-config` explicitly
920+
# in that case.
921+
buildTools = (old.buildTools or []) ++ [ pkgs.pkg-config ];
893922
});
894923

895924

@@ -1272,6 +1301,13 @@ let
12721301
[ final.openssl ]
12731302
"--libs openssl";
12741303

1304+
# This one needs `libcrypto` explicitly for reasons not yet investigated. `libpq` should pull it in via `openssl`.
1305+
postgresql-migration =
1306+
addStaticLinkerFlagsWithPkgconfig
1307+
super.postgresql-migration
1308+
[ final.openssl final.postgresql ]
1309+
"--libs libpq libcrypto";
1310+
12751311
xml-to-json =
12761312
addStaticLinkerFlagsWithPkgconfig
12771313
super.xml-to-json
@@ -1283,6 +1319,12 @@ let
12831319
# See https://github.com/curl/curl/issues/2775 for an investigation of why.
12841320
"--libs-only-L --libs-only-l libcurl expat";
12851321

1322+
nfc =
1323+
addStaticLinkerFlagsWithPkgconfig
1324+
super.nfc
1325+
[ final.libusb-compat-0_1 final.libusb1 ]
1326+
"--libs libusb";
1327+
12861328
# This package's dependency `rounded` currently fails its test with a patterm match error.
12871329
aern2-real =
12881330
addStaticLinkerFlagsWithPkgconfig
@@ -1664,20 +1706,28 @@ in
16641706
"cuda" # needs `allowUnfree = true`; enabling it gives `unsupported platform for the pure Linux stdenv`
16651707
"debug" # `regex-base <0.94` on `regex-tdfa-text`
16661708
"diagrams-builder" # `template-haskell >=2.5 && <2.16` on `size-based`
1709+
"diagrams-cairo" # `gtk2hs` bug building `glib`: https://github.com/nh2/static-haskell-nix/issues/4#issuecomment-1634681846
16671710
"gloss-examples" # `base >=4.8 && <4.14` on `repa-io`
1711+
"gtk-sni-tray" # needs `gi-gtk` which requires `glib` which is problematic
16681712
"gtk3" # Haskell package `glib` fails with `Ambiguous module name ‘Gtk2HsSetup’: it was found in multiple packages: gtk2hs-buildtools-0.13.8.0 gtk2hs-buildtools-0.13.8.0`
1669-
"H" # error: anonymous function at pkgs/applications/science/math/R/default.nix:1:1 called with unexpected argument 'javaSupport', at lib/customisation.nix:69:16
1713+
"H" # error: anonymous fun2rsyHqx27f4EQHEUjWU/libHScipher-aes-0.2.11-CpO2rsyHqx27f4EQHEUjWU.a(gf.o):(.text+0x0): first defined herection at pkgs/applications/science/math/R/default.nix:1:1 called with unexpected argument 'javaSupport', at lib/customisation.nix:69:16
1714+
"hackage-cli" # error: error: multiple definition of `gf_mul'; /nix/store/...-cipher-aes-0.2.11/lib/ghc-9.2.7/x86_64-linux-ghc-9.2.7/cipher-aes-0.2.11-[..]/libHScipher-aes-0.2.11-[..].a(gf.o):(.text+0x0): first defined here
16701715
"hamilton" # `_gfortran_concat_string` linker error via openblas
16711716
"hquantlib" # `time >=1.4.0.0 && <1.9.0.0` on `hquantlib-time`
16721717
"ihaskell" # linker error
16731718
"LambdaHack" # fails `systemd` dependency erroring on `#include <printf.h>`
16741719
"language-puppet" # `base >=4.6 && <4.14, ghc-prim >=0.3 && <0.6` for dependency `protolude`
16751720
"learn-physics" # needs opengl: `cannot find -lGLU` `-lGL`
1721+
"LPFP" # `gtk2hs` bug building `glib`: https://github.com/nh2/static-haskell-nix/issues/4#issuecomment-1634681846
16761722
"magico" # undefined reference to `_gfortran_concat_string'
1723+
"monomer" # needs `nanovg` which is in this list
1724+
"nanovg" # needs opengl: `cannot find -lGLU` `-lGL`
16771725
"odbc" # `odbcss.h: No such file or directory`
1726+
"pango" # `gtk2hs` bug building `glib`: https://github.com/nh2/static-haskell-nix/issues/4#issuecomment-1634681846
16781727
"qchas" # `_gfortran_concat_string` linker error via openblas
16791728
"rhine-gloss" # needs opengl: `cannot find -lGLU` `-lGL`
16801729
"soxlib" # fails `systemd` dependency erroring on `#include <printf.h>`
1730+
"termonad" # needs `glib` which is problematic
16811731
];
16821732

16831733
inherit normalPkgs;

0 commit comments

Comments
 (0)