microsoft/surface: Use cleaner logic for managing list of supported kernels

This commit is contained in:
mexisme 2026-02-12 13:05:40 +00:00
parent d03c256822
commit 3652e05fa7

View file

@ -6,6 +6,10 @@
}: }:
let let
inherit (builtins)
attrNames
;
inherit (lib) inherit (lib)
mkDefault mkDefault
mkOption mkOption
@ -13,24 +17,20 @@ let
versions versions
; ;
# Set the version and hash for the kernel sources supportedKernels = {
srcVersion = "longterm" = {
with config.hardware.microsoft-surface; version = "6.12.19";
if kernelVersion == "longterm" then hash = "sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE=";
"6.12.19" };
else if kernelVersion == "stable" then "stable" = {
"6.18.8" version = "6.18.8";
else hash = "sha256-N/DF1cJCwdYE6H1I8IeV6GGlqF9yW0yhHQpTjxL/jP8=";
abort "Invalid kernel version: ${kernelVersion}"; };
};
srcHash = # Set the version and hash for the kernel sources
with config.hardware.microsoft-surface; srcVersion = supportedKernels.${config.hardware.microsoft-surface.kernelVersion}.version;
if kernelVersion == "longterm" then srcHash = supportedKernels.${config.hardware.microsoft-surface.kernelVersion}.hash;
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
else if kernelVersion == "stable" then
"sha256-N/DF1cJCwdYE6H1I8IeV6GGlqF9yW0yhHQpTjxL/jP8="
else
abort "Invalid kernel version: ${kernelVersion}";
# Fetch the latest linux-surface patches # Fetch the latest linux-surface patches
linux-surface = pkgs.fetchFromGitHub { linux-surface = pkgs.fetchFromGitHub {
@ -61,10 +61,7 @@ in
{ {
options.hardware.microsoft-surface.kernelVersion = mkOption { options.hardware.microsoft-surface.kernelVersion = mkOption {
description = "Kernel Version to use (patched for MS Surface)"; description = "Kernel Version to use (patched for MS Surface)";
type = types.enum [ type = types.enum (attrNames supportedKernels);
"longterm"
"stable"
];
default = "longterm"; default = "longterm";
}; };