microsoft/surface: decouple kernel source and linux-surface package versions

This commit is contained in:
Andre
2025-04-12 11:28:09 -04:00
parent 2034c5d2e7
commit 33aa2d8399

View File

@@ -3,51 +3,58 @@
let let
inherit (lib) mkDefault mkOption types versions; inherit (lib) mkDefault mkOption types versions;
# Set the full kernel version and hashes # Set the version and hash for the kernel sources
version = srcVersion = with config.microsoft-surface;
if config.microsoft-surface.kernelVersion == "longterm" then if kernelVersion == "longterm" then
"6.12.19" "6.12.19"
else if config.microsoft-surface.kernelVersion == "stable" then else if kernelVersion == "stable" then
"6.13.6" "6.13.6"
else else
abort "Invalid kernel version: ${config.microsoft-surface.kernelVersion}"; abort "Invalid kernel version: ${kernelVersion}";
shortVersion = versions.majorMinor version; srcHash = with config.microsoft-surface;
packageHash = if kernelVersion == "longterm" then
if shortVersion == "6.12" then
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
else if shortVersion == "6.13" then
"sha256-otD1ckNxNnvV8xipf9SZpbfg+bBq5EPwyieYtLIV4Ck="
else
abort "Invalid kernel version: ${shortVersion}";
srcHash =
if shortVersion == "6.12" then
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE=" "sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
else if shortVersion == "6.13" then else if kernelVersion == "stable" then
"sha256-3gBTy0E9QI8g/R1XiCGZUbikQD5drBsdkDIJCTis0Zk=" "sha256-3gBTy0E9QI8g/R1XiCGZUbikQD5drBsdkDIJCTis0Zk="
else else
abort "Invalid kernel version: ${shortVersion}"; abort "Invalid kernel version: ${kernelVersion}";
# Fetch the release from the linux-surface project # Set the version and hash for the linux-surface releases
rev = "arch-${version}-1"; pkgVersion = with config.microsoft-surface;
repos = pkgs.callPackage ({ fetchFromGitHub, rev, packageHash }: { if kernelVersion == "longterm" then
"6.12.7"
else if kernelVersion == "stable" then
"6.13.6"
else
abort "Invalid kernel version: ${kernelVersion}";
pkgHash = with config.microsoft-surface;
if kernelVersion == "longterm" then
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
else if kernelVersion == "stable" then
"sha256-otD1ckNxNnvV8xipf9SZpbfg+bBq5EPwyieYtLIV4Ck="
else
abort "Invalid kernel version: ${kernelVersion}";
# Fetch the linux-surface package
repos = pkgs.callPackage ({ fetchFromGitHub, rev, hash }: {
linux-surface = fetchFromGitHub { linux-surface = fetchFromGitHub {
owner = "linux-surface"; owner = "linux-surface";
repo = "linux-surface"; repo = "linux-surface";
rev = rev; rev = rev;
hash = packageHash; hash = hash;
}; };
}) { inherit rev packageHash; }; }) { hash = pkgHash; rev = "arch-${pkgVersion}-1"; };
# Build the kernel package # Fetch and build the kernel package
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; }) linuxPackage surfacePatches; inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; }) linuxPackage surfacePatches;
kernelPatches = surfacePatches { kernelPatches = surfacePatches {
inherit version; version = pkgVersion;
patchFn = ./kernel/${shortVersion}/patches.nix; patchFn = ./kernel/${versions.majorMinor pkgVersion}/patches.nix;
}; };
kernelPackages = linuxPackage { kernelPackages = linuxPackage {
inherit version kernelPatches; inherit kernelPatches; version = srcVersion;
sha256 = srcHash; sha256 = srcHash;
ignoreConfigErrors=true; ignoreConfigErrors=true;
}; };