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
|
# 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;
|
||||||
postUnpack = (old.postUnpack or "") + ''
|
in if name == "inter-hub-models"
|
||||||
cp ${./build/Generated/TypesPart1.hs} \
|
then drv.overrideAttrs (old: {
|
||||||
"$sourceRoot/build/Generated/TypesPart1.hs"
|
postUnpack = (old.postUnpack or "") + ''
|
||||||
cp ${./build/Generated/TypesPart2.hs} \
|
cp ${./build/Generated/TypesPart1.hs} \
|
||||||
"$sourceRoot/build/Generated/TypesPart2.hs"
|
"$sourceRoot/build/Generated/TypesPart1.hs"
|
||||||
printf '%s\n' \
|
cp ${./build/Generated/TypesPart2.hs} \
|
||||||
'-- Split wrapper: GHC 9.10.3 interface-file overflow workaround.' \
|
"$sourceRoot/build/Generated/TypesPart2.hs"
|
||||||
'module Generated.Types (' \
|
printf '%s\n' \
|
||||||
' module Generated.TypesPart1,' \
|
'-- Split wrapper: GHC 9.10.3 interface-file overflow workaround.' \
|
||||||
' module Generated.TypesPart2' \
|
'module Generated.Types (' \
|
||||||
' ) where' \
|
' module Generated.TypesPart1,' \
|
||||||
'import Generated.TypesPart1' \
|
' module Generated.TypesPart2' \
|
||||||
'import Generated.TypesPart2' \
|
' ) where' \
|
||||||
> "$sourceRoot/build/Generated/Types.hs"
|
'import Generated.TypesPart1' \
|
||||||
cabal_file=$(ls "$sourceRoot"/*.cabal | head -1)
|
'import Generated.TypesPart2' \
|
||||||
awk '/Generated\.LearningInsightInclude/{
|
> "$sourceRoot/build/Generated/Types.hs"
|
||||||
print
|
cabal_file=$(ls "$sourceRoot"/*.cabal | head -1)
|
||||||
print " Generated.TypesPart1"
|
awk '/Generated\.LearningInsightInclude/{
|
||||||
print " Generated.TypesPart2"
|
print
|
||||||
next
|
print " Generated.TypesPart1"
|
||||||
}{print}' "$cabal_file" > /tmp/patched-models.cabal
|
print " Generated.TypesPart2"
|
||||||
mv /tmp/patched-models.cabal "$cabal_file"
|
next
|
||||||
'';
|
}{print}' "$cabal_file" > /tmp/patched-models.cabal
|
||||||
});
|
mv /tmp/patched-models.cabal "$cabal_file"
|
||||||
} else {}
|
'';
|
||||||
);
|
})
|
||||||
|
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