diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 53d810372a4..4499f260d60 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -961,4 +961,14 @@ self: super: { sha256 = "0xa5b7i9wx32ji0zzlh1a1pws677iffby3bg39kv3c9srdb4by1g"; })]; }); + + # GLUT uses `dlopen` to link to freeglut, so we need to set the RUNPATH correctly for + # it to find `libglut.so` from the nix store. We do this by patching GLUT.cabal to pkg-config + # depend on freeglut, which provides GHC to necessary information to generate a correct RPATH. + # + # Note: Simply patching the dynamic library (.so) of the GLUT build will *not* work, since the + # RPATH also needs to be propagated when using static linking. GHC automatically handles this for + # us when we patch the cabal file (Link options will be recored in the ghc package registry). + GLUT = addPkgconfigDepend (appendPatch super.GLUT ./patches/GLUT.patch) pkgs.freeglut; + } diff --git a/pkgs/development/haskell-modules/patches/GLUT.patch b/pkgs/development/haskell-modules/patches/GLUT.patch new file mode 100644 index 00000000000..3025812213b --- /dev/null +++ b/pkgs/development/haskell-modules/patches/GLUT.patch @@ -0,0 +1,12 @@ +diff --git a/GLUT.cabal b/GLUT.cabal +index f370d6c..a404e1e 100644 +--- a/GLUT.cabal ++++ b/GLUT.cabal +@@ -103,6 +103,7 @@ library + else + cpp-options: "-DCALLCONV=ccall" + cc-options: "-DUSE_DLSYM" ++ pkgconfig-depends: freeglut + + executable BOGLGP01-OnYourOwn1 + if !flag(BuildExamples)