1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-12-18 15:49:45 +01:00

Merge pull request #851 from mexisme/microsoft/surface/kernel-6.6

Rewrite the microsoft/surface `linuxPackage` function to make it simpler to use
This commit is contained in:
Jörg Thalheim 2024-02-02 07:49:42 +07:00 committed by GitHub
commit 83e571bb29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 99 additions and 73 deletions

View file

@ -1,38 +1,29 @@
{ config, lib, pkgs, ... }:
let
inherit (lib) mkIf mkOption types;
inherit (pkgs) fetchurl;
inherit (lib) mkIf mkOption;
inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage repos;
inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches isVersionOf versionsOfEnum;
cfg = config.microsoft-surface;
version = "6.6.13";
majorVersion = "6.6";
patchDir = repos.linux-surface + "/patches/${majorVersion}";
kernelPatches = pkgs.callPackage ./patches.nix {
inherit (lib) kernel;
inherit version patchDir;
kernelPatches = surfacePatches {
inherit version;
patchFn = ./patches.nix;
};
kernelPackages = linuxPackage {
inherit version kernelPatches;
extraMeta.branch = majorVersion;
src = fetchurl {
url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
sha256 = "sha256-iLiefdQerU46seQRyLuNWSV1rPgVzx3zwNxX4uiCwLw=";
};
ignoreConfigErrors=true;
};
in {
options.microsoft-surface.kernelVersion = mkOption {
type = types.enum [ version majorVersion ];
type = versionsOfEnum version;
};
config = mkIf (cfg.kernelVersion == version || cfg.kernelVersion == majorVersion) {
config = mkIf (isVersionOf cfg.kernelVersion version) {
boot = {
inherit kernelPackages;
};

View file

@ -1,5 +1,6 @@
{ kernel,
patchDir,
{ lib,
kernel ? lib.kernel,
patchSrc,
version,
}:
@ -14,7 +15,7 @@
# Surface Aggregator Module
#
SURFACE_AGGREGATOR = module;
SURFACE_AGGREGATOR_ERROR_INJECTION = no;
# SURFACE_AGGREGATOR_ERROR_INJECTION is not set
SURFACE_AGGREGATOR_BUS = yes;
SURFACE_AGGREGATOR_CDEV = module;
SURFACE_AGGREGATOR_HUB = module;
@ -31,27 +32,23 @@
BATTERY_SURFACE = module;
CHARGER_SURFACE = module;
#
# Surface Hotplug
#
##
## Surface Hotplug
##
SURFACE_HOTPLUG = module;
#
# Intel Touch Host Controller
#
##
## IPTS and ITHC touchscreen
##
## This only enables the user interface for IPTS/ITHC data.
## For the touchscreen to work, you need to install iptsd.
##
HID_IPTS = module;
HID_ITHC = module;
#
# IPTS touchscreen
#
# This only enables the user interface for IPTS data.
# For the touchscreen to work, you need to install iptsd.
#
MISC_IPTS = module;
#
# Cameras: IPU3
#
##
## Cameras: IPU3
##
VIDEO_DW9719 = module;
VIDEO_IPU3_IMGU = module;
VIDEO_IPU3_CIO2 = module;
@ -59,23 +56,28 @@
INTEL_SKL_INT3472 = module;
REGULATOR_TPS68470 = module;
COMMON_CLK_TPS68470 = module;
COMMON_LEDS_TPS68470 = module;
LEDS_TPS68470 = module;
#
# Cameras: Sensor drivers
#
##
## Cameras: Sensor drivers
##
VIDEO_OV5693 = module;
VIDEO_OV7251 = module;
VIDEO_OV8865 = module;
#
# ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
#
##
## Surface 3: atomisp causes problems (see issue #1095). Disable it for now.
##
# INTEL_ATOMISP is not set
##
## ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
##
APDS9960 = module;
#
# Other Drivers
#
##
## Other Drivers
##
INPUT_SOC_BUTTON_ARRAY = module;
SURFACE_3_POWER_OPREGION = module;
SURFACE_PRO3_BUTTON = module;
@ -85,58 +87,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";
}
]

View file

@ -1,22 +1,55 @@
{ lib,
{ pkgs,
lib,
fetchurl,
buildLinux,
callPackage,
linuxPackagesFor,
}:
let
inherit (lib) recurseIntoAttrs;
inherit (builtins) elem;
inherit (lib) recurseIntoAttrs types versions;
in {
repos = callPackage ../repos.nix {};
repos = pkgs.callPackage ../repos.nix {};
linuxPackage =
{ version,
modDirVersion ? version,
{ 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
buildLinux' = buildLinux (args // { inherit modDirVersion; });
linuxPackagesFor' = linuxPackagesFor buildLinux';
in recurseIntoAttrs linuxPackagesFor';
} @ 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.majorMinor version}"),
version,
patchFn,
}: pkgs.callPackage patchFn {
inherit (lib) kernel;
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) ];
versionsOfEnum = 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 versionsOf isVersionOf versionsOfEnum;
}