@@ -93,19 +93,12 @@ let
9393 ${config.system.extraSystemBuilderCmds}
9494 '';
9595
96− # Handle assertions
97−
98− failed = map (x: x.message) (filter (x: !x.assertion) config.assertions);
99−
100− showWarnings = res: fold (w: x: builtins.trace "[1;31mwarning: ${w}[0m" x) res config.warnings;
101−
10296 # Putting it all together. This builds a store path containing
10397 # symlinks to the various parts of the built configuration (the
10498 # kernel, systemd units, init scripts, etc.) as well as a script
10599 # `switch-to-configuration' that activates the configuration and
106100 # makes it bootable.
107− baseSystem = showWarnings (
108− if [] == failed then pkgs.stdenvNoCC.mkDerivation {
101+ baseSystem = pkgs.stdenvNoCC.mkDerivation {
109102 name = let hn = config.networking.hostName;
110103 nn = if (hn != "") then hn else "unnamed";
111104 in "nixos-system-${nn}-${config.system.nixos.label}";
@@ -130,12 +123,22 @@ let
130123 # Needed by switch-to-configuration.
131124
132125 perl = "${pkgs.perl}/bin/perl " + (concatMapStringsSep " " (lib: "-I${lib}/${pkgs.perl.libPrefix}") (with pkgs.perlPackages; [ FileSlurp NetDBus XMLParser XMLTwig ]));
133− } else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}");
126+ };
127+
128+ # Handle assertions and warnings
129+
130+ failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
131+
132+ showWarnings = res: fold (w: x: builtins.trace "[1;31mwarning: ${w}[0m" x) res config.warnings;
133+
134+ baseSystemAssertWarn = if failedAssertions != []
135+ then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
136+ else showWarnings baseSystem;
134137
135138 # Replace runtime dependencies
136139 system = fold ({ oldDependency, newDependency }: drv:
137140 pkgs.replaceDependency { inherit oldDependency newDependency drv; }
138− ) baseSystem config.system.replaceRuntimeDependencies;
141+ ) baseSystemAssertWarn config.system.replaceRuntimeDependencies;
139142
140143in
141144