Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1/*
2 This file contains all of the different variants of nixpkgs instances.
3
4 Unlike the other package sets like pkgsCross, pkgsi686Linux, etc., this
5 contains non-critical package sets. The intent is to be a shorthand
6 for things like using different toolchains in every package in nixpkgs.
7*/
8{
9 lib,
10 stdenv,
11 nixpkgsFun,
12 overlays,
13 makeMuslParsedPlatform,
14}:
15let
16 makeLLVMParsedPlatform =
17 parsed:
18 (
19 parsed
20 // {
21 abi = lib.systems.parse.abis.llvm;
22 }
23 );
24in
25self: super: {
26 pkgsLLVM = nixpkgsFun {
27 overlays = [
28 (self': super': {
29 pkgsLLVM = super';
30 })
31 ]
32 ++ overlays;
33 # Bootstrap a cross stdenv using the LLVM toolchain.
34 # This is currently not possible when compiling natively,
35 # so we don't need to check hostPlatform != buildPlatform.
36 crossSystem = stdenv.hostPlatform // {
37 useLLVM = true;
38 linker = "lld";
39 };
40 };
41
42 pkgsArocc = nixpkgsFun {
43 overlays = [
44 (self': super': {
45 pkgsArocc = super';
46 })
47 ]
48 ++ overlays;
49 # Bootstrap a cross stdenv using the Aro C compiler.
50 # This is currently not possible when compiling natively,
51 # so we don't need to check hostPlatform != buildPlatform.
52 crossSystem = stdenv.hostPlatform // {
53 useArocc = true;
54 linker = "lld";
55 };
56 };
57
58 pkgsZig = nixpkgsFun {
59 overlays = [
60 (self': super': {
61 pkgsZig = super';
62 })
63 ]
64 ++ overlays;
65 # Bootstrap a cross stdenv using the Zig toolchain.
66 # This is currently not possible when compiling natively,
67 # so we don't need to check hostPlatform != buildPlatform.
68 crossSystem = stdenv.hostPlatform // {
69 useZig = true;
70 linker = "lld";
71 };
72 };
73
74 # All packages built with the Musl libc. This will override the
75 # default GNU libc on Linux systems. Non-Linux systems are not
76 # supported. 32-bit is also not supported.
77 pkgsMusl =
78 if stdenv.hostPlatform.isLinux && stdenv.buildPlatform.is64bit then
79 nixpkgsFun {
80 overlays = [
81 (self': super': {
82 pkgsMusl = super';
83 })
84 ]
85 ++ overlays;
86 ${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} = {
87 config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed);
88 };
89 }
90 else
91 throw "Musl libc only supports 64-bit Linux systems.";
92
93 # x86_64-darwin packages for aarch64-darwin users to use with Rosetta for incompatible packages
94 pkgsx86_64Darwin =
95 if stdenv.hostPlatform.isDarwin then
96 nixpkgsFun {
97 overlays = [
98 (self': super': {
99 pkgsx86_64Darwin = super';
100 })
101 ]
102 ++ overlays;
103 localSystem = {
104 config = lib.systems.parse.tripleFromSystem (
105 stdenv.hostPlatform.parsed
106 // {
107 cpu = lib.systems.parse.cpuTypes.x86_64;
108 }
109 );
110 };
111 }
112 else
113 throw "x86_64 Darwin package set can only be used on Darwin systems.";
114
115 # Full package set with rocm on cuda off
116 # Mostly useful for asserting pkgs.pkgsRocm.torchWithRocm == pkgs.torchWithRocm and similar
117 pkgsRocm = nixpkgsFun ({
118 config = super.config // {
119 cudaSupport = false;
120 rocmSupport = true;
121 };
122 });
123
124 # Full package set with cuda on rocm off
125 # Mostly useful for asserting pkgs.pkgsCuda.torchWithCuda == pkgs.torchWithCuda and similar
126 pkgsCuda = nixpkgsFun {
127 config = super.config // {
128 cudaSupport = true;
129 rocmSupport = false;
130 };
131 };
132
133 # `pkgsForCudaArch` maps each CUDA capability in _cuda.db.cudaCapabilityToInfo to a Nixpkgs variant configured for
134 # that target system. For example, `pkgsForCudaArch.sm_90a.python3Packages.torch` refers to PyTorch built for the
135 # Hopper architecture, leveraging architecture-specific features.
136 # NOTE: Not every package set is supported on every architecture!
137 # See `Using pkgsForCudaArch` in doc/languages-frameworks/cuda.section.md for more information.
138 pkgsForCudaArch = lib.listToAttrs (
139 lib.map (cudaCapability: {
140 name = self._cuda.lib.mkRealArchitecture cudaCapability;
141 value = nixpkgsFun {
142 config = super.config // {
143 cudaSupport = true;
144 rocmSupport = false;
145 # Not supported by architecture-specific feature sets, so disable for all.
146 # Users can choose to build for family-specific feature sets if they wish.
147 cudaForwardCompat = false;
148 cudaCapabilities = [ cudaCapability ];
149 };
150 };
151 }) (lib.attrNames self._cuda.db.cudaCapabilityToInfo)
152 );
153
154 pkgsExtraHardening = nixpkgsFun {
155 overlays = [
156 (
157 self': super':
158 {
159 pkgsExtraHardening = super';
160 stdenv = super'.withDefaultHardeningFlags (
161 super'.stdenv.cc.defaultHardeningFlags
162 ++ [
163 "strictflexarrays1"
164 "shadowstack"
165 "nostrictaliasing"
166 "pacret"
167 "trivialautovarinit"
168 ]
169 ) super'.stdenv;
170 glibc = super'.glibc.override rec {
171 enableCET = if self'.stdenv.hostPlatform.isx86_64 then "permissive" else false;
172 enableCETRuntimeDefault = enableCET != false;
173 };
174 }
175 // lib.optionalAttrs (with super'.stdenv.hostPlatform; isx86_64 && isLinux) {
176 # causes shadowstack disablement
177 pcre = super'.pcre.override { enableJit = false; };
178 pcre-cpp = super'.pcre-cpp.override { enableJit = false; };
179 }
180 )
181 ]
182 ++ overlays;
183 };
184}