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:
commit
83e571bb29
|
@ -1,38 +1,29 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) mkIf mkOption types;
|
inherit (lib) mkIf mkOption;
|
||||||
inherit (pkgs) fetchurl;
|
|
||||||
|
|
||||||
inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage repos;
|
inherit (pkgs.callPackage ../linux-package.nix { }) linuxPackage surfacePatches isVersionOf versionsOfEnum;
|
||||||
|
|
||||||
cfg = config.microsoft-surface;
|
cfg = config.microsoft-surface;
|
||||||
|
|
||||||
version = "6.6.13";
|
version = "6.6.13";
|
||||||
majorVersion = "6.6";
|
kernelPatches = surfacePatches {
|
||||||
patchDir = repos.linux-surface + "/patches/${majorVersion}";
|
inherit version;
|
||||||
kernelPatches = pkgs.callPackage ./patches.nix {
|
patchFn = ./patches.nix;
|
||||||
inherit (lib) kernel;
|
|
||||||
inherit version patchDir;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
kernelPackages = linuxPackage {
|
kernelPackages = linuxPackage {
|
||||||
inherit version kernelPatches;
|
inherit version kernelPatches;
|
||||||
extraMeta.branch = majorVersion;
|
|
||||||
src = fetchurl {
|
|
||||||
url = "mirror://kernel/linux/kernel/v6.x/linux-${version}.tar.xz";
|
|
||||||
sha256 = "sha256-iLiefdQerU46seQRyLuNWSV1rPgVzx3zwNxX4uiCwLw=";
|
sha256 = "sha256-iLiefdQerU46seQRyLuNWSV1rPgVzx3zwNxX4uiCwLw=";
|
||||||
};
|
|
||||||
ignoreConfigErrors=true;
|
ignoreConfigErrors=true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options.microsoft-surface.kernelVersion = mkOption {
|
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 = {
|
boot = {
|
||||||
inherit kernelPackages;
|
inherit kernelPackages;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{ kernel,
|
{ lib,
|
||||||
patchDir,
|
kernel ? lib.kernel,
|
||||||
|
patchSrc,
|
||||||
version,
|
version,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
# Surface Aggregator Module
|
# Surface Aggregator Module
|
||||||
#
|
#
|
||||||
SURFACE_AGGREGATOR = module;
|
SURFACE_AGGREGATOR = module;
|
||||||
SURFACE_AGGREGATOR_ERROR_INJECTION = no;
|
# SURFACE_AGGREGATOR_ERROR_INJECTION is not set
|
||||||
SURFACE_AGGREGATOR_BUS = yes;
|
SURFACE_AGGREGATOR_BUS = yes;
|
||||||
SURFACE_AGGREGATOR_CDEV = module;
|
SURFACE_AGGREGATOR_CDEV = module;
|
||||||
SURFACE_AGGREGATOR_HUB = module;
|
SURFACE_AGGREGATOR_HUB = module;
|
||||||
|
@ -31,27 +32,23 @@
|
||||||
BATTERY_SURFACE = module;
|
BATTERY_SURFACE = module;
|
||||||
CHARGER_SURFACE = module;
|
CHARGER_SURFACE = module;
|
||||||
|
|
||||||
#
|
##
|
||||||
# Surface Hotplug
|
## Surface Hotplug
|
||||||
#
|
##
|
||||||
SURFACE_HOTPLUG = module;
|
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;
|
HID_ITHC = module;
|
||||||
|
|
||||||
#
|
##
|
||||||
# IPTS touchscreen
|
## Cameras: IPU3
|
||||||
#
|
##
|
||||||
# This only enables the user interface for IPTS data.
|
|
||||||
# For the touchscreen to work, you need to install iptsd.
|
|
||||||
#
|
|
||||||
MISC_IPTS = module;
|
|
||||||
|
|
||||||
#
|
|
||||||
# Cameras: IPU3
|
|
||||||
#
|
|
||||||
VIDEO_DW9719 = module;
|
VIDEO_DW9719 = module;
|
||||||
VIDEO_IPU3_IMGU = module;
|
VIDEO_IPU3_IMGU = module;
|
||||||
VIDEO_IPU3_CIO2 = module;
|
VIDEO_IPU3_CIO2 = module;
|
||||||
|
@ -59,23 +56,28 @@
|
||||||
INTEL_SKL_INT3472 = module;
|
INTEL_SKL_INT3472 = module;
|
||||||
REGULATOR_TPS68470 = module;
|
REGULATOR_TPS68470 = module;
|
||||||
COMMON_CLK_TPS68470 = module;
|
COMMON_CLK_TPS68470 = module;
|
||||||
COMMON_LEDS_TPS68470 = module;
|
LEDS_TPS68470 = module;
|
||||||
|
|
||||||
#
|
##
|
||||||
# Cameras: Sensor drivers
|
## Cameras: Sensor drivers
|
||||||
#
|
##
|
||||||
VIDEO_OV5693 = module;
|
VIDEO_OV5693 = module;
|
||||||
VIDEO_OV7251 = module;
|
VIDEO_OV7251 = module;
|
||||||
VIDEO_OV8865 = 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;
|
APDS9960 = module;
|
||||||
|
|
||||||
#
|
##
|
||||||
# Other Drivers
|
## Other Drivers
|
||||||
#
|
##
|
||||||
INPUT_SOC_BUTTON_ARRAY = module;
|
INPUT_SOC_BUTTON_ARRAY = module;
|
||||||
SURFACE_3_POWER_OPREGION = module;
|
SURFACE_3_POWER_OPREGION = module;
|
||||||
SURFACE_PRO3_BUTTON = module;
|
SURFACE_PRO3_BUTTON = module;
|
||||||
|
@ -85,58 +87,58 @@
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0001-surface3-oemb";
|
name = "ms-surface/0001-surface3-oemb";
|
||||||
patch = patchDir + "/0001-surface3-oemb.patch";
|
patch = patchSrc + "/0001-surface3-oemb.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0002-mwifiex";
|
name = "ms-surface/0002-mwifiex";
|
||||||
patch = patchDir + "/0002-mwifiex.patch";
|
patch = patchSrc + "/0002-mwifiex.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0003-ath10k";
|
name = "ms-surface/0003-ath10k";
|
||||||
patch = patchDir + "/0003-ath10k.patch";
|
patch = patchSrc + "/0003-ath10k.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0004-ipts";
|
name = "ms-surface/0004-ipts";
|
||||||
patch = patchDir + "/0004-ipts.patch";
|
patch = patchSrc + "/0004-ipts.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0005-ithc";
|
name = "ms-surface/0005-ithc";
|
||||||
patch = patchDir + "/0005-ithc.patch";
|
patch = patchSrc + "/0005-ithc.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0006-surface-sam";
|
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";
|
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";
|
name = "ms-surface/0008-surface-button";
|
||||||
patch = patchDir + "/0008-surface-button.patch";
|
patch = patchSrc + "/0008-surface-button.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0009-surface-typecover";
|
name = "ms-surface/0009-surface-typecover";
|
||||||
patch = patchDir + "/0009-surface-typecover.patch";
|
patch = patchSrc + "/0009-surface-typecover.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0010-surface-shutdown";
|
name = "ms-surface/0010-surface-shutdown";
|
||||||
patch = patchDir + "/0010-surface-shutdown.patch";
|
patch = patchSrc + "/0010-surface-shutdown.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0011-surface-gpe";
|
name = "ms-surface/0011-surface-gpe";
|
||||||
patch = patchDir + "/0011-surface-gpe.patch";
|
patch = patchSrc + "/0011-surface-gpe.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0012-cameras";
|
name = "ms-surface/0012-cameras";
|
||||||
patch = patchDir + "/0012-cameras.patch";
|
patch = patchSrc + "/0012-cameras.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0013-amd-gpio";
|
name = "ms-surface/0013-amd-gpio";
|
||||||
patch = patchDir + "/0013-amd-gpio.patch";
|
patch = patchSrc + "/0013-amd-gpio.patch";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
name = "ms-surface/0014-rtc";
|
name = "ms-surface/0014-rtc";
|
||||||
patch = patchDir + "/0014-rtc.patch";
|
patch = patchSrc + "/0014-rtc.patch";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,22 +1,55 @@
|
||||||
{ lib,
|
{ pkgs,
|
||||||
|
lib,
|
||||||
|
fetchurl,
|
||||||
buildLinux,
|
buildLinux,
|
||||||
callPackage,
|
|
||||||
linuxPackagesFor,
|
linuxPackagesFor,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib) recurseIntoAttrs;
|
inherit (builtins) elem;
|
||||||
|
inherit (lib) recurseIntoAttrs types versions;
|
||||||
|
|
||||||
in {
|
repos = pkgs.callPackage ../repos.nix {};
|
||||||
repos = callPackage ../repos.nix {};
|
|
||||||
|
|
||||||
linuxPackage =
|
linuxPackage =
|
||||||
{ version,
|
{ url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz",
|
||||||
modDirVersion ? version,
|
sha256 ? null,
|
||||||
|
src ? (fetchurl { inherit url sha256; }),
|
||||||
|
version,
|
||||||
|
modDirVersion ? (versions.pad 3 version),
|
||||||
|
kernelPatches ? [],
|
||||||
...
|
...
|
||||||
} @ args:
|
} @ args: let
|
||||||
let
|
inherit (builtins) removeAttrs;
|
||||||
buildLinux' = buildLinux (args // { inherit modDirVersion; });
|
|
||||||
linuxPackagesFor' = linuxPackagesFor buildLinux';
|
args' = {
|
||||||
in recurseIntoAttrs linuxPackagesFor';
|
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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue