forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariants.nix
More file actions
186 lines (177 loc) · 5.64 KB
/
variants.nix
File metadata and controls
186 lines (177 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
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, except for x86.
pkgsMusl =
if stdenv.hostPlatform.isLinux && (stdenv.buildPlatform.is64bit || stdenv.buildPlatform.isx86) 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, and i686-linux.";
# 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"
"glibcxxassertions"
"libcxxhardeningfast"
"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;
};
}