···17 '';
18 });
190000000000000000000000000000000000020 path = with pkgs; map getBin
21 [ coreutils
22 gnugrep
···28 util-linux # needed for mount and mountpoint
29 ];
3031- scriptType = with types;
32 let scriptOptions =
33 { deps = mkOption
34 { type = types.listOf types.str;
···38 text = mkOption
39 { type = types.lines;
40 description = "The content of the script.";
000000000000041 };
42 };
43 in either str (submodule { options = scriptOptions; });
···74 idempotent and fast.
75 '';
7677- type = types.attrsOf scriptType;
78-79- apply = set: {
80- script =
81- ''
82- #! ${pkgs.runtimeShell}
83-84- systemConfig=@out@
85-86- export PATH=/empty
87- for i in ${toString path}; do
88- PATH=$PATH:$i/bin:$i/sbin
89- done
90-91- _status=0
92- trap "_status=1 _localstatus=\$?" ERR
93-94- # Ensure a consistent umask.
95- umask 0022
96-97- ${
98- let
99- set' = mapAttrs (n: v: if isString v then noDepEntry v else v) set;
100- withHeadlines = addAttributeName set';
101- in textClosureMap id (withHeadlines) (attrNames withHeadlines)
102- }
103104- # Make this configuration the current configuration.
105- # The readlink is there to ensure that when $systemConfig = /system
106- # (which is a symlink to the store), /run/current-system is still
107- # used as a garbage collection root.
108- ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
109-110- # Prevent the current configuration from being garbage-collected.
111- ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
112-113- exit $_status
114- '';
115- };
116 };
117118 system.userActivationScripts = mkOption {
···137 idempotent and fast.
138 '';
139140- type = with types; attrsOf scriptType;
141142 apply = set: {
143 script = ''
···17 '';
18 });
1920+ systemActivationScript = set: onlyDry: let
21+ set' = filterAttrs (_: v: onlyDry -> v.supportsDryActivation) (mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set);
22+ withHeadlines = addAttributeName set';
23+ in
24+ ''
25+ #!${pkgs.runtimeShell}
26+27+ systemConfig='@out@'
28+29+ export PATH=/empty
30+ for i in ${toString path}; do
31+ PATH=$PATH:$i/bin:$i/sbin
32+ done
33+34+ _status=0
35+ trap "_status=1 _localstatus=\$?" ERR
36+37+ # Ensure a consistent umask.
38+ umask 0022
39+40+ ${textClosureMap id (withHeadlines) (attrNames withHeadlines)}
41+42+ '' + optionalString (!onlyDry) ''
43+ # Make this configuration the current configuration.
44+ # The readlink is there to ensure that when $systemConfig = /system
45+ # (which is a symlink to the store), /run/current-system is still
46+ # used as a garbage collection root.
47+ ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
48+49+ # Prevent the current configuration from being garbage-collected.
50+ ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
51+52+ exit $_status
53+ '';
54+55 path = with pkgs; map getBin
56 [ coreutils
57 gnugrep
···63 util-linux # needed for mount and mountpoint
64 ];
6566+ scriptType = withDry: with types;
67 let scriptOptions =
68 { deps = mkOption
69 { type = types.listOf types.str;
···73 text = mkOption
74 { type = types.lines;
75 description = "The content of the script.";
76+ };
77+ } // optionalAttrs withDry {
78+ supportsDryActivation = mkOption
79+ { type = types.bool;
80+ default = false;
81+ description = ''
82+ Whether this activation script supports being dry-activated.
83+ These activation scripts will also be executed on dry-activate
84+ activations with the environment variable
85+ <literal>NIXOS_ACTION</literal> being set to <literal>dry-activate
86+ </literal>. it's important that these activation scripts don't
87+ modify anything about the system when the variable is set.
88+ '';
89 };
90 };
91 in either str (submodule { options = scriptOptions; });
···122 idempotent and fast.
123 '';
124125+ type = types.attrsOf (scriptType true);
126+ apply = set: set // {
127+ script = systemActivationScript set false;
128+ };
129+ };
000000000000000000000130131+ system.dryActivationScript = mkOption {
132+ description = "The shell script that is to be run when dry-activating a system.";
133+ readOnly = true;
134+ internal = true;
135+ default = systemActivationScript (removeAttrs config.system.activationScripts [ "script" ]) true;
0000000136 };
137138 system.userActivationScripts = mkOption {
···157 idempotent and fast.
158 '';
159160+ type = with types; attrsOf (scriptType false);
161162 apply = set: {
163 script = ''
···36 exit 1;
37}
380039# This is a NixOS installation if it has /etc/NIXOS or a proper
40# /etc/os-release.
41die "This is not a NixOS installation!\n" unless
···360 if scalar @unitsToStopFiltered > 0;
361 print STDERR "would NOT stop the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n"
362 if scalar(keys %unitsToSkip) > 0;
0000363 print STDERR "would restart systemd\n" if $restartSystemd;
364 print STDERR "would restart the following units: ", join(", ", sort(keys %unitsToRestart)), "\n"
365 if scalar(keys %unitsToRestart) > 0;
···36 exit 1;
37}
3839+$ENV{NIXOS_ACTION} = $action;
40+41# This is a NixOS installation if it has /etc/NIXOS or a proper
42# /etc/os-release.
43die "This is not a NixOS installation!\n" unless
···362 if scalar @unitsToStopFiltered > 0;
363 print STDERR "would NOT stop the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n"
364 if scalar(keys %unitsToSkip) > 0;
365+366+ print STDERR "would activate the configuration...\n";
367+ system("$out/dry-activate", "$out");
368+369 print STDERR "would restart systemd\n" if $restartSystemd;
370 print STDERR "would restart the following units: ", join(", ", sort(keys %unitsToRestart)), "\n"
371 if scalar(keys %unitsToRestart) > 0;
+5-2
nixos/modules/system/activation/top-level.nix
···56 ''}
5758 echo "$activationScript" > $out/activate
059 substituteInPlace $out/activate --subst-var out
60- chmod u+x $out/activate
61- unset activationScript
06263 cp ${config.system.build.bootStage2} $out/init
64 substituteInPlace $out/init --subst-var-by systemConfig $out
···108 config.system.build.installBootLoader
109 or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
110 activationScript = config.system.activationScripts.script;
0111 nixosLabel = config.system.nixos.label;
112113 configurationName = config.boot.loader.grub.configurationName;
···56 ''}
5758 echo "$activationScript" > $out/activate
59+ echo "$dryActivationScript" > $out/dry-activate
60 substituteInPlace $out/activate --subst-var out
61+ substituteInPlace $out/dry-activate --subst-var out
62+ chmod u+x $out/activate $out/dry-activate
63+ unset activationScript dryActivationScript
6465 cp ${config.system.build.bootStage2} $out/init
66 substituteInPlace $out/init --subst-var-by systemConfig $out
···110 config.system.build.installBootLoader
111 or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
112 activationScript = config.system.activationScripts.script;
113+ dryActivationScript = config.system.dryActivationScript;
114 nixosLabel = config.system.nixos.label;
115116 configurationName = config.boot.loader.grub.configurationName;
···1+{ stdenv, lib, version, src, cmake, python3, llvm, libcxxabi }:
2+stdenv.mkDerivation rec {
3+ pname = "compiler-rt";
4+ inherit version src;
5+6+ nativeBuildInputs = [ cmake python3 llvm ];
7+8+ NIX_CFLAGS_COMPILE = [
9+ "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
10+ ];
11+12+ cmakeFlags = [
13+ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
14+ "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
15+ "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
16+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
17+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
18+ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
19+ "-DCOMPILER_RT_BUILD_PROFILE=OFF"
20+ "-DCMAKE_C_COMPILER_WORKS=ON"
21+ "-DCMAKE_CXX_COMPILER_WORKS=ON"
22+ "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
23+ "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
24+ "-DCOMPILER_RT_BUILD_BUILTINS=ON"
25+ "-DCMAKE_C_FLAGS=-nodefaultlibs"
26+ #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
27+ "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
28+ ];
29+30+ outputs = [ "out" "dev" ];
31+32+ patches = [
33+ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
34+ ];
35+36+37+ # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
38+ # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
39+ # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
40+ # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
41+ # a flag and turn the flag off during the stdenv build.
42+ postPatch = lib.optionalString (!stdenv.isDarwin) ''
43+ substituteInPlace cmake/builtin-config-ix.cmake \
44+ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
45+ '';
46+47+ # Hack around weird upsream RPATH bug
48+ postInstall = ''
49+ ln -s "$out/lib"/*/* "$out/lib"
50+ ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
51+ ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
52+ ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
53+ ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
54+ '';
55+56+ enableParallelBuilding = true;
57+58+ meta = with lib; {
59+ description = "ROCm fork of the LLVM Compiler runtime libraries";
60+ homepage = "https://github.com/RadeonOpenCompute/llvm-project";
61+ license = licenses.ncsa;
62+ maintainers = with maintainers; [ acowley danieldk lovesegfault ];
63+ platforms = platforms.linux;
64+ };
65+}