From 8605f354e2409ce5f7a9ad3589427e3d11937674 Mon Sep 17 00:00:00 2001 From: mexisme Date: Sun, 26 Nov 2023 12:42:11 +1300 Subject: [PATCH 01/10] Use a new linuxPackage function --- .../common/kernel/linux-6.1.x/default.nix | 8 +-- .../common/kernel/linux-6.1.x/patches.nix | 33 +++++++------ .../common/kernel/linux-6.5.x/default.nix | 8 +-- .../common/kernel/linux-6.5.x/patches.nix | 33 +++++++------ .../surface/common/kernel/linux-package.nix | 49 ++++++++++++++++--- 5 files changed, 84 insertions(+), 47 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-6.1.x/default.nix b/microsoft/surface/common/kernel/linux-6.1.x/default.nix index 05ec4cf..45105cc 100644 --- a/microsoft/surface/common/kernel/linux-6.1.x/default.nix +++ b/microsoft/surface/common/kernel/linux-6.1.x/default.nix @@ -4,19 +4,19 @@ let inherit (lib) mkIf mkOption types; inherit (pkgs) fetchurl; - inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage repos; + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage1 repos; cfg = config.microsoft-surface; version = "6.1.62"; extraMeta.branch = "6.1"; - patchDir = repos.linux-surface + "/patches/${extraMeta.branch}"; + patchSrc = repos.linux-surface + "/patches/${extraMeta.branch}"; kernelPatches = pkgs.callPackage ./patches.nix { inherit (lib) kernel; - inherit version patchDir; + inherit version patchSrc; }; - kernelPackages = linuxPackage { + kernelPackages = linuxPackage1 { inherit version extraMeta kernelPatches; src = fetchurl { url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz"; diff --git a/microsoft/surface/common/kernel/linux-6.1.x/patches.nix b/microsoft/surface/common/kernel/linux-6.1.x/patches.nix index e197649..5af71be 100644 --- a/microsoft/surface/common/kernel/linux-6.1.x/patches.nix +++ b/microsoft/surface/common/kernel/linux-6.1.x/patches.nix @@ -1,5 +1,6 @@ -{ kernel, - patchDir, +{ lib, + kernel ? lib.kernel, + patchSrc, version, }: @@ -84,58 +85,58 @@ } { name = "ms-surface/0001-surface3-oemb"; - patch = patchDir + "/0001-surface3-oemb.patch"; + patch = patchSrc + "/0001-surface3-oemb.patch"; } { name = "ms-surface/0002-mwifiex"; - patch = patchDir + "/0002-mwifiex.patch"; + patch = patchSrc + "/0002-mwifiex.patch"; } { name = "ms-surface/0003-ath10k"; - patch = patchDir + "/0003-ath10k.patch"; + patch = patchSrc + "/0003-ath10k.patch"; } { name = "ms-surface/0004-ipts"; - patch = patchDir + "/0004-ipts.patch"; + patch = patchSrc + "/0004-ipts.patch"; } { name = "ms-surface/0005-ithc"; - patch = patchDir + "/0005-ithc.patch"; + patch = patchSrc + "/0005-ithc.patch"; } { name = "ms-surface/0006-surface-sam"; - patch = patchDir + "/0006-surface-sam.patch"; + patch = patchSrc + "/0006-surface-sam.patch"; } { name = "ms-surface/0007-surface-sam-over-hid"; - patch = patchDir + "/0007-surface-sam-over-hid.patch"; + patch = patchSrc + "/0007-surface-sam-over-hid.patch"; } { name = "ms-surface/0008-surface-button"; - patch = patchDir + "/0008-surface-button.patch"; + patch = patchSrc + "/0008-surface-button.patch"; } { name = "ms-surface/0009-surface-typecover"; - patch = patchDir + "/0009-surface-typecover.patch"; + patch = patchSrc + "/0009-surface-typecover.patch"; } { name = "ms-surface/0010-surface-shutdown"; - patch = patchDir + "/0010-surface-shutdown.patch"; + patch = patchSrc + "/0010-surface-shutdown.patch"; } { name = "ms-surface/0011-surface-gpe"; - patch = patchDir + "/0011-surface-gpe.patch"; + patch = patchSrc + "/0011-surface-gpe.patch"; } { name = "ms-surface/0012-cameras"; - patch = patchDir + "/0012-cameras.patch"; + patch = patchSrc + "/0012-cameras.patch"; } { name = "ms-surface/0013-amd-gpio"; - patch = patchDir + "/0013-amd-gpio.patch"; + patch = patchSrc + "/0013-amd-gpio.patch"; } { name = "ms-surface/0014-rtc"; - patch = patchDir + "/0014-rtc.patch"; + patch = patchSrc + "/0014-rtc.patch"; } ] diff --git a/microsoft/surface/common/kernel/linux-6.5.x/default.nix b/microsoft/surface/common/kernel/linux-6.5.x/default.nix index b26b466..0d90108 100644 --- a/microsoft/surface/common/kernel/linux-6.5.x/default.nix +++ b/microsoft/surface/common/kernel/linux-6.5.x/default.nix @@ -4,19 +4,19 @@ let inherit (lib) mkIf mkOption types; inherit (pkgs) fetchurl; - inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage repos; + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage1 repos; cfg = config.microsoft-surface; version = "6.5.11"; extraMeta.branch = "6.5"; - patchDir = repos.linux-surface + "/patches/${extraMeta.branch}"; + patchSrc = repos.linux-surface + "/patches/${extraMeta.branch}"; kernelPatches = pkgs.callPackage ./patches.nix { inherit (lib) kernel; - inherit version patchDir; + inherit version patchSrc; }; - kernelPackages = linuxPackage { + kernelPackages = linuxPackage1 { inherit version extraMeta kernelPatches; src = fetchurl { url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz"; diff --git a/microsoft/surface/common/kernel/linux-6.5.x/patches.nix b/microsoft/surface/common/kernel/linux-6.5.x/patches.nix index d7b9289..148f8b2 100644 --- a/microsoft/surface/common/kernel/linux-6.5.x/patches.nix +++ b/microsoft/surface/common/kernel/linux-6.5.x/patches.nix @@ -1,5 +1,6 @@ -{ kernel, - patchDir, +{ lib, + kernel ? lib.kernel, + patchSrc, version, }: @@ -85,58 +86,58 @@ } { name = "ms-surface/0001-surface3-oemb"; - patch = patchDir + "/0001-surface3-oemb.patch"; + patch = patchSrc + "/0001-surface3-oemb.patch"; } { name = "ms-surface/0002-mwifiex"; - patch = patchDir + "/0002-mwifiex.patch"; + patch = patchSrc + "/0002-mwifiex.patch"; } { name = "ms-surface/0003-ath10k"; - patch = patchDir + "/0003-ath10k.patch"; + patch = patchSrc + "/0003-ath10k.patch"; } { name = "ms-surface/0004-ipts"; - patch = patchDir + "/0004-ipts.patch"; + patch = patchSrc + "/0004-ipts.patch"; } { name = "ms-surface/0005-ithc"; - patch = patchDir + "/0005-ithc.patch"; + patch = patchSrc + "/0005-ithc.patch"; } { name = "ms-surface/0006-surface-sam"; - patch = patchDir + "/0006-surface-sam.patch"; + patch = patchSrc + "/0006-surface-sam.patch"; } { name = "ms-surface/0007-surface-sam-over-hid"; - patch = patchDir + "/0007-surface-sam-over-hid.patch"; + patch = patchSrc + "/0007-surface-sam-over-hid.patch"; } { name = "ms-surface/0008-surface-button"; - patch = patchDir + "/0008-surface-button.patch"; + patch = patchSrc + "/0008-surface-button.patch"; } { name = "ms-surface/0009-surface-typecover"; - patch = patchDir + "/0009-surface-typecover.patch"; + patch = patchSrc + "/0009-surface-typecover.patch"; } { name = "ms-surface/0010-surface-shutdown"; - patch = patchDir + "/0010-surface-shutdown.patch"; + patch = patchSrc + "/0010-surface-shutdown.patch"; } { name = "ms-surface/0011-surface-gpe"; - patch = patchDir + "/0011-surface-gpe.patch"; + patch = patchSrc + "/0011-surface-gpe.patch"; } { name = "ms-surface/0012-cameras"; - patch = patchDir + "/0012-cameras.patch"; + patch = patchSrc + "/0012-cameras.patch"; } { name = "ms-surface/0013-amd-gpio"; - patch = patchDir + "/0013-amd-gpio.patch"; + patch = patchSrc + "/0013-amd-gpio.patch"; } { name = "ms-surface/0014-rtc"; - patch = patchDir + "/0014-rtc.patch"; + patch = patchSrc + "/0014-rtc.patch"; } ] diff --git a/microsoft/surface/common/kernel/linux-package.nix b/microsoft/surface/common/kernel/linux-package.nix index c115df1..b4082a4 100644 --- a/microsoft/surface/common/kernel/linux-package.nix +++ b/microsoft/surface/common/kernel/linux-package.nix @@ -1,16 +1,17 @@ -{ lib, +{ pkgs, + lib, + fetchurl, buildLinux, - callPackage, linuxPackagesFor, }: let - inherit (lib) recurseIntoAttrs; + inherit (lib) recurseIntoAttrs versions; + repos = pkgs.callPackage ../repos.nix {}; -in { - repos = callPackage ../repos.nix {}; - - linuxPackage = + # Version 1 of the linuxPackage function: + # (DEPRECATED) + linuxPackage1 = { version, modDirVersion ? version, ... @@ -19,4 +20,38 @@ in { buildLinux' = buildLinux (args // { inherit modDirVersion; }); linuxPackagesFor' = linuxPackagesFor buildLinux'; in recurseIntoAttrs linuxPackagesFor'; + + # Version 1 of the linuxPackage funtion, with hopefully simplified arguments: + linuxPackage2 = + { url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz", + sha256 ? null, + src ? (fetchurl { inherit url sha256; }), + version, + modDirVersion ? (versions.pad 3 version), + kernelPatches ? [], + ... + } @ args: let + inherit (builtins) removeAttrs; + + args' = { + inherit src version modDirVersion kernelPatches; + } // removeAttrs args [ "url" "sha256" ]; + linuxPackage = buildLinux args'; + linuxPackages' = recurseIntoAttrs (linuxPackagesFor linuxPackage); + in linuxPackages'; + + surfacePatches = + { patchSrc ? (repos.linux-surface + "/patches/${versions.major version}"), + version, + patchFn, + }: pkgs.callPackage patchFn { + inherit (lib) kernel; + inherit version patchSrc; + }; + +in { + inherit linuxPackage1 linuxPackage2 repos surfacePatches; + + # Default version: + linuxPackage = linuxPackage2; } From 0516b822878bb28639bc1c9176f4889e7fbd83bb Mon Sep 17 00:00:00 2001 From: mexisme Date: Sun, 26 Nov 2023 12:43:48 +1300 Subject: [PATCH 02/10] Add kernel 6.6 --- microsoft/surface/common/kernel/default.nix | 1 + .../common/kernel/linux-6.6.x/default.nix | 30 ++++ .../common/kernel/linux-6.6.x/patches.nix | 142 ++++++++++++++++++ 3 files changed, 173 insertions(+) create mode 100644 microsoft/surface/common/kernel/linux-6.6.x/default.nix create mode 100644 microsoft/surface/common/kernel/linux-6.6.x/patches.nix diff --git a/microsoft/surface/common/kernel/default.nix b/microsoft/surface/common/kernel/default.nix index a0637a3..481755d 100644 --- a/microsoft/surface/common/kernel/default.nix +++ b/microsoft/surface/common/kernel/default.nix @@ -7,6 +7,7 @@ in { imports = [ ./linux-6.1.x ./linux-6.5.x + ./linux-6.6.x ]; options.microsoft-surface.kernelVersion = mkOption { diff --git a/microsoft/surface/common/kernel/linux-6.6.x/default.nix b/microsoft/surface/common/kernel/linux-6.6.x/default.nix new file mode 100644 index 0000000..e0a3449 --- /dev/null +++ b/microsoft/surface/common/kernel/linux-6.6.x/default.nix @@ -0,0 +1,30 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkIf mkOption types; + + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage2 surfacePatches; + + cfg = config.microsoft-surface; + + version = "6.6.2"; + kernelPatches = surfacePatches { + inherit version; + patchFn = ./patches.nix; + }; + kernelPackages = linuxPackage2 { + inherit version kernelPatches; + sha256 = "sha256-c9T2rY3WrCpB7VLCkoiYt8PyUZ7V29sRkgIJo2mZt34="; + }; + +in { + options.microsoft-surface.kernelVersion = mkOption { + type = types.enum [ version ]; + }; + + config = mkIf (cfg.kernelVersion == version) { + boot = { + inherit kernelPackages; + }; + }; +} diff --git a/microsoft/surface/common/kernel/linux-6.6.x/patches.nix b/microsoft/surface/common/kernel/linux-6.6.x/patches.nix new file mode 100644 index 0000000..9c0dce2 --- /dev/null +++ b/microsoft/surface/common/kernel/linux-6.6.x/patches.nix @@ -0,0 +1,142 @@ +{ lib, + kernel ? lib.kernel, + patchSrc, + version, +}: + +[ + { + name = "microsoft-surface-patches-linux-${version}"; + patch = null; + structuredExtraConfig = with kernel; { + ## + ## Surface Aggregator Module + ## + CONFIG_SURFACE_AGGREGATOR = module; + # CONFIG_SURFACE_AGGREGATOR_ERROR_INJECTION is not set + CONFIG_SURFACE_AGGREGATOR_BUS = yes; + CONFIG_SURFACE_AGGREGATOR_CDEV = module; + CONFIG_SURFACE_AGGREGATOR_HUB = module; + CONFIG_SURFACE_AGGREGATOR_REGISTRY = module; + CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH = module; + + CONFIG_SURFACE_ACPI_NOTIFY = module; + CONFIG_SURFACE_DTX = module; + CONFIG_SURFACE_PLATFORM_PROFILE = module; + + CONFIG_SURFACE_HID = module; + CONFIG_SURFACE_KBD = module; + + CONFIG_BATTERY_SURFACE = module; + CONFIG_CHARGER_SURFACE = module; + + ## + ## Surface Hotplug + ## + CONFIG_SURFACE_HOTPLUG = module; + + ## + ## IPTS and ITHC touchscreen + ## + ## This only enables the user interface for IPTS/ITHC data. + ## For the touchscreen to work, you need to install iptsd. + ## + CONFIG_HID_IPTS = module; + CONFIG_HID_ITHC = module; + + ## + ## Cameras: IPU3 + ## + CONFIG_VIDEO_DW9719 = module; + CONFIG_VIDEO_IPU3_IMGU = module; + CONFIG_VIDEO_IPU3_CIO2 = module; + CONFIG_IPU_BRIDGE = module; + CONFIG_INTEL_SKL_INT3472 = module; + CONFIG_REGULATOR_TPS68470 = module; + CONFIG_COMMON_CLK_TPS68470 = module; + CONFIG_LEDS_TPS68470 = module; + + ## + ## Cameras: Sensor drivers + ## + CONFIG_VIDEO_OV5693 = module; + CONFIG_VIDEO_OV7251 = module; + CONFIG_VIDEO_OV8865 = module; + + ## + ## Surface 3: atomisp causes problems (see issue #1095). Disable it for now. + ## + # CONFIG_INTEL_ATOMISP is not set + + ## + ## ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7 + ## + CONFIG_APDS9960 = module; + + ## + ## Other Drivers + ## + CONFIG_INPUT_SOC_BUTTON_ARRAY = module; + CONFIG_SURFACE_3_POWER_OPREGION = module; + CONFIG_SURFACE_PRO3_BUTTON = module; + CONFIG_SURFACE_GPE = module; + CONFIG_SURFACE_BOOK1_DGPU_SWITCH = module; + }; + } + { + name = "ms-surface/0001-surface3-oemb"; + patch = patchSrc + "/0001-surface3-oemb.patch"; + } + { + name = "ms-surface/0002-mwifiex"; + patch = patchSrc + "/0002-mwifiex.patch"; + } + { + name = "ms-surface/0003-ath10k"; + patch = patchSrc + "/0003-ath10k.patch"; + } + { + name = "ms-surface/0004-ipts"; + patch = patchSrc + "/0004-ipts.patch"; + } + { + name = "ms-surface/0005-ithc"; + patch = patchSrc + "/0005-ithc.patch"; + } + { + name = "ms-surface/0006-surface-sam"; + patch = patchSrc + "/0006-surface-sam.patch"; + } + { + name = "ms-surface/0007-surface-sam-over-hid"; + patch = patchSrc + "/0007-surface-sam-over-hid.patch"; + } + { + name = "ms-surface/0008-surface-button"; + patch = patchSrc + "/0008-surface-button.patch"; + } + { + name = "ms-surface/0009-surface-typecover"; + patch = patchSrc + "/0009-surface-typecover.patch"; + } + { + name = "ms-surface/0010-surface-shutdown"; + patch = patchSrc + "/0010-surface-shutdown.patch"; + } + { + name = "ms-surface/0011-surface-gpe"; + patch = patchSrc + "/0011-surface-gpe.patch"; + } + { + name = "ms-surface/0012-cameras"; + patch = patchSrc + "/0012-cameras.patch"; + } + { + name = "ms-surface/0013-amd-gpio"; + patch = patchSrc + "/0013-amd-gpio.patch"; + } + { + name = "ms-surface/0014-rtc"; + patch = patchSrc + "/0014-rtc.patch"; + } +] From 0e169f3d58c8b8f088aff60cb8a8cdfb49254caa Mon Sep 17 00:00:00 2001 From: mexisme Date: Sun, 26 Nov 2023 12:44:19 +1300 Subject: [PATCH 03/10] Use kernel 6.6.2 by default --- microsoft/surface/common/default.nix | 2 +- microsoft/surface/surface-go/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft/surface/common/default.nix b/microsoft/surface/common/default.nix index b6b00ee..d4ac2fd 100644 --- a/microsoft/surface/common/default.nix +++ b/microsoft/surface/common/default.nix @@ -10,7 +10,7 @@ in { ./surface-control ]; - microsoft-surface.kernelVersion = mkDefault "6.5.11"; + microsoft-surface.kernelVersion = mkDefault "6.6.2"; # Seems to be required to properly enable S0ix "Modern Standby": boot.kernelParams = mkDefault [ "mem_sleep_default=deep" ]; diff --git a/microsoft/surface/surface-go/default.nix b/microsoft/surface/surface-go/default.nix index a1073dd..ede626f 100644 --- a/microsoft/surface/surface-go/default.nix +++ b/microsoft/surface/surface-go/default.nix @@ -17,7 +17,7 @@ in { ../../../common/cpu/intel/kaby-lake ]; - microsoft-surface.kernelVersion = "6.1.62"; + microsoft-surface.kernelVersion = "6.6.2"; boot.kernelParams = [ "i915.enable_rc6=1" From 7dcae71f6107a92991c5c37e7f090684cc3b10c2 Mon Sep 17 00:00:00 2001 From: mexisme Date: Sun, 26 Nov 2023 13:01:52 +1300 Subject: [PATCH 04/10] Fix typos --- microsoft/surface/common/kernel/linux-package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-package.nix b/microsoft/surface/common/kernel/linux-package.nix index b4082a4..8d92553 100644 --- a/microsoft/surface/common/kernel/linux-package.nix +++ b/microsoft/surface/common/kernel/linux-package.nix @@ -21,7 +21,7 @@ let linuxPackagesFor' = linuxPackagesFor buildLinux'; in recurseIntoAttrs linuxPackagesFor'; - # Version 1 of the linuxPackage funtion, with hopefully simplified arguments: + # Version 1 of the linuxPackage function, with hopefully simplified arguments: linuxPackage2 = { url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz", sha256 ? null, @@ -41,7 +41,7 @@ let in linuxPackages'; surfacePatches = - { patchSrc ? (repos.linux-surface + "/patches/${versions.major version}"), + { patchSrc ? (repos.linux-surface + "/patches/${versions.majorMinor version}"), version, patchFn, }: pkgs.callPackage patchFn { From 62b6776b46ef2ae54e529f3b511e9be0736c3837 Mon Sep 17 00:00:00 2001 From: mexisme Date: Sun, 26 Nov 2023 20:09:24 +1300 Subject: [PATCH 05/10] Fix rev and sha256 for the current linux-surface patches --- microsoft/surface/common/repos.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/microsoft/surface/common/repos.nix b/microsoft/surface/common/repos.nix index 99b660f..9c2793c 100644 --- a/microsoft/surface/common/repos.nix +++ b/microsoft/surface/common/repos.nix @@ -4,8 +4,8 @@ linux-surface = fetchFromGitHub { owner = "linux-surface"; repo = "linux-surface"; - rev = "b82e8acd3c015190423b114770b0e9fcc206dd2d"; - hash = "sha256-parp1F5fFzKkiM6ILK+ZolMdSwU1kLOOMvksSwE/zKA="; + rev = "a6eafcad32dc789ae92f42636b11e9aae6e7c879"; #b82e8acd3c015190423b114770b0e9fcc206dd2d"; + hash = "sha256-GfxRzxFxDZoSZyEOzxr/Hz0IonbuwzkGaisKl3VYvlI="; #sha256-parp1F5fFzKkiM6ILK+ZolMdSwU1kLOOMvksSwE/zKA="; }; # This is the owner and repo for the pre-patched kernel from the "linux-surface" project: From 7def5339687ab801e11c8e1395b533ba270e3748 Mon Sep 17 00:00:00 2001 From: mexisme Date: Wed, 31 Jan 2024 12:00:03 +1300 Subject: [PATCH 06/10] Drop the deprecated "linuxPackage1" function, rename "linuxPackage2" to "linuxPackage" --- .../common/kernel/linux-6.6.x/default.nix | 4 ++-- .../surface/common/kernel/linux-package.nix | 20 ++----------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-6.6.x/default.nix b/microsoft/surface/common/kernel/linux-6.6.x/default.nix index 0aa0222..6663138 100644 --- a/microsoft/surface/common/kernel/linux-6.6.x/default.nix +++ b/microsoft/surface/common/kernel/linux-6.6.x/default.nix @@ -3,7 +3,7 @@ let inherit (lib) mkIf mkOption types; - inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage2 surfacePatches; + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches; cfg = config.microsoft-surface; @@ -12,7 +12,7 @@ let inherit version; patchFn = ./patches.nix; }; - kernelPackages = linuxPackage2 { + kernelPackages = linuxPackage { inherit version kernelPatches; sha256 = "sha256-iLiefdQerU46seQRyLuNWSV1rPgVzx3zwNxX4uiCwLw="; ignoreConfigErrors=true; diff --git a/microsoft/surface/common/kernel/linux-package.nix b/microsoft/surface/common/kernel/linux-package.nix index 8d92553..2672e36 100644 --- a/microsoft/surface/common/kernel/linux-package.nix +++ b/microsoft/surface/common/kernel/linux-package.nix @@ -9,20 +9,7 @@ let inherit (lib) recurseIntoAttrs versions; repos = pkgs.callPackage ../repos.nix {}; - # Version 1 of the linuxPackage function: - # (DEPRECATED) - linuxPackage1 = - { version, - modDirVersion ? version, - ... - } @ args: - let - buildLinux' = buildLinux (args // { inherit modDirVersion; }); - linuxPackagesFor' = linuxPackagesFor buildLinux'; - in recurseIntoAttrs linuxPackagesFor'; - - # Version 1 of the linuxPackage function, with hopefully simplified arguments: - linuxPackage2 = + linuxPackage = { url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz", sha256 ? null, src ? (fetchurl { inherit url sha256; }), @@ -50,8 +37,5 @@ let }; in { - inherit linuxPackage1 linuxPackage2 repos surfacePatches; - - # Default version: - linuxPackage = linuxPackage2; + inherit linuxPackage repos surfacePatches; } From 606b6a270e7b9aed4164b088ce8d6c0c9458c7d9 Mon Sep 17 00:00:00 2001 From: mexisme Date: Wed, 31 Jan 2024 12:04:04 +1300 Subject: [PATCH 07/10] Drop the kernel version override for Surface Go hardware --- microsoft/surface/surface-go/default.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/microsoft/surface/surface-go/default.nix b/microsoft/surface/surface-go/default.nix index 0b3169a..fdd13f6 100644 --- a/microsoft/surface/surface-go/default.nix +++ b/microsoft/surface/surface-go/default.nix @@ -17,8 +17,6 @@ in { ../../../common/cpu/intel/kaby-lake ]; - microsoft-surface.kernelVersion = "6.6.10"; - boot.kernelParams = [ "i915.enable_rc6=1" "i915.modeset=1" From c5214dc06a29ce79fbd22e256037e4852ad8a29f Mon Sep 17 00:00:00 2001 From: mexisme Date: Wed, 31 Jan 2024 21:31:15 +1300 Subject: [PATCH 08/10] Add some functions to allow for a major.minor kernel version to be able to auto-allow the major.minor.patch to be auto-selected --- .../surface/common/kernel/linux-package.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-package.nix b/microsoft/surface/common/kernel/linux-package.nix index 2672e36..5cb64b1 100644 --- a/microsoft/surface/common/kernel/linux-package.nix +++ b/microsoft/surface/common/kernel/linux-package.nix @@ -6,7 +6,9 @@ }: let - inherit (lib) recurseIntoAttrs versions; + inherit (builtins) elem; + inherit (lib) recurseIntoAttrs types versions; + repos = pkgs.callPackage ../repos.nix {}; linuxPackage = @@ -36,6 +38,18 @@ let inherit version patchSrc; }; + versionsOf = version: + # Provides a list of versions that can be used as an enum option for this full version: + [ version (versions.majorMinor version) ]; + + versionsOfOption = version: + # Provide an enum option for versions of this kernel: + types.enum (versionsOf version); + + isVersionOf = kernelVersion: version: + # Test if the provided version is considered one of the list of versions from above: + elem version (versionsOf version); + in { - inherit linuxPackage repos surfacePatches; + inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfOption; } From 85a2b5542eed00c5d3362394cc1aca575b963e3a Mon Sep 17 00:00:00 2001 From: mexisme Date: Wed, 31 Jan 2024 21:32:59 +1300 Subject: [PATCH 09/10] Restore the "majorVersion" functionality --- microsoft/surface/common/kernel/linux-6.6.x/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-6.6.x/default.nix b/microsoft/surface/common/kernel/linux-6.6.x/default.nix index 6663138..c06ac8c 100644 --- a/microsoft/surface/common/kernel/linux-6.6.x/default.nix +++ b/microsoft/surface/common/kernel/linux-6.6.x/default.nix @@ -1,9 +1,9 @@ { config, lib, pkgs, ... }: let - inherit (lib) mkIf mkOption types; + inherit (lib) mkIf mkOption; - inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches; + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches isVersionOf versionsOfOption; cfg = config.microsoft-surface; @@ -20,10 +20,10 @@ let in { options.microsoft-surface.kernelVersion = mkOption { - type = types.enum [ version ]; + type = versionsOfOption version; }; - config = mkIf (cfg.kernelVersion == version) { + config = mkIf (isVersionOf cfg.kernelVersion version) { boot = { inherit kernelPackages; }; From 88712a124b9a15e8b487d9bec9847ba0aa876d2c Mon Sep 17 00:00:00 2001 From: mexisme Date: Wed, 31 Jan 2024 21:36:14 +1300 Subject: [PATCH 10/10] Pick a better name than "versionsOfOption" --- microsoft/surface/common/kernel/linux-6.6.x/default.nix | 4 ++-- microsoft/surface/common/kernel/linux-package.nix | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/microsoft/surface/common/kernel/linux-6.6.x/default.nix b/microsoft/surface/common/kernel/linux-6.6.x/default.nix index c06ac8c..82b0f0c 100644 --- a/microsoft/surface/common/kernel/linux-6.6.x/default.nix +++ b/microsoft/surface/common/kernel/linux-6.6.x/default.nix @@ -3,7 +3,7 @@ let inherit (lib) mkIf mkOption; - inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches isVersionOf versionsOfOption; + inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches isVersionOf versionsOfEnum; cfg = config.microsoft-surface; @@ -20,7 +20,7 @@ let in { options.microsoft-surface.kernelVersion = mkOption { - type = versionsOfOption version; + type = versionsOfEnum version; }; config = mkIf (isVersionOf cfg.kernelVersion version) { diff --git a/microsoft/surface/common/kernel/linux-package.nix b/microsoft/surface/common/kernel/linux-package.nix index 5cb64b1..45b4734 100644 --- a/microsoft/surface/common/kernel/linux-package.nix +++ b/microsoft/surface/common/kernel/linux-package.nix @@ -42,7 +42,7 @@ let # Provides a list of versions that can be used as an enum option for this full version: [ version (versions.majorMinor version) ]; - versionsOfOption = version: + versionsOfEnum = version: # Provide an enum option for versions of this kernel: types.enum (versionsOf version); @@ -51,5 +51,5 @@ let elem version (versionsOf version); in { - inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfOption; + inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfEnum; }