Loading pkgs/by-name/gh/ghostty/package.nix +41 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ pandoc, pkg-config, removeReferencesTo, util-linux, versionCheckHook, wrapGAppsHook4, writeShellApplication, zig_0_14, # Usually you would override `zig.hook` with this, but we do that internally Loading @@ -31,7 +33,44 @@ }: let zig = zig_0_14; zig_hook = zig.hook.overrideAttrs { # HACK: # Work around a Zig bug where embedding a large enough file could crash # the compiler when too many cores are used, which causes Hydra builds to # reliably fail. See these links for more info: # # * https://github.com/ziglang/zig/issues/25297 # * https://github.com/ziglang/zig/issues/22867 # * https://github.com/ghostty-org/ghostty/discussions/8676 # # Note that the `-j` parameter does NOT fix this. It seems like the faulty # intern pool logic always depends on the full amount of available cores # instead of the value of `-j`, so we have to use `taskset` to trick Zig # into thinking it only has access to a limited amount of cores. zigWithLimitedCores = writeShellApplication { name = "zig"; passthru = { inherit (zig) version meta; }; runtimeInputs = [ zig util-linux ]; text = '' maxCores=$(nproc) # 32 cores seem to be the upper limit through empiric testing coreLimit=$((maxCores < 32 ? maxCores : 32)) # Also take NIX_BUILD_CORES into account so the build respects the `--cores` argument effectiveCores=$((NIX_BUILD_CORES > coreLimit ? coreLimit : NIX_BUILD_CORES)) taskset -c "0-$((effectiveCores - 1))" zig "$@" ''; }; zig_hook = (zig.hook.override { zig = zigWithLimitedCores; }).overrideAttrs { zig_default_flags = "-Dcpu=baseline -Doptimize=${optimizeLevel} --color off"; }; in Loading Loading
pkgs/by-name/gh/ghostty/package.nix +41 −2 Original line number Diff line number Diff line Loading @@ -20,8 +20,10 @@ pandoc, pkg-config, removeReferencesTo, util-linux, versionCheckHook, wrapGAppsHook4, writeShellApplication, zig_0_14, # Usually you would override `zig.hook` with this, but we do that internally Loading @@ -31,7 +33,44 @@ }: let zig = zig_0_14; zig_hook = zig.hook.overrideAttrs { # HACK: # Work around a Zig bug where embedding a large enough file could crash # the compiler when too many cores are used, which causes Hydra builds to # reliably fail. See these links for more info: # # * https://github.com/ziglang/zig/issues/25297 # * https://github.com/ziglang/zig/issues/22867 # * https://github.com/ghostty-org/ghostty/discussions/8676 # # Note that the `-j` parameter does NOT fix this. It seems like the faulty # intern pool logic always depends on the full amount of available cores # instead of the value of `-j`, so we have to use `taskset` to trick Zig # into thinking it only has access to a limited amount of cores. zigWithLimitedCores = writeShellApplication { name = "zig"; passthru = { inherit (zig) version meta; }; runtimeInputs = [ zig util-linux ]; text = '' maxCores=$(nproc) # 32 cores seem to be the upper limit through empiric testing coreLimit=$((maxCores < 32 ? maxCores : 32)) # Also take NIX_BUILD_CORES into account so the build respects the `--cores` argument effectiveCores=$((NIX_BUILD_CORES > coreLimit ? coreLimit : NIX_BUILD_CORES)) taskset -c "0-$((effectiveCores - 1))" zig "$@" ''; }; zig_hook = (zig.hook.override { zig = zigWithLimitedCores; }).overrideAttrs { zig_default_flags = "-Dcpu=baseline -Doptimize=${optimizeLevel} --color off"; }; in Loading