Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/systems/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions lib/systems/parse.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/config/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 3 additions & 1 deletion pkgs/by-name/bu/bun/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions pkgs/development/compilers/zig/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
11 changes: 10 additions & 1 deletion pkgs/development/libraries/jemalloc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
18 changes: 17 additions & 1 deletion pkgs/os-specific/linux/kernel/common-config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down