This commit is contained in:
Peritia 2025-09-10 12:17:16 +02:00
parent fc0abdd4bb
commit aca73cdd0f
73 changed files with 3873 additions and 381 deletions

View file

@ -1,20 +0,0 @@
{ config, lib, pkgs, ... }:
let
cfg = config.nyx-module.system.Custom-Kernel;
in
{
options.nyx-module.system.Custom-Kernel = {
enable = lib.mkEnableOption "Enable Custom-Kernel (system) module";
package = lib.mkOption {
type = lib.types.package;
default = pkgs.Custom-Kernel;
description = "Package to install for Custom-Kernel.";
};
};
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
};
}

View file

@ -0,0 +1,87 @@
# Custom Kernel Module for Microsoft Surface Pro (Kaby Lake / i5-7300U)
#
# Requires:
# - inputs.nixos-hardware.nixosModules.microsoft-surface-pro-intel
#
# Notes:
# - Estimated kernel build time: ~4h30m
#
{ config, lib, pkgs, ... }:
let
cfg = config.nyx-module.hardware.Custom-Kernel.SurfacePro-KabyLake;
in
{
options.nyx-module.hardware.Custom-Kernel.SurfacePro-KabyLake = {
enable = lib.mkEnableOption "Enable Custom Surface Pro (Kaby Lake) kernel module";
kernelVersion = lib.mkOption {
type = lib.types.enum [ "stable" "longtime" ];
default = "stable";
description = "Choose which kernel version nixos-hardware will build for Surface Pro.";
};
};
config = lib.mkIf cfg.enable {
# Ensure nixos-hardware Surface Pro module is imported
assertions = [
{
assertion = config ? hardware.microsoft-surface;
message = ''
The module `nyx-module.hardware.Custom-Kernel.SurfacePro-KabyLake` requires
`inputs.nixos-hardware.nixosModules.microsoft-surface-pro-intel`
to be imported into your configuration.
'';
}
];
# Pick kernel version for Surface hardware support
hardware.microsoft-surface.kernelVersion = cfg.kernelVersion;
# boot.kernelPackages = pkgs.linuxPackages_6_6; # normally set by nixos-hardware
# Extra kernel modules
boot.kernelModules = [ "hid-microsoft" ];
# Initrd modules — required for Surface hardware to function
boot.initrd.kernelModules = [
# Surface Aggregator Module (SAM): buttons, sensors, keyboard
"surface_aggregator"
"surface_aggregator_registry"
"surface_aggregator_hub"
"surface_hid_core"
"surface_hid"
# Intel Low Power Subsystem (keyboard, I2C, etc.)
"intel_lpss"
"intel_lpss_pci"
"8250_dw"
];
# IPTSd not required — touchscreen and pen work via HID
services.iptsd.enable = lib.mkForce false;
# Optional: reduce display flickering
# boot.kernelParams = [ "i915.enable_psr=0" ];
# Optional: blacklist problematic modules
# boot.blacklistedKernelModules = [ "surface_gpe" ];
# Thermald for thermal management
services.thermald = {
enable = true;
configFile = ./thermal-conf.xml;
# Example: extra options if needed
# extraOptions = [
# "--adaptive"
# "--max-temperature=65"
# ];
};
# Optional: CPU power management tuning
# powerManagement.cpuFreqGovernor = "powersave"; # or "ondemand", "performance"
# Optional: disable Intel Turbo Boost if overheating persists
# systemd.tmpfiles.rules = [
# "w /sys/devices/system/cpu/intel_pstate/no_turbo - - - - 1"
# ];
};
}

View file

@ -2,6 +2,6 @@
{
imports = [
./Custom-Kernel.nix
./custom-kernel-surfacepro-kbl.nix
];
}

View file

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<ThermalConfiguration>
<Platform>
<Name>Surface Pro 7 Thermal Workaround</Name>
<ProductName>*</ProductName>
<Preference>QUIET</Preference>
<ThermalZones>
<ThermalZone>
<Type>cpu</Type>
<TripPoints>
<TripPoint>
<SensorType>x86_pkg_temp</SensorType>
<Temperature>65000</Temperature>
<type>passive</type>
<ControlType>PARALLEL</ControlType>
<CoolingDevice>
<index>1</index>
<type>rapl_controller</type>
<influence>100</influence>
<SamplingPeriod>10</SamplingPeriod>
</CoolingDevice>
<CoolingDevice>
<index>2</index>
<type>intel_pstate</type>
<influence>90</influence>
<SamplingPeriod>10</SamplingPeriod>
</CoolingDevice>
<CoolingDevice>
<index>3</index>
<type>intel_powerclamp</type>
<influence>80</influence>
<SamplingPeriod>10</SamplingPeriod>
</CoolingDevice>
</TripPoint>
</TripPoints>
</ThermalZone>
</ThermalZones>
</Platform>
</ThermalConfiguration>