diff --git a/lib/systems/default.nix b/lib/systems/default.nix index ec0106a13dacf..0d3f84eec70af 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -251,6 +251,17 @@ let else if final.isAarch64 then "aa64" else final.parsed.cpu.name; + pageSize = let + pageSizeArg = args.pageSize or {}; + checkValue = value: assert parse.types.pageSize.check value; value; + in { + min = checkValue (pageSizeArg.min or parse.pageSizes."4k"); + max = checkValue (pageSizeArg.max or parse.pageSizes."64k"); + range = builtins.attrValues (lib.filterAttrs + (_: v: v >= final.pageSize.min && v <= final.pageSize.max) + (builtins.removeAttrs parse.pageSizes [ "_type" ])); + }; + darwinArch = { armv7a = "armv7"; aarch64 = "arm64"; @@ -318,7 +329,7 @@ let }) // mapAttrs (n: v: v final.parsed) inspect.predicates // mapAttrs (n: v: v final.gcc.arch or "default") architectures.predicates - // args // { + // builtins.removeAttrs args [ "pageSize" ] // { rust = rust // { # Once args.rustc.platform.target-family is deprecated and # removed, there will no longer be any need to modify any diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index e3e6ef16c6b07..29184fd93d6c3 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -424,6 +424,24 @@ rec { ################################################################################ + types.openPageSize = mkOptionType { + name = "pageSize"; + description = "4k aligned page size value"; + merge = mergeOneOption; + check = x: (x / 4096) > 0; + }; + + types.pageSize = enum (attrValues pageSizes); + + pageSizes = setType types.openPageSize { + "4k" = 4096; + "16k" = 16384; + "32k" = 32768; + "64k" = 65536; + }; + + ################################################################################ + types.parsedPlatform = mkOptionType { name = "system"; description = "fully parsed representation of llvm- or nix-style platform tuple"; diff --git a/nixos/modules/config/nix.nix b/nixos/modules/config/nix.nix index b59b0f3cd0f69..c9dfe0df57368 100644 --- a/nixos/modules/config/nix.nix +++ b/nixos/modules/config/nix.nix @@ -56,7 +56,7 @@ let ++ map (x: "gccarch-${x}") ( systems.architectures.inferiors.${pkgs.stdenv.hostPlatform.gcc.arch} or [ ] ) - ); + ) ++ map (v: "pages-${builtins.toString (v / 1024)}") pkgs.stdenv.hostPlatform.pageSize.range; legacyConfMappings = { useSandbox = "sandbox"; diff --git a/pkgs/by-name/bu/bun/package.nix b/pkgs/by-name/bu/bun/package.nix index a9d311ee46410..b8374ac9eb83c 100644 --- a/pkgs/by-name/bu/bun/package.nix +++ b/pkgs/by-name/bu/bun/package.nix @@ -121,7 +121,9 @@ stdenvNoCC.mkDerivation rec { platforms = builtins.attrNames passthru.sources; # Broken for Musl at 2024-01-13, tracking issue: # https://github.com/NixOS/nixpkgs/issues/280716 - broken = stdenvNoCC.hostPlatform.isMusl; + # Broken on systems with page sizes > 16k + # https://github.com/oven-sh/bun/issues/6241 + broken = stdenvNoCC.hostPlatform.isMusl || stdenvNoCC.hostPlatform.pageSize.min > 16384; # Hangs when run via Rosetta 2 on Apple Silicon hydraPlatforms = lib.lists.remove "x86_64-darwin" lib.platforms.all; diff --git a/pkgs/development/compilers/zig/generic.nix b/pkgs/development/compilers/zig/generic.nix index 84f83b5aa7093..7ab3de03e7d17 100644 --- a/pkgs/development/compilers/zig/generic.nix +++ b/pkgs/development/compilers/zig/generic.nix @@ -167,6 +167,11 @@ stdenv.mkDerivation (finalAttrs: { }; meta = { + # Versions older than 0.14 do not have a runtime page size feature. + broken = + lib.versionOlder finalAttrs.version "0.14" + && stdenv.hostPlatform.pageSize.min > 4096 + && !stdenv.hostPlatform.isDarwin; description = "General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software"; homepage = "https://ziglang.org/"; changelog = "https://ziglang.org/download/${finalAttrs.version}/release-notes.html"; diff --git a/pkgs/development/libraries/jemalloc/default.nix b/pkgs/development/libraries/jemalloc/default.nix index 9c2eeadd676e5..fe18fed3ab271 100644 --- a/pkgs/development/libraries/jemalloc/default.nix +++ b/pkgs/development/libraries/jemalloc/default.nix @@ -48,7 +48,16 @@ stdenv.mkDerivation rec { ] # AArch64 has configurable page size up to 64k. The default configuration # for jemalloc only supports 4k page sizes. - ++ lib.optional stdenv.hostPlatform.isAarch64 "--with-lg-page=16" + ++ lib.optional stdenv.hostPlatform.isAarch64 "--with-lg-page=${ + { + "4" = "12"; + "8" = "13"; + "16" = "14"; + "32" = "15"; + "64" = "16"; + } + ."${builtins.toString (stdenv.hostPlatform.pageSize.min / 1024)}" + }" # See https://github.com/jemalloc/jemalloc/issues/1997 # Using a value of 48 should work on both emulated and native x86_64-darwin. ++ lib.optional (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) "--with-lg-vaddr=48"; diff --git a/pkgs/os-specific/linux/kernel/common-config.nix b/pkgs/os-specific/linux/kernel/common-config.nix index 0f7606c79b532..5d9340c4486fa 100644 --- a/pkgs/os-specific/linux/kernel/common-config.nix +++ b/pkgs/os-specific/linux/kernel/common-config.nix @@ -1436,7 +1436,23 @@ let # Enable Intel Turbo Boost Max 3.0 INTEL_TURBO_MAX_3 = yes; - }; + } + // + lib.optionalAttrs (stdenv.hostPlatform.system == "aarch64-linux" || stdenv.hostPlatform.isPower) + ( + let + key = + if stdenv.hostPlatform.isPower then + "PPC" + else if stdenv.hostPlatform.isAarch64 then + "ARM64" + else + throw "Not supported"; + in + { + "${key}_${builtins.toString (stdenv.hostPlatform.pageSize.min / 1024)}K_PAGES" = yes; + } + ); accel = { # Build DRM accelerator devices