···1717 '';
1818 });
19192020+ systemActivationScript = set: onlyDry: let
2121+ set' = filterAttrs (_: v: onlyDry -> v.supportsDryActivation) (mapAttrs (_: v: if isString v then (noDepEntry v) // { supportsDryActivation = false; } else v) set);
2222+ withHeadlines = addAttributeName set';
2323+ in
2424+ ''
2525+ #!${pkgs.runtimeShell}
2626+2727+ systemConfig='@out@'
2828+2929+ export PATH=/empty
3030+ for i in ${toString path}; do
3131+ PATH=$PATH:$i/bin:$i/sbin
3232+ done
3333+3434+ _status=0
3535+ trap "_status=1 _localstatus=\$?" ERR
3636+3737+ # Ensure a consistent umask.
3838+ umask 0022
3939+4040+ ${textClosureMap id (withHeadlines) (attrNames withHeadlines)}
4141+4242+ '' + optionalString (!onlyDry) ''
4343+ # Make this configuration the current configuration.
4444+ # The readlink is there to ensure that when $systemConfig = /system
4545+ # (which is a symlink to the store), /run/current-system is still
4646+ # used as a garbage collection root.
4747+ ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
4848+4949+ # Prevent the current configuration from being garbage-collected.
5050+ ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
5151+5252+ exit $_status
5353+ '';
5454+2055 path = with pkgs; map getBin
2156 [ coreutils
2257 gnugrep
···2863 util-linux # needed for mount and mountpoint
2964 ];
30653131- scriptType = with types;
6666+ scriptType = withDry: with types;
3267 let scriptOptions =
3368 { deps = mkOption
3469 { type = types.listOf types.str;
···3873 text = mkOption
3974 { type = types.lines;
4075 description = "The content of the script.";
7676+ };
7777+ } // optionalAttrs withDry {
7878+ supportsDryActivation = mkOption
7979+ { type = types.bool;
8080+ default = false;
8181+ description = ''
8282+ Whether this activation script supports being dry-activated.
8383+ These activation scripts will also be executed on dry-activate
8484+ activations with the environment variable
8585+ <literal>NIXOS_ACTION</literal> being set to <literal>dry-activate
8686+ </literal>. it's important that these activation scripts don't
8787+ modify anything about the system when the variable is set.
8888+ '';
4189 };
4290 };
4391 in either str (submodule { options = scriptOptions; });
···74122 idempotent and fast.
75123 '';
761247777- type = types.attrsOf scriptType;
7878-7979- apply = set: {
8080- script =
8181- ''
8282- #! ${pkgs.runtimeShell}
8383-8484- systemConfig=@out@
8585-8686- export PATH=/empty
8787- for i in ${toString path}; do
8888- PATH=$PATH:$i/bin:$i/sbin
8989- done
9090-9191- _status=0
9292- trap "_status=1 _localstatus=\$?" ERR
9393-9494- # Ensure a consistent umask.
9595- umask 0022
9696-9797- ${
9898- let
9999- set' = mapAttrs (n: v: if isString v then noDepEntry v else v) set;
100100- withHeadlines = addAttributeName set';
101101- in textClosureMap id (withHeadlines) (attrNames withHeadlines)
102102- }
125125+ type = types.attrsOf (scriptType true);
126126+ apply = set: set // {
127127+ script = systemActivationScript set false;
128128+ };
129129+ };
103130104104- # Make this configuration the current configuration.
105105- # The readlink is there to ensure that when $systemConfig = /system
106106- # (which is a symlink to the store), /run/current-system is still
107107- # used as a garbage collection root.
108108- ln -sfn "$(readlink -f "$systemConfig")" /run/current-system
109109-110110- # Prevent the current configuration from being garbage-collected.
111111- ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
112112-113113- exit $_status
114114- '';
115115- };
131131+ system.dryActivationScript = mkOption {
132132+ description = "The shell script that is to be run when dry-activating a system.";
133133+ readOnly = true;
134134+ internal = true;
135135+ default = systemActivationScript (removeAttrs config.system.activationScripts [ "script" ]) true;
116136 };
117137118138 system.userActivationScripts = mkOption {
···137157 idempotent and fast.
138158 '';
139159140140- type = with types; attrsOf scriptType;
160160+ type = with types; attrsOf (scriptType false);
141161142162 apply = set: {
143163 script = ''
···3636 exit 1;
3737}
38383939+$ENV{NIXOS_ACTION} = $action;
4040+3941# This is a NixOS installation if it has /etc/NIXOS or a proper
4042# /etc/os-release.
4143die "This is not a NixOS installation!\n" unless
···360362 if scalar @unitsToStopFiltered > 0;
361363 print STDERR "would NOT stop the following changed units: ", join(", ", sort(keys %unitsToSkip)), "\n"
362364 if scalar(keys %unitsToSkip) > 0;
365365+366366+ print STDERR "would activate the configuration...\n";
367367+ system("$out/dry-activate", "$out");
368368+363369 print STDERR "would restart systemd\n" if $restartSystemd;
364370 print STDERR "would restart the following units: ", join(", ", sort(keys %unitsToRestart)), "\n"
365371 if scalar(keys %unitsToRestart) > 0;
+5-2
nixos/modules/system/activation/top-level.nix
···5656 ''}
57575858 echo "$activationScript" > $out/activate
5959+ echo "$dryActivationScript" > $out/dry-activate
5960 substituteInPlace $out/activate --subst-var out
6060- chmod u+x $out/activate
6161- unset activationScript
6161+ substituteInPlace $out/dry-activate --subst-var out
6262+ chmod u+x $out/activate $out/dry-activate
6363+ unset activationScript dryActivationScript
62646365 cp ${config.system.build.bootStage2} $out/init
6466 substituteInPlace $out/init --subst-var-by systemConfig $out
···108110 config.system.build.installBootLoader
109111 or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true";
110112 activationScript = config.system.activationScripts.script;
113113+ dryActivationScript = config.system.dryActivationScript;
111114 nixosLabel = config.system.nixos.label;
112115113116 configurationName = config.boot.loader.grub.configurationName;
···11+{ stdenv, lib, version, src, cmake, python3, llvm, libcxxabi }:
22+stdenv.mkDerivation rec {
33+ pname = "compiler-rt";
44+ inherit version src;
55+66+ nativeBuildInputs = [ cmake python3 llvm ];
77+88+ NIX_CFLAGS_COMPILE = [
99+ "-DSCUDO_DEFAULT_OPTIONS=DeleteSizeMismatch=0:DeallocationTypeMismatch=0"
1010+ ];
1111+1212+ cmakeFlags = [
1313+ "-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON"
1414+ "-DCMAKE_C_COMPILER_TARGET=${stdenv.hostPlatform.config}"
1515+ "-DCMAKE_ASM_COMPILER_TARGET=${stdenv.hostPlatform.config}"
1616+ "-DCOMPILER_RT_BUILD_SANITIZERS=OFF"
1717+ "-DCOMPILER_RT_BUILD_XRAY=OFF"
1818+ "-DCOMPILER_RT_BUILD_LIBFUZZER=OFF"
1919+ "-DCOMPILER_RT_BUILD_PROFILE=OFF"
2020+ "-DCMAKE_C_COMPILER_WORKS=ON"
2121+ "-DCMAKE_CXX_COMPILER_WORKS=ON"
2222+ "-DCOMPILER_RT_BAREMETAL_BUILD=ON"
2323+ "-DCMAKE_SIZEOF_VOID_P=${toString (stdenv.hostPlatform.parsed.cpu.bits / 8)}"
2424+ "-DCOMPILER_RT_BUILD_BUILTINS=ON"
2525+ "-DCMAKE_C_FLAGS=-nodefaultlibs"
2626+ #https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program
2727+ "-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY"
2828+ ];
2929+3030+ outputs = [ "out" "dev" ];
3131+3232+ patches = [
3333+ ./compiler-rt-codesign.patch # Revert compiler-rt commit that makes codesign mandatory
3434+ ];
3535+3636+3737+ # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
3838+ # to get it, but they're unfree. Since LLVM is rather central to the stdenv, we patch out TSAN support so that Hydra
3939+ # can build this. If we didn't do it, basically the entire nixpkgs on Darwin would have an unfree dependency and we'd
4040+ # get no binary cache for the entire platform. If you really find yourself wanting the TSAN, make this controllable by
4141+ # a flag and turn the flag off during the stdenv build.
4242+ postPatch = lib.optionalString (!stdenv.isDarwin) ''
4343+ substituteInPlace cmake/builtin-config-ix.cmake \
4444+ --replace 'set(X86 i386)' 'set(X86 i386 i486 i586 i686)'
4545+ '';
4646+4747+ # Hack around weird upsream RPATH bug
4848+ postInstall = ''
4949+ ln -s "$out/lib"/*/* "$out/lib"
5050+ ln -s $out/lib/*/clang_rt.crtbegin-*.o $out/lib/crtbegin.o
5151+ ln -s $out/lib/*/clang_rt.crtend-*.o $out/lib/crtend.o
5252+ ln -s $out/lib/*/clang_rt.crtbegin_shared-*.o $out/lib/crtbeginS.o
5353+ ln -s $out/lib/*/clang_rt.crtend_shared-*.o $out/lib/crtendS.o
5454+ '';
5555+5656+ enableParallelBuilding = true;
5757+5858+ meta = with lib; {
5959+ description = "ROCm fork of the LLVM Compiler runtime libraries";
6060+ homepage = "https://github.com/RadeonOpenCompute/llvm-project";
6161+ license = licenses.ncsa;
6262+ maintainers = with maintainers; [ acowley danieldk lovesegfault ];
6363+ platforms = platforms.linux;
6464+ };
6565+}