diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2c3c022684..706bc60ad2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -223,14 +223,18 @@ jobs: steps: - uses: actions/checkout@v4 - name: "Check that evaluation of hydra jobs works without using remote builders for GHC 9.6.7" - run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc967-native --show-trace --builders '' + run: | + sed -i 's/runningHydraEvalTest = true;/runningHydraEvalTest = false;/' flake.nix + nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc967-native --show-trace --builders '' hydra-without-remote-builders-ghc9102: runs-on: [self-hosted, linux] steps: - uses: actions/checkout@v4 - name: "Check that evaluation of hydra jobs works without using remote builders for GHC 9.10.2" - run: nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc9102-native --show-trace --builders '' + run: | + sed -i 's/runningHydraEvalTest = true;/runningHydraEvalTest = false;/' flake.nix + nix path-info --derivation .#requiredJobs.x86_64-darwin.required-unstable-ghc9102-native --show-trace --builders '' hix-cabal: runs-on: [self-hosted, linux] diff --git a/builder/default.nix b/builder/default.nix index 27ae6f2f3e..c813f87e7d 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -41,7 +41,7 @@ let # component builder and for nix-shells. ghcForComponent = import ./ghc-for-component-wrapper.nix { inherit lib ghc haskellLib; - inherit (buildPackages) stdenv; + inherit (pkgs) stdenv; inherit (buildPackages.buildPackages) runCommand makeWrapper; inherit (buildPackages.buildPackages.xorg) lndir; }; diff --git a/builder/ghc-for-component-wrapper.nix b/builder/ghc-for-component-wrapper.nix index ad8a15fc5c..a96f2302dc 100644 --- a/builder/ghc-for-component-wrapper.nix +++ b/builder/ghc-for-component-wrapper.nix @@ -14,6 +14,7 @@ , postInstall ? "" , enableDWARF , plugins +, ghcOptions ? [] }: let @@ -23,7 +24,7 @@ let libDir = "$wrappedGhc/${configFiles.libDir}"; docDir = "$wrappedGhc/share/doc/ghc/html"; # For musl we can use haddock from the buildGHC - haddock = if stdenv.targetPlatform.isMusl + haddock = if stdenv.hostPlatform.isMusl then ghc.buildGHC else ghc; @@ -107,7 +108,7 @@ let --set "NIX_${ghcCommandCaps}PKG" "$wrappedGhc/bin/${ghcCommand}-pkg" \ --set "NIX_${ghcCommandCaps}_DOCDIR" "${docDir}" \ --set "GHC_PLUGINS" "$GHC_PLUGINS" \ - --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}" + --set "NIX_${ghcCommandCaps}_LIBDIR" "${libDir}"${lib.concatMapStrings (o: " --add-flags ${o}") ghcOptions} fi done @@ -159,8 +160,7 @@ let inherit script targetPrefix; inherit (ghc) version meta; }; - propagatedBuildInputs = configFiles.libDeps; - nativeBuildInputs = [ghc]; + propagatedBuildInputs = configFiles.libDeps ++ lib.optional stdenv.hasCC stdenv.cc ++ [ghc]; } ('' mkdir -p $out/configFiles configFiles=$out/configFiles diff --git a/builder/shell-for.nix b/builder/shell-for.nix index 2bb4ede064..27e19ab3bc 100644 --- a/builder/shell-for.nix +++ b/builder/shell-for.nix @@ -143,6 +143,7 @@ let ''; inherit enableDWARF; plugins = []; + ghcOptions = haskell-nix.templateHaskell.${compiler.nix-name}.ghcOptions or []; }; hoogleIndex = let @@ -192,11 +193,16 @@ in ''} $(builtin type -P "${ghcEnv.targetPrefix}pkg-config" &> /dev/null && echo "--with-pkg-config=${ghcEnv.targetPrefix}pkg-config") \ "$@" ''); + propagatedBuildInputs = mkDrvArgs.propagateBuildInputs or [] ++ ghcEnv.drv.propagatedBuildInputs; phases = ["installPhase"]; installPhase = '' echo "${"Shell for " + toString (builtins.map (p : p.identifier.name) selectedPackages)}" echo $nativeBuildInputs $buildInputs > $out ''; + shellHook = mkDrvArgs.shellHook or "" + lib.optionalString stdenv.hostPlatform.isWindows '' + + export pkgsHostTargetAsString="''${pkgsHostTarget[@]}" + ''; # This helps tools like `ghcide` (that use the ghc api) to find # the correct global package DB. diff --git a/ci.nix b/ci.nix index bcb3ad6532..f949c7085a 100644 --- a/ci.nix +++ b/ci.nix @@ -29,12 +29,9 @@ (final: prev: { haskell-nix = prev.haskell-nix // { inherit checkMaterialization; - extraPkgconfigMappings = prev.haskell-nix.extraPkgconfigMappings or {} // { - "libsodium" = [ "libsodium-18" ]; - }; }; - libsodium-18 = (final.callPackage (inputs.nixpkgs-2311 + "/pkgs/development/libraries/libsodium") {}).overrideAttrs (_: { dontDisableStatic = true; }); }) + (import ./test/overlay.nix) ]; # Needed for dwarf tests config = haskellNix.config // { diff --git a/flake.nix b/flake.nix index 54723b2b81..721aaf1f3a 100644 --- a/flake.nix +++ b/flake.nix @@ -91,7 +91,8 @@ callFlake = import flake-compat; ifdLevel = 3; - runningHydraEvalTest = false; + # TODO set this to false when the macOS builders for ci.zw3rk.com are back online + runningHydraEvalTest = true; defaultCompiler = "ghc967"; config = import ./config.nix; diff --git a/hix/default.nix b/hix/default.nix index c0cbcb96d4..745bf46cd9 100644 --- a/hix/default.nix +++ b/hix/default.nix @@ -92,6 +92,7 @@ let --projectArgs) printf %s "$2" > "$HIX_TMPDIR/projectArgs.nix" shift + args+=(--override-input projectArgs "$(realpath "$HIX_TMPDIR")") ;; --supportedSystems) printf %s "$2" > "$HIX_TMPDIR/supportedSystems.nix" @@ -166,7 +167,6 @@ let cp $HIX_FLAKE $FLAKE/flake.nix chmod +w $FLAKE/flake.nix fi - args+=(--override-input projectArgs "$(realpath "$HIX_TMPDIR")") nix $cmd "''${args[@]}" ;; esac diff --git a/overlays/armv6l-linux.nix b/overlays/armv6l-linux.nix index e2df3cdaf5..96ebbd0c6f 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..125a1665fc 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..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) # - setupBuildFlags = map (opt: "--ghc-option=" + opt) (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 setupBuildFlags configureFlags; } +in { inherit testWrapper ghcOptions configureFlags; } diff --git a/overlays/windows.nix b/overlays/windows.nix index a1891268f3..c7bc2172bc 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..1bd2c228cc 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-0cuvKmWGj5xuN3kJ6W9mv09bn6PAH4nTBK0QyEPc7Hg= repository ghcjs-overlay url: https://raw.githubusercontent.com/input-output-hk/hackage-overlay-ghcjs/ffb32dce467b9a4d27be759fdd2740a6edd09d0b diff --git a/test/overlay.nix b/test/overlay.nix new file mode 100644 index 0000000000..8d8d3dfada --- /dev/null +++ b/test/overlay.nix @@ -0,0 +1,8 @@ +final: prev: { + haskell-nix = prev.haskell-nix // { + extraPkgconfigMappings = prev.haskell-nix.extraPkgconfigMappings or {} // { + "libsodium" = [ "libsodium-18" ]; + }; + }; + libsodium-18 = (final.callPackage (final.haskell-nix.sources.nixpkgs-2311 + "/pkgs/development/libraries/libsodium") {}).overrideAttrs (_: { dontDisableStatic = true; }); +} diff --git a/test/th-dlls/default.nix b/test/th-dlls/default.nix index 8ec1425654..79f2caefb8 100644 --- a/test/th-dlls/default.nix +++ b/test/th-dlls/default.nix @@ -7,12 +7,12 @@ let project = externalInterpreter: project' { inherit compiler-nix-name evalPackages; src = testSrc "th-dlls"; - cabalProjectLocal = builtins.readFile ../cabal.project.local; modules = import ../modules.nix ++ [({pkgs, ...}: lib.optionalAttrs externalInterpreter { packages.th-dlls.components.library.ghcOptions = [ "-fexternal-interpreter" ]; # Static openssl seems to fail to load in iserv for musl packages.HsOpenSSL.components.library.libs = lib.optional pkgs.stdenv.hostPlatform.isMusl (pkgs.openssl.override { static = false; }); })]; + shell.nativeBuildInputs = [ buildPackages.haskell-nix.nix-tools-unchecked.exes.cabal ]; }; packages = (project false).hsPkgs;