fix(nix): intercept callCabal2nix to patch inter-hub-models
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled

Previous attempt failed: inter-hub-models is not a named attribute in
haskellPackages (IHP creates it via callCabal2nix locally), so the
hasAttr guard bailed silently.

New approach: override callCabal2nix itself. When called with
name == "inter-hub-models", inject a postUnpack phase that copies
TypesPart1/TypesPart2 into the build sandbox and replaces Types.hs
with the thin wrapper. Applied to both haskellPackages and
haskell.packages.ghc910 to cover whichever set IHP uses.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 00:38:12 +02:00
parent 4d788c2f8a
commit 3283ad62ee

View File

@@ -20,14 +20,21 @@
# GHC 9.10.3 crash fix: Generated.Types imports 119 modules, pushing the # GHC 9.10.3 crash fix: Generated.Types imports 119 modules, pushing the
# combined interface-file read past a ~287 MB binary-deserialization limit. # combined interface-file read past a ~287 MB binary-deserialization limit.
# We patch the inter-hub-models derivation (after build-generated-code runs) #
# to replace Generated.Types with a thin re-export of two split modules that # inter-hub-models is NOT a named attribute in haskellPackages — IHP creates
# are already maintained in build/Generated/TypesPart{1,2}.hs. # it as a local derivation via callCabal2nix. We intercept at callCabal2nix:
# when called with name "inter-hub-models", we add a postUnpack phase that
# injects TypesPart1/TypesPart2 and replaces Types.hs with a thin wrapper.
#
# Applied to both haskellPackages (IHP's modified default set) and
# haskell.packages.ghc910 (the specific GHC version, whichever IHP uses).
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: prev: { (let
haskellPackages = prev.haskellPackages.extend (hfinal: hprev: patchCallCabal2nix = hsPackages: hsPackages.extend (hfinal: hprev: {
if builtins.hasAttr "inter-hub-models" hprev then { callCabal2nix = name: src: args:
"inter-hub-models" = hprev."inter-hub-models".overrideAttrs (old: { let drv = hprev.callCabal2nix name src args;
in if name == "inter-hub-models"
then drv.overrideAttrs (old: {
postUnpack = (old.postUnpack or "") + '' postUnpack = (old.postUnpack or "") + ''
cp ${./build/Generated/TypesPart1.hs} \ cp ${./build/Generated/TypesPart1.hs} \
"$sourceRoot/build/Generated/TypesPart1.hs" "$sourceRoot/build/Generated/TypesPart1.hs"
@@ -51,9 +58,17 @@
}{print}' "$cabal_file" > /tmp/patched-models.cabal }{print}' "$cabal_file" > /tmp/patched-models.cabal
mv /tmp/patched-models.cabal "$cabal_file" mv /tmp/patched-models.cabal "$cabal_file"
''; '';
})
else drv;
}); });
} else {} in final: prev: {
); # IHP likely rewrites haskellPackages to point to GHC 9.10.3; cover both.
haskellPackages = patchCallCabal2nix prev.haskellPackages;
haskell = prev.haskell // {
packages = prev.haskell.packages // {
ghc910 = patchCallCabal2nix prev.haskell.packages.ghc910;
};
};
}) })
]; ];