From 570aed4b46916551da969c4daeef0322461ac2fe Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Sat, 23 Feb 2019 18:06:51 +0000 Subject: [PATCH] lib: add `showWarnings` --- lib/default.nix | 2 +- lib/trivial.nix | 3 ++- nixos/modules/system/activation/top-level.nix | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index dbb90081b2c3..688c117d52b4 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -59,7 +59,7 @@ let stringLength sub substring tail; inherit (trivial) id const concat or and bitAnd bitOr bitXor bitNot boolToString mergeAttrs flip mapNullable inNixShell min max - importJSON warn info nixpkgsVersion version mod compare + importJSON warn info showWarnings nixpkgsVersion version mod compare splitByAndCompare functionArgs setFunctionArgs isFunction; inherit (fixedPoints) fix fix' converge extends composeExtensions makeExtensible makeExtensibleWithCustomName; diff --git a/lib/trivial.nix b/lib/trivial.nix index 3f0816b55405..2d682961035f 100644 --- a/lib/trivial.nix +++ b/lib/trivial.nix @@ -259,9 +259,10 @@ rec { # TODO: figure out a clever way to integrate location information from # something like __unsafeGetAttrPos. - warn = msg: builtins.trace "WARNING: ${msg}"; + warn = msg: builtins.trace "warning: ${msg}"; info = msg: builtins.trace "INFO: ${msg}"; + showWarnings = warnings: res: lib.fold (w: x: warn w x) res warnings; ## Function annotations diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index a560af5ce96d..5c88d27b6c65 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -130,11 +130,9 @@ let failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions); - showWarnings = res: fold (w: x: builtins.trace "warning: ${w}" x) res config.warnings; - baseSystemAssertWarn = if failedAssertions != [] then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" - else showWarnings baseSystem; + else showWarnings config.warnings baseSystem; # Replace runtime dependencies system = fold ({ oldDependency, newDependency }: drv: