nixpkgs/pkgs/top-level/variants.nix
Wolfgang Walther 612e76db51
pkgsx86_64Darwin: move behind allowVariants
This is already not used in-tree, so should be a variant.
2025-07-24 15:31:04 +02:00

185 lines
5.5 KiB
Nix

/*
This file contains all of the different variants of nixpkgs instances.
Unlike the other package sets like pkgsCross, pkgsi686Linux, etc., this
contains non-critical package sets. The intent is to be a shorthand
for things like using different toolchains in every package in nixpkgs.
*/
{
lib,
stdenv,
nixpkgsFun,
overlays,
makeMuslParsedPlatform,
}:
let
makeLLVMParsedPlatform =
parsed:
(
parsed
// {
abi = lib.systems.parse.abis.llvm;
}
);
in
self: super: {
pkgsLLVM = nixpkgsFun {
overlays = [
(self': super': {
pkgsLLVM = super';
})
]
++ overlays;
# Bootstrap a cross stdenv using the LLVM toolchain.
# This is currently not possible when compiling natively,
# so we don't need to check hostPlatform != buildPlatform.
crossSystem = stdenv.hostPlatform // {
useLLVM = true;
linker = "lld";
};
};
pkgsArocc = nixpkgsFun {
overlays = [
(self': super': {
pkgsArocc = super';
})
]
++ overlays;
# Bootstrap a cross stdenv using the Aro C compiler.
# This is currently not possible when compiling natively,
# so we don't need to check hostPlatform != buildPlatform.
crossSystem = stdenv.hostPlatform // {
useArocc = true;
linker = "lld";
};
};
pkgsZig = nixpkgsFun {
overlays = [
(self': super': {
pkgsZig = super';
})
]
++ overlays;
# Bootstrap a cross stdenv using the Zig toolchain.
# This is currently not possible when compiling natively,
# so we don't need to check hostPlatform != buildPlatform.
crossSystem = stdenv.hostPlatform // {
useZig = true;
linker = "lld";
};
};
# All packages built with the Musl libc. This will override the
# default GNU libc on Linux systems. Non-Linux systems are not
# supported. 32-bit is also not supported.
pkgsMusl =
if stdenv.hostPlatform.isLinux && stdenv.buildPlatform.is64bit then
nixpkgsFun {
overlays = [
(self': super': {
pkgsMusl = super';
})
]
++ overlays;
${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} = {
config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed);
};
}
else
throw "Musl libc only supports 64-bit Linux systems.";
# x86_64-darwin packages for aarch64-darwin users to use with Rosetta for incompatible packages
pkgsx86_64Darwin =
if stdenv.hostPlatform.isDarwin then
nixpkgsFun {
overlays = [
(self': super': {
pkgsx86_64Darwin = super';
})
]
++ overlays;
localSystem = {
config = lib.systems.parse.tripleFromSystem (
stdenv.hostPlatform.parsed
// {
cpu = lib.systems.parse.cpuTypes.x86_64;
}
);
};
}
else
throw "x86_64 Darwin package set can only be used on Darwin systems.";
# Full package set with rocm on cuda off
# Mostly useful for asserting pkgs.pkgsRocm.torchWithRocm == pkgs.torchWithRocm and similar
pkgsRocm = nixpkgsFun ({
config = super.config // {
cudaSupport = false;
rocmSupport = true;
};
});
# Full package set with cuda on rocm off
# Mostly useful for asserting pkgs.pkgsCuda.torchWithCuda == pkgs.torchWithCuda and similar
pkgsCuda = nixpkgsFun {
config = super.config // {
cudaSupport = true;
rocmSupport = false;
};
};
# `pkgsForCudaArch` maps each CUDA capability in _cuda.db.cudaCapabilityToInfo to a Nixpkgs variant configured for
# that target system. For example, `pkgsForCudaArch.sm_90a.python3Packages.torch` refers to PyTorch built for the
# Hopper architecture, leveraging architecture-specific features.
# NOTE: Not every package set is supported on every architecture!
# See `Using pkgsForCudaArch` in doc/languages-frameworks/cuda.section.md for more information.
pkgsForCudaArch = lib.listToAttrs (
lib.map (cudaCapability: {
name = self._cuda.lib.mkRealArchitecture cudaCapability;
value = nixpkgsFun {
config = super.config // {
cudaSupport = true;
rocmSupport = false;
# Not supported by architecture-specific feature sets, so disable for all.
# Users can choose to build for family-specific feature sets if they wish.
cudaForwardCompat = false;
cudaCapabilities = [ cudaCapability ];
};
};
}) (lib.attrNames self._cuda.db.cudaCapabilityToInfo)
);
pkgsExtraHardening = nixpkgsFun {
overlays = [
(
self': super':
{
pkgsExtraHardening = super';
stdenv = super'.withDefaultHardeningFlags (
super'.stdenv.cc.defaultHardeningFlags
++ [
"strictflexarrays1"
"shadowstack"
"nostrictaliasing"
"pacret"
"trivialautovarinit"
]
) super'.stdenv;
glibc = super'.glibc.override rec {
enableCET = if self'.stdenv.hostPlatform.isx86_64 then "permissive" else false;
enableCETRuntimeDefault = enableCET != false;
};
}
// lib.optionalAttrs (with super'.stdenv.hostPlatform; isx86_64 && isLinux) {
# causes shadowstack disablement
pcre = super'.pcre.override { enableJit = false; };
pcre-cpp = super'.pcre-cpp.override { enableJit = false; };
}
)
]
++ overlays;
};
}