mirror of
				https://github.com/NixOS/nixos-hardware.git
				synced 2025-11-04 09:17:14 +08:00 
			
		
		
		
	new kernelAtleast option at lib/kernel-version.nix
Issues a warning when the kernel version is below a threshhold.
This commit is contained in:
		
							
								
								
									
										31
									
								
								lib/kernel-version.nix
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								lib/kernel-version.nix
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user