From 0a3514de568ee2884dd642f497cae3740a3e29a4 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 26 Feb 2016 10:40:24 +0100 Subject: [PATCH] new kernelAtleast option at lib/kernel-version.nix Issues a warning when the kernel version is below a threshhold. --- lib/kernel-version.nix | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/kernel-version.nix diff --git a/lib/kernel-version.nix b/lib/kernel-version.nix new file mode 100644 index 0000000..99115a7 --- /dev/null +++ b/lib/kernel-version.nix @@ -0,0 +1,31 @@ +{ config, lib, ... }: +with lib; +let + cfg = config; +in +{ + options.kernelAtleast = mkOption { + type = types.listOf types.optionSet; + options = + [ { version = mkOption { + type = types.str; + example = "4.4"; + description = + "Issue warning when kernel version is below this number."; + }; + msg = mkOption { + type = types.str; + example = ""; + }; + } + ]; + }; + + config.warnings = builtins.concatLists (map + (x: if (builtins.compareVersions cfg.boot.kernelPackages.kernel.version x.version) == -1 + then [ "${x.msg} (${cfg.boot.kernelPackages.kernel.version} < ${x.version})" ] + else [ ] + ) cfg.kernelAtleast + ); + +}