diff options
author | Shea Levy <shea@shealevy.com> | 2014-04-21 11:46:16 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2014-04-22 14:09:02 -0400 |
commit | 7d1ddae58e465a1708967c9fee651c33819969c6 (patch) | |
tree | 7a71354c5c1c8a8e8959a9f696af4d077df821ac /nixos/modules/system/activation/top-level.nix | |
parent | 5ba24cc8ea7c3979a174142393d155bbc32167cf (diff) | |
download | nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar.gz nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar.bz2 nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar.lz nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar.xz nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.tar.zst nixlib-7d1ddae58e465a1708967c9fee651c33819969c6.zip |
nixos: evaluate assertions at toplevel, not at systemPackages
Fixes #2340
Diffstat (limited to 'nixos/modules/system/activation/top-level.nix')
-rw-r--r-- | nixos/modules/system/activation/top-level.nix | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 7cdaecce198e..b739ef693ce9 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -84,33 +84,39 @@ let ${config.system.extraSystemBuilderCmds} ''; + # Handle assertions + + failed = map (x: x.message) (filter (x: !x.assertion) config.assertions); + + showWarnings = res: fold (w: x: builtins.trace "^[[1;31mwarning: ${w}^[[0m" x) res config.warnings; # Putting it all together. This builds a store path containing # symlinks to the various parts of the built configuration (the # kernel, systemd units, init scripts, etc.) as well as a script # `switch-to-configuration' that activates the configuration and # makes it bootable. - system = pkgs.stdenv.mkDerivation { - name = "nixos-${config.system.nixosVersion}"; - preferLocalBuild = true; - buildCommand = systemBuilder; - - inherit (pkgs) utillinux coreutils; - systemd = config.systemd.package; - - inherit children; - kernelParams = config.boot.kernelParams; - installBootLoader = - config.system.build.installBootLoader - or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; - activationScript = config.system.activationScripts.script; - nixosVersion = config.system.nixosVersion; - - configurationName = config.boot.loader.grub.configurationName; - - # Needed by switch-to-configuration. - perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl"; - }; + system = showWarnings ( + if [] == failed then pkgs.stdenv.mkDerivation { + name = "nixos-${config.system.nixosVersion}"; + preferLocalBuild = true; + buildCommand = systemBuilder; + + inherit (pkgs) utillinux coreutils; + systemd = config.systemd.package; + + inherit children; + kernelParams = config.boot.kernelParams; + installBootLoader = + config.system.build.installBootLoader + or "echo 'Warning: do not know how to make this configuration bootable; please enable a boot loader.' 1>&2; true"; + activationScript = config.system.activationScripts.script; + nixosVersion = config.system.nixosVersion; + + configurationName = config.boot.loader.grub.configurationName; + + # Needed by switch-to-configuration. + perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl"; + } else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}"); in |