writeHaskell: allow providing function for libraries

This is much safer at avoiding version mismatches.
This commit is contained in:
Lin Jian
2026-05-06 01:47:30 +08:00
parent a52a4f0adc
commit 7a72b3ecb5
+3 -2
View File
@@ -17,6 +17,7 @@ let
last
optionalString
strings
toFunction
types
;
in
@@ -751,7 +752,7 @@ rec {
## `pkgs.writers.writeHaskell` usage example
```nix
writeHaskell "missiles" { libraries = [ pkgs.haskellPackages.acme-missiles ]; } ''
writeHaskell "missiles" { libraries = hpkgs: [ hpkgs.acme-missiles ]; } ''
import Acme.Missiles
main = launchMissiles
@@ -777,7 +778,7 @@ rec {
makeBinWriter {
compileScript = ''
cp $contentPath tmp.hs
${(ghc.withPackages (_: libraries))}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
${(ghc.withPackages (toFunction libraries))}/bin/ghc ${lib.escapeShellArgs ghcArgs'} tmp.hs
mv tmp $out
'';
inherit makeWrapperArgs strip;