diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-14 22:20:09 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-14 22:20:09 -0500 |
| commit | d30ae1657f46855a65d0994bf1c61f454356ff9e (patch) | |
| tree | 855069fe85a1017ff29da8932cc9b900c73b7097 /Omni/Bild/Builder.nix | |
| parent | c071c02345bc9fd272e215b84aa09b9ab942a7ee (diff) | |
Fix module compilation: use custom builder to avoid GHC setup hooks
The haskell.ghcWith package has setup hooks that override buildPhase
even when explicitly set. Solution: use custom builder = stdenv.shell
with args instead of relying on mkDerivation phases.
Changes: - Module derivations: Use custom builder with single -c script
- Combines unpack, build, and install into one script - Explicitly
call ghc with full path to avoid hook interference - Remove unused
objectPaths computation (now using ghc --make with source)
This fixes builds for Omni/Lint.hs, Omni/Task.hs, and all other
Haskell targets with complex dependency graphs.
Diffstat (limited to 'Omni/Bild/Builder.nix')
| -rw-r--r-- | Omni/Bild/Builder.nix | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/Omni/Bild/Builder.nix b/Omni/Bild/Builder.nix index 6610a27..3328b7d 100644 --- a/Omni/Bild/Builder.nix +++ b/Omni/Bild/Builder.nix @@ -185,28 +185,33 @@ with bild; let name = "hs-mod-${sanitize modName}"; src = mkModuleSrc node.nodePath; inherit CODEROOT; - buildInputs = sysdeps_ ++ [ghcPkg] ++ depDrvs; - buildPhase = let - copyDeps = - lib.strings.concatMapStringsSep "\n" (d: '' - cp -rL ${d}/hidir/. hidir/ 2>/dev/null || true - '') - depDrvs; - in '' - mkdir -p hidir odir - ${copyDeps} - chmod -R +w hidir || true - ghc -c \ - -Wall -Werror -haddock -Winvalid-haddock \ - -i. -ihidir \ - -odir odir -hidir hidir \ - ${node.nodePath} - ''; - installPhase = '' - mkdir -p $out/hidir $out/odir - cp -r hidir/* $out/hidir/ || true - cp -r odir/* $out/odir/ || true - ''; + nativeBuildInputs = []; + buildInputs = sysdeps_ ++ depDrvs; + builder = "${stdenv.shell}"; + args = [ + "-c" + (let + copyDeps = + lib.strings.concatMapStringsSep "\n" (d: '' + cp -rL ${d}/hidir/. hidir/ 2>/dev/null || true + '') + depDrvs; + in '' + set -eu + cd $sourceRoot + mkdir -p hidir odir + ${copyDeps} + chmod -R +w hidir || true + ${ghcPkg}/bin/ghc -c \ + -Wall -Werror -haddock -Winvalid-haddock \ + -i. -ihidir \ + -odir odir -hidir hidir \ + ${node.nodePath} + mkdir -p $out/hidir $out/odir + cp -r hidir/* $out/hidir/ || true + cp -r odir/* $out/odir/ || true + '') + ]; }; # Recursive attrset of all module derivations @@ -215,11 +220,6 @@ with bild; let (modName: node: mkModuleDrv modName node (map (dep: builtins.getAttr dep self) node.nodeImports)) graph.graphModules); - - # Compute exact object paths at eval time - moduleToObjPath = modName: drv: "${drv}/odir/${lib.strings.replaceStrings ["."] ["/"] modName}.o"; - objectPaths = - lib.attrsets.mapAttrsToList moduleToObjPath modules; in # Final link derivation stdenv.mkDerivation rec { @@ -230,8 +230,7 @@ with bild; let pkgFlags = lib.strings.concatMapStringsSep " " (p: "-package ${p}") target.langdeps; copyHiFiles = lib.strings.concatMapStringsSep "\n" (drv: "cp -rL ${drv}/hidir/. . 2>/dev/null || true") (lib.attrsets.attrValues modules); in '' - set -eux - echo "Starting custom link phase with ${builtins.toString (builtins.length objectPaths)} object files" + set -eu ${copyHiFiles} chmod -R +w . || true ${ghcPkg}/bin/ghc --make \ @@ -241,7 +240,6 @@ with bild; let -threaded \ -o ${name} \ ${lib.optionalString (target.mainModule != "Main") "-main-is ${target.mainModule}"} - echo "Link completed successfully" ''; installPhase = '' install -D ${name} $out/bin/${name} |
