diff options
author | Jan Malakhovski <oxij@oxij.org> | 2018-09-24 19:40:59 +0000 |
---|---|---|
committer | Jan Malakhovski <oxij@oxij.org> | 2018-09-24 19:45:15 +0000 |
commit | fece91537bc31c070a80015a54149d45644b1ced (patch) | |
tree | 832668d0f6718e2f022714ac3957ac1aec2c599a /nixos/modules/system/activation/top-level.nix | |
parent | 0f3b89bbedc1a33cc1fc3c142e235da2c64614c3 (diff) | |
download | nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar.gz nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar.bz2 nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar.lz nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar.xz nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.tar.zst nixpkgs-fece91537bc31c070a80015a54149d45644b1ced.zip |
nixos: top-level: evaluate assertions before warnings
or else at least the following config will fail with an evaluation error instead of an assert ``` { services.nixosManual.enable = false; services.nixosManual.showManual = true; } ```
Diffstat (limited to 'nixos/modules/system/activation/top-level.nix')
-rw-r--r-- | nixos/modules/system/activation/top-level.nix | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 254e9266e89..848587bde29 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -93,19 +93,12 @@ 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. - baseSystem = showWarnings ( - if [] == failed then pkgs.stdenvNoCC.mkDerivation { + baseSystem = pkgs.stdenvNoCC.mkDerivation { name = let hn = config.networking.hostName; nn = if (hn != "") then hn else "unnamed"; in "nixos-system-${nn}-${config.system.nixos.label}"; @@ -130,12 +123,22 @@ let # Needed by switch-to-configuration. perl = "${pkgs.perl}/bin/perl " + (concatMapStringsSep " " (lib: "-I${lib}/${pkgs.perl.libPrefix}") (with pkgs.perlPackages; [ FileSlurp NetDBus XMLParser XMLTwig ])); - } else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}"); + }; + + # Handle assertions and warnings + + failedAssertions = 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; + + baseSystemAssertWarn = if failedAssertions != [] + then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" + else showWarnings baseSystem; # Replace runtime dependencies system = fold ({ oldDependency, newDependency }: drv: pkgs.replaceDependency { inherit oldDependency newDependency drv; } - ) baseSystem config.system.replaceRuntimeDependencies; + ) baseSystemAssertWarn config.system.replaceRuntimeDependencies; in |