generated from coulomb/repo-seed
fix(nix): intercept callCabal2nix to patch inter-hub-models
Some checks failed
Build and Deploy / build-push-deploy (push) Has been cancelled
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:
81
flake.nix
81
flake.nix
@@ -20,40 +20,55 @@
|
||||
|
||||
# GHC 9.10.3 crash fix: Generated.Types imports 119 modules, pushing the
|
||||
# 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
|
||||
# are already maintained in build/Generated/TypesPart{1,2}.hs.
|
||||
#
|
||||
# inter-hub-models is NOT a named attribute in haskellPackages — IHP creates
|
||||
# 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 = [
|
||||
(final: prev: {
|
||||
haskellPackages = prev.haskellPackages.extend (hfinal: hprev:
|
||||
if builtins.hasAttr "inter-hub-models" hprev then {
|
||||
"inter-hub-models" = hprev."inter-hub-models".overrideAttrs (old: {
|
||||
postUnpack = (old.postUnpack or "") + ''
|
||||
cp ${./build/Generated/TypesPart1.hs} \
|
||||
"$sourceRoot/build/Generated/TypesPart1.hs"
|
||||
cp ${./build/Generated/TypesPart2.hs} \
|
||||
"$sourceRoot/build/Generated/TypesPart2.hs"
|
||||
printf '%s\n' \
|
||||
'-- Split wrapper: GHC 9.10.3 interface-file overflow workaround.' \
|
||||
'module Generated.Types (' \
|
||||
' module Generated.TypesPart1,' \
|
||||
' module Generated.TypesPart2' \
|
||||
' ) where' \
|
||||
'import Generated.TypesPart1' \
|
||||
'import Generated.TypesPart2' \
|
||||
> "$sourceRoot/build/Generated/Types.hs"
|
||||
cabal_file=$(ls "$sourceRoot"/*.cabal | head -1)
|
||||
awk '/Generated\.LearningInsightInclude/{
|
||||
print
|
||||
print " Generated.TypesPart1"
|
||||
print " Generated.TypesPart2"
|
||||
next
|
||||
}{print}' "$cabal_file" > /tmp/patched-models.cabal
|
||||
mv /tmp/patched-models.cabal "$cabal_file"
|
||||
'';
|
||||
});
|
||||
} else {}
|
||||
);
|
||||
(let
|
||||
patchCallCabal2nix = hsPackages: hsPackages.extend (hfinal: hprev: {
|
||||
callCabal2nix = name: src: args:
|
||||
let drv = hprev.callCabal2nix name src args;
|
||||
in if name == "inter-hub-models"
|
||||
then drv.overrideAttrs (old: {
|
||||
postUnpack = (old.postUnpack or "") + ''
|
||||
cp ${./build/Generated/TypesPart1.hs} \
|
||||
"$sourceRoot/build/Generated/TypesPart1.hs"
|
||||
cp ${./build/Generated/TypesPart2.hs} \
|
||||
"$sourceRoot/build/Generated/TypesPart2.hs"
|
||||
printf '%s\n' \
|
||||
'-- Split wrapper: GHC 9.10.3 interface-file overflow workaround.' \
|
||||
'module Generated.Types (' \
|
||||
' module Generated.TypesPart1,' \
|
||||
' module Generated.TypesPart2' \
|
||||
' ) where' \
|
||||
'import Generated.TypesPart1' \
|
||||
'import Generated.TypesPart2' \
|
||||
> "$sourceRoot/build/Generated/Types.hs"
|
||||
cabal_file=$(ls "$sourceRoot"/*.cabal | head -1)
|
||||
awk '/Generated\.LearningInsightInclude/{
|
||||
print
|
||||
print " Generated.TypesPart1"
|
||||
print " Generated.TypesPart2"
|
||||
next
|
||||
}{print}' "$cabal_file" > /tmp/patched-models.cabal
|
||||
mv /tmp/patched-models.cabal "$cabal_file"
|
||||
'';
|
||||
})
|
||||
else drv;
|
||||
});
|
||||
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;
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user