From 4130a9f5d49c24bd5c5bc110b8ac2ec2d4f12170 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 16 Jul 2025 16:04:28 +1200 Subject: [PATCH 1/8] Add haskell-nix.templateHaskell.ghcOptions --- overlays/armv6l-linux.nix | 64 ++++++++++++++++++++------------------- overlays/linux-cross.nix | 15 +++------ overlays/mingw_w64.nix | 6 ++-- overlays/windows.nix | 40 +++++++++++++----------- test/cabal.project.local | 2 +- 5 files changed, 64 insertions(+), 63 deletions(-) diff --git a/overlays/armv6l-linux.nix b/overlays/armv6l-linux.nix index e2df3cdaf5..dde8e585df 100644 --- a/overlays/armv6l-linux.nix +++ b/overlays/armv6l-linux.nix @@ -1,42 +1,44 @@ final: prev: +let + isLinuxCross = + prev.haskell-nix.haskellLib.isCrossHost + && prev.hostPlatform.isLinux + && (prev.hostPlatform.isAarch32 + || prev.hostPlatform.isAarch64 + || prev.hostPlatform.isi686); + +in { - haskell-nix = prev.haskell-nix // ({ + haskell-nix = prev.haskell-nix // final.lib.optionalAttrs isLinuxCross ({ + templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes: + import ./linux-cross.nix { + inherit (final.stdenv) hostPlatform buildPlatform; + inherit (final) stdenv lib; + inherit (final.pkgsBuildBuild) writeShellScriptBin symlinkJoin; + inherit (final.haskell-nix) haskellLib; + qemu = final.pkgsBuildBuild.qemu; + inherit (final) gmp; + inherit (iserv-proxy-exes) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof; + }) final.haskell-nix.iserv-proxy-exes; defaultModules = prev.haskell-nix.defaultModules ++ [ ({ pkgs, buildModules, config, lib, ... }: let - withTH = import ./linux-cross.nix { - inherit (pkgs.stdenv) hostPlatform buildPlatform; - inherit (pkgs) stdenv lib; - inherit (pkgs.pkgsBuildBuild) writeShellScriptBin symlinkJoin; - inherit (pkgs.haskell-nix) haskellLib; - # qemu for linux - # Using `buildPackages.buildPackages` here fixes `python3Packages.pygobject3` issue. - qemu = pkgs.buildPackages.buildPackages.qemu; - -# wine = pkgs.buildPackages.winePackages.minimal; -# inherit (pkgs.windows) mingw_w64_pthreads; - inherit (pkgs) gmp; - # iserv-proxy needs to come from the buildPackages, as it needs to run on the - # build host. - inherit (final.haskell-nix.iserv-proxy-exes.${config.compiler.nix-name}) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof; - } // { - # we can perform testing of cross compiled test-suites by using wine. - # Therefore let's enable doCrossCheck here! - doCrossCheck = pkgs.stdenv.hostPlatform.isWindows; - }; + withTH = final.haskell-nix.templateHaskell.${config.compiler.nix-name}; in prev.haskell-nix.haskellLib.addPackageKeys { + inherit (withTH) configureFlags testWrapper; + + setupBuildFlags = map (opt: "--ghc-option=" + opt) withTH.ghcOptions + ++ lib.optionals pkgs.stdenv.hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ]) + # Also for GHC #15275 + ++ lib.optionals pkgs.stdenv.hostPlatform.isAarch64 ["--gcc-option=-fPIC"]; + + enableShared = lib.mkDefault false; + + doCrossCheck = true; + packages = { # clock 0.7.2 needs to be patched to support cross compilation. clock.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isAarch32 [ ({ version }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ]; - # nix calls this package crypto - # cryptonite-openssl.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ]; - - # http-client.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ]; - - # conduit.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ]; - # streaming-commons.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ]; - # x509-system.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ]; - # file-embed-lzma.patches = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ]; # Set all of these to [], as these form the # dependency graph of the libiserv, iserv-proxy, and iserv-remote @@ -59,7 +61,7 @@ final: prev: network.setupBuildFlags = []; unix.setupBuildFlags = []; }; - }// withTH + } ) ]; }); diff --git a/overlays/linux-cross.nix b/overlays/linux-cross.nix index d674140fe1..71c20f951c 100644 --- a/overlays/linux-cross.nix +++ b/overlays/linux-cross.nix @@ -31,8 +31,6 @@ let # ensure that we get a low pid < 65535 for android (If we run outside) # of nix build envs. - # we want this to hold only for arm (32 and 64bit) for now. - isLinuxCross = haskellLib.isCrossHost && hostPlatform.isLinux && (hostPlatform.isAarch32 || hostPlatform.isAarch64 || hostPlatform.isi686); qemuIservWrapperScript = enableProfiling: let interpreter = @@ -58,15 +56,12 @@ let ''; qemuIservWrapper = symlinkJoin { name = "iserv-wrapper"; paths = [ (qemuIservWrapperScript false) (qemuIservWrapperScript true) ]; }; configureFlags = lib.optional (hostPlatform.isAarch32 || hostPlatform.isAndroid) "--disable-split-sections"; - setupBuildFlags = map (opt: "--ghc-option=" + opt) ((lib.optionals isLinuxCross + ghcOptions = [ "-fexternal-interpreter" "-pgmi" "${qemuIservWrapper}/bin/iserv-wrapper" "-L${gmp}/lib" # Required to work-around https://gitlab.haskell.org/ghc/ghc/issues/15275 - ] ++ lib.optionals hostPlatform.isAarch64 ["-fPIC"])) - ++ lib.optionals hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ]) - # Also for GHC #15275 - ++ lib.optionals hostPlatform.isAarch64 ["--gcc-option=-fPIC"]; + ] ++ lib.optionals hostPlatform.isAarch64 ["-fPIC"]; # Wrapper for qemu testing qemuTestWrapper = writeShellScriptBin "test-wrapper" '' @@ -75,8 +70,6 @@ let ''; # Choose the appropriate test wrapper - testWrapper = lib.optional isLinuxCross "${qemuTestWrapper}/bin/test-wrapper"; + testWrapper = "${qemuTestWrapper}/bin/test-wrapper"; - enableShared = lib.mkDefault (!isLinuxCross); - -in { inherit configureFlags setupBuildFlags testWrapper enableShared; } +in { inherit configureFlags ghcOptions testWrapper; } diff --git a/overlays/mingw_w64.nix b/overlays/mingw_w64.nix index 7cfc744723..6e8f74a086 100644 --- a/overlays/mingw_w64.nix +++ b/overlays/mingw_w64.nix @@ -73,14 +73,14 @@ let ################################################################################ # Build logic (TH support via remote iserv via wine) # - setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals hostPlatform.isWindows ([ + ghcOptions = lib.optionals hostPlatform.isWindows ([ "-fexternal-interpreter" "-pgmi" "${wineIservWrapper}/bin/iserv-wrapper" # TODO: this should be automatically injected based on the extraLibrary. "-L${mingw_w64_pthreads}/lib" "-L${mingw_w64_pthreads}/bin" "-L${gmp}/lib" - ])); + ]); ################################################################################ # Test logic via wine @@ -105,4 +105,4 @@ let ''; testWrapper = lib.optional hostPlatform.isWindows "${wineTestWrapper}/bin/test-wrapper"; -in { inherit testWrapper setupBuildFlags configureFlags; } +in { inherit testWrapper ghcOptions configureFlags; } diff --git a/overlays/windows.nix b/overlays/windows.nix index a1891268f3..7417cb190b 100644 --- a/overlays/windows.nix +++ b/overlays/windows.nix @@ -37,26 +37,32 @@ final: prev: configureFlags = (drv.configureFlags or []) ++ [ "--enable-static --disable-shared" ]; }); - haskell-nix = prev.haskell-nix // ({ + haskell-nix = prev.haskell-nix // final.lib.optionalAttrs final.stdenv.hostPlatform.isWindows ({ + templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes: + import ./mingw_w64.nix { + inherit (final.stdenv) hostPlatform; + inherit (final.pkgsBuildBuild) lib writeShellScriptBin; + wine = final.pkgsBuildBuild.winePackages.minimal; + inherit (final.windows) mingw_w64_pthreads; + inherit (final) gmp; + inherit (final.pkgsBuildBuild) symlinkJoin; + # iserv-proxy needs to come from the buildPackages, as it needs to run on the + # build host. + inherit (iserv-proxy-exes) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof; + }) final.haskell-nix.iserv-proxy-exes; defaultModules = prev.haskell-nix.defaultModules ++ [ ({ pkgs, buildModules, config, lib, ... }: let - withTH = import ./mingw_w64.nix { - inherit (pkgs.stdenv) hostPlatform; - inherit (pkgs.pkgsBuildBuild) lib writeShellScriptBin; - wine = pkgs.pkgsBuildBuild.winePackages.minimal; - inherit (pkgs.windows) mingw_w64_pthreads; - inherit (pkgs) gmp; - inherit (pkgs.pkgsBuildBuild) symlinkJoin; - # iserv-proxy needs to come from the buildPackages, as it needs to run on the - # build host. - inherit (final.haskell-nix.iserv-proxy-exes.${config.compiler.nix-name}) iserv-proxy iserv-proxy-interpreter iserv-proxy-interpreter-prof; - } // { - # we can perform testing of cross compiled test-suites by using wine. - # Therefore let's enable doCrossCheck here! - doCrossCheck = pkgs.stdenv.hostPlatform.isWindows; - }; + withTH = final.haskell-nix.templateHaskell.${config.compiler.nix-name}; in prev.haskell-nix.haskellLib.addPackageKeys { + inherit (withTH) configureFlags testWrapper; + + setupBuildFlags = map (opt: "--ghc-option=" + opt) withTH.ghcOptions; + + # we can perform testing of cross compiled test-suites by using wine. + # Therefore let's enable doCrossCheck here! + doCrossCheck = pkgs.stdenv.hostPlatform.isWindows; + packages = { # Apply https://github.com/haskell/cabal/pull/6055 @@ -115,7 +121,7 @@ final: prev: unix-time.components.library.libs = [ pkgs.windows.mingw_w64_pthreads ]; unix-time.postUnpack = "substituteInPlace */cbits/win_patch.h --replace Windows.h windows.h"; }; - } // withTH + } ) ]; }); diff --git a/test/cabal.project.local b/test/cabal.project.local index a134a793f2..52f16106fc 100644 --- a/test/cabal.project.local +++ b/test/cabal.project.local @@ -29,7 +29,7 @@ repository head.hackage.ghc.haskell.org f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d - --sha256: sha256-V7cPUrMNDXF+LDrNKUE+co1MEmOquGUQ19Z6dJP8bFA= + --sha256: sha256-EXgjjlBrCHX80zkR5s7APh30dgT3e5O6BgsQRtCxT6c= repository ghcjs-overlay url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/ffb32dce467b9a4d27be759fdd2740a6edd09d0b From ccc8a48d8c449ef947f7c69f2fddde84b497a30f Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 16 Jul 2025 17:19:02 +1200 Subject: [PATCH 2/8] Update overlays/armv6l-linux.nix Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- overlays/armv6l-linux.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlays/armv6l-linux.nix b/overlays/armv6l-linux.nix index dde8e585df..96ebbd0c6f 100644 --- a/overlays/armv6l-linux.nix +++ b/overlays/armv6l-linux.nix @@ -10,7 +10,7 @@ let in { haskell-nix = prev.haskell-nix // final.lib.optionalAttrs isLinuxCross ({ - templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes: + templateHaskell = builtins.mapAttrs (_compiler-nix-name: iserv-proxy-exes: import ./linux-cross.nix { inherit (final.stdenv) hostPlatform buildPlatform; inherit (final) stdenv lib; From 4774b42085073f41703ec3be57835b0436c9b89d Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Wed, 16 Jul 2025 17:19:10 +1200 Subject: [PATCH 3/8] Update overlays/windows.nix Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- overlays/windows.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlays/windows.nix b/overlays/windows.nix index 7417cb190b..c7bc2172bc 100644 --- a/overlays/windows.nix +++ b/overlays/windows.nix @@ -38,7 +38,7 @@ final: prev: }); haskell-nix = prev.haskell-nix // final.lib.optionalAttrs final.stdenv.hostPlatform.isWindows ({ - templateHaskell = builtins.mapAttrs (compiler-nix-name: iserv-proxy-exes: + templateHaskell = builtins.mapAttrs (_compiler-nix-name: iserv-proxy-exes: import ./mingw_w64.nix { inherit (final.stdenv) hostPlatform; inherit (final.pkgsBuildBuild) lib writeShellScriptBin; From d126e0a14919d51486ed11074f8589b2ace7bff2 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 17 Jul 2025 23:32:08 +1200 Subject: [PATCH 4/8] Disable macOS ci for now --- flake.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 54723b2b81..6b76536b7b 100644 --- a/flake.nix +++ b/flake.nix @@ -110,8 +110,9 @@ systems = [ "x86_64-linux" ] ++ (if runningHydraEvalTest then [ ] else [ - "x86_64-darwin" - "aarch64-darwin" + # TODO put these back when the macOS builders for ci.zw3rk.com are back online + # "x86_64-darwin" + # "aarch64-darwin" ]); nixpkgsArgs = { From 309c6ebbf1e9a2aea76953b46a8407e52c9ba128 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Thu, 17 Jul 2025 23:35:03 +1200 Subject: [PATCH 5/8] Bump head.hackage --- test/cabal.project.local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cabal.project.local b/test/cabal.project.local index 52f16106fc..1961c4c749 100644 --- a/test/cabal.project.local +++ b/test/cabal.project.local @@ -29,7 +29,7 @@ repository head.hackage.ghc.haskell.org f76d08be13e9a61a377a85e2fb63f4c5435d40f8feb3e12eb05905edb8cdea89 26021a13b401500c8eb2761ca95c61f2d625bfef951b939a8124ed12ecf07329 7541f32a4ccca4f97aea3b22f5e593ba2c0267546016b992dfadcd2fe944e55d - --sha256: sha256-EXgjjlBrCHX80zkR5s7APh30dgT3e5O6BgsQRtCxT6c= + --sha256: sha256-njXNb4OInAsW0Nfyslum+Kw8X5HDYDXnaXBsW8hUUCU= repository ghcjs-overlay url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/ffb32dce467b9a4d27be759fdd2740a6edd09d0b From fe9847d620d3c251dcfdd0c943beca6253ef675d Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Fri, 18 Jul 2025 09:36:18 +1200 Subject: [PATCH 6/8] Disable macOS ci for now --- flake.nix | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index 6b76536b7b..09892c7d19 100644 --- a/flake.nix +++ b/flake.nix @@ -297,10 +297,11 @@ hydraJobs.nix-tools = pkgs.releaseTools.aggregate { name = "nix-tools"; constituents = (if runningHydraEvalTest then [ ] else [ - "aarch64-darwin.nix-tools.static.zipped.nix-tools-static" - "x86_64-darwin.nix-tools.static.zipped.nix-tools-static" - "aarch64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" - "x86_64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" + # TODO put these back when the macOS builders for ci.zw3rk.com are back online + # "aarch64-darwin.nix-tools.static.zipped.nix-tools-static" + # "x86_64-darwin.nix-tools.static.zipped.nix-tools-static" + # "aarch64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" + # "x86_64-darwin.nix-tools.static.zipped.nix-tools-static-no-ifd" ]) ++ [ "x86_64-linux.nix-tools.static.zipped.nix-tools-static" "x86_64-linux.nix-tools.static.zipped.nix-tools-static-arm64" From fe3584d761eb9003893709bff76e1348fc0789ab Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Fri, 18 Jul 2025 13:05:40 +1200 Subject: [PATCH 7/8] Fix testWrapper type --- overlays/linux-cross.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlays/linux-cross.nix b/overlays/linux-cross.nix index 71c20f951c..125a1665fc 100644 --- a/overlays/linux-cross.nix +++ b/overlays/linux-cross.nix @@ -70,6 +70,6 @@ let ''; # Choose the appropriate test wrapper - testWrapper = "${qemuTestWrapper}/bin/test-wrapper"; + testWrapper = [ "${qemuTestWrapper}/bin/test-wrapper" ]; in { inherit configureFlags ghcOptions testWrapper; } From 567a347ad7cae16bfa457417308ec987997b167f Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Fri, 18 Jul 2025 13:11:11 +1200 Subject: [PATCH 8/8] Simplify mingw_w64.nix --- overlays/mingw_w64.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/overlays/mingw_w64.nix b/overlays/mingw_w64.nix index 6e8f74a086..2ab1cc133f 100644 --- a/overlays/mingw_w64.nix +++ b/overlays/mingw_w64.nix @@ -13,7 +13,7 @@ }: let - configureFlags = lib.optional hostPlatform.isWindows "--disable-split-sections"; + configureFlags = ["--disable-split-sections"]; wineIservWrapperScript = enableProfiling: let @@ -73,14 +73,14 @@ let ################################################################################ # Build logic (TH support via remote iserv via wine) # - ghcOptions = lib.optionals hostPlatform.isWindows ([ + ghcOptions = [ "-fexternal-interpreter" "-pgmi" "${wineIservWrapper}/bin/iserv-wrapper" # TODO: this should be automatically injected based on the extraLibrary. "-L${mingw_w64_pthreads}/lib" "-L${mingw_w64_pthreads}/bin" "-L${gmp}/lib" - ]); + ]; ################################################################################ # Test logic via wine @@ -103,6 +103,6 @@ let export Path ${wine}/bin/wine64 $@ ''; - testWrapper = lib.optional hostPlatform.isWindows "${wineTestWrapper}/bin/test-wrapper"; + testWrapper = ["${wineTestWrapper}/bin/test-wrapper"]; in { inherit testWrapper ghcOptions configureFlags; }