Skip to content

Commit 33aa2d8

Browse files
committed
microsoft/surface: decouple kernel source and linux-surface package versions
1 parent 2034c5d commit 33aa2d8

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

microsoft/surface/common/default.nix

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,58 @@
33
let
44
inherit (lib) mkDefault mkOption types versions;
55

6-
# Set the full kernel version and hashes
7-
version =
8-
if config.microsoft-surface.kernelVersion == "longterm" then
6+
# Set the version and hash for the kernel sources
7+
srcVersion = with config.microsoft-surface;
8+
if kernelVersion == "longterm" then
99
"6.12.19"
10-
else if config.microsoft-surface.kernelVersion == "stable" then
10+
else if kernelVersion == "stable" then
1111
"6.13.6"
1212
else
13-
abort "Invalid kernel version: ${config.microsoft-surface.kernelVersion}";
14-
15-
shortVersion = versions.majorMinor version;
16-
packageHash =
17-
if shortVersion == "6.12" then
18-
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
19-
else if shortVersion == "6.13" then
20-
"sha256-otD1ckNxNnvV8xipf9SZpbfg+bBq5EPwyieYtLIV4Ck="
21-
else
22-
abort "Invalid kernel version: ${shortVersion}";
13+
abort "Invalid kernel version: ${kernelVersion}";
2314

24-
srcHash =
25-
if shortVersion == "6.12" then
15+
srcHash = with config.microsoft-surface;
16+
if kernelVersion == "longterm" then
2617
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
27-
else if shortVersion == "6.13" then
18+
else if kernelVersion == "stable" then
2819
"sha256-3gBTy0E9QI8g/R1XiCGZUbikQD5drBsdkDIJCTis0Zk="
2920
else
30-
abort "Invalid kernel version: ${shortVersion}";
21+
abort "Invalid kernel version: ${kernelVersion}";
22+
23+
# Set the version and hash for the linux-surface releases
24+
pkgVersion = with config.microsoft-surface;
25+
if kernelVersion == "longterm" then
26+
"6.12.7"
27+
else if kernelVersion == "stable" then
28+
"6.13.6"
29+
else
30+
abort "Invalid kernel version: ${kernelVersion}";
31+
32+
pkgHash = with config.microsoft-surface;
33+
if kernelVersion == "longterm" then
34+
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
35+
else if kernelVersion == "stable" then
36+
"sha256-otD1ckNxNnvV8xipf9SZpbfg+bBq5EPwyieYtLIV4Ck="
37+
else
38+
abort "Invalid kernel version: ${kernelVersion}";
3139

32-
# Fetch the release from the linux-surface project
33-
rev = "arch-${version}-1";
34-
repos = pkgs.callPackage ({ fetchFromGitHub, rev, packageHash }: {
40+
# Fetch the linux-surface package
41+
repos = pkgs.callPackage ({ fetchFromGitHub, rev, hash }: {
3542
linux-surface = fetchFromGitHub {
3643
owner = "linux-surface";
3744
repo = "linux-surface";
3845
rev = rev;
39-
hash = packageHash;
46+
hash = hash;
4047
};
41-
}) { inherit rev packageHash; };
48+
}) { hash = pkgHash; rev = "arch-${pkgVersion}-1"; };
4249

43-
# Build the kernel package
50+
# Fetch and build the kernel package
4451
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; }) linuxPackage surfacePatches;
4552
kernelPatches = surfacePatches {
46-
inherit version;
47-
patchFn = ./kernel/${shortVersion}/patches.nix;
53+
version = pkgVersion;
54+
patchFn = ./kernel/${versions.majorMinor pkgVersion}/patches.nix;
4855
};
4956
kernelPackages = linuxPackage {
50-
inherit version kernelPatches;
57+
inherit kernelPatches; version = srcVersion;
5158
sha256 = srcHash;
5259
ignoreConfigErrors=true;
5360
};

0 commit comments

Comments
 (0)