mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2025-11-04 17:27:14 +08:00
chore: format repo using treefmt-nix and nixfmt-rfc-style
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkDefault mkOption types versions;
|
||||
inherit (lib)
|
||||
mkDefault
|
||||
mkOption
|
||||
types
|
||||
versions
|
||||
;
|
||||
|
||||
# Set the version and hash for the kernel sources
|
||||
srcVersion = with config.hardware.microsoft-surface;
|
||||
srcVersion =
|
||||
with config.hardware.microsoft-surface;
|
||||
if kernelVersion == "longterm" then
|
||||
"6.12.19"
|
||||
else if kernelVersion == "stable" then
|
||||
@@ -12,7 +23,8 @@ let
|
||||
else
|
||||
abort "Invalid kernel version: ${kernelVersion}";
|
||||
|
||||
srcHash = with config.hardware.microsoft-surface;
|
||||
srcHash =
|
||||
with config.hardware.microsoft-surface;
|
||||
if kernelVersion == "longterm" then
|
||||
"sha256-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
|
||||
else if kernelVersion == "stable" then
|
||||
@@ -21,15 +33,17 @@ let
|
||||
abort "Invalid kernel version: ${kernelVersion}";
|
||||
|
||||
# Set the version and hash for the linux-surface releases
|
||||
pkgVersion = with config.hardware.microsoft-surface;
|
||||
pkgVersion =
|
||||
with config.hardware.microsoft-surface;
|
||||
if kernelVersion == "longterm" then
|
||||
"6.12.7"
|
||||
else if kernelVersion == "stable" then
|
||||
"6.14.2"
|
||||
else
|
||||
abort "Invalid kernel version: ${kernelVersion}";
|
||||
|
||||
pkgHash = with config.hardware.microsoft-surface;
|
||||
|
||||
pkgHash =
|
||||
with config.hardware.microsoft-surface;
|
||||
if kernelVersion == "longterm" then
|
||||
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
|
||||
else if kernelVersion == "stable" then
|
||||
@@ -38,28 +52,46 @@ let
|
||||
abort "Invalid kernel version: ${kernelVersion}";
|
||||
|
||||
# Fetch the linux-surface package
|
||||
repos = pkgs.callPackage ({ fetchFromGitHub, rev, hash }: {
|
||||
linux-surface = fetchFromGitHub {
|
||||
owner = "linux-surface";
|
||||
repo = "linux-surface";
|
||||
rev = rev;
|
||||
hash = hash;
|
||||
};
|
||||
}) { hash = pkgHash; rev = "arch-${pkgVersion}-1"; };
|
||||
repos =
|
||||
pkgs.callPackage
|
||||
(
|
||||
{
|
||||
fetchFromGitHub,
|
||||
rev,
|
||||
hash,
|
||||
}:
|
||||
{
|
||||
linux-surface = fetchFromGitHub {
|
||||
owner = "linux-surface";
|
||||
repo = "linux-surface";
|
||||
rev = rev;
|
||||
hash = hash;
|
||||
};
|
||||
}
|
||||
)
|
||||
{
|
||||
hash = pkgHash;
|
||||
rev = "arch-${pkgVersion}-1";
|
||||
};
|
||||
|
||||
# Fetch and build the kernel package
|
||||
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; }) linuxPackage surfacePatches;
|
||||
inherit (pkgs.callPackage ./kernel/linux-package.nix { inherit repos; })
|
||||
linuxPackage
|
||||
surfacePatches
|
||||
;
|
||||
kernelPatches = surfacePatches {
|
||||
version = pkgVersion;
|
||||
patchFn = ./kernel/${versions.majorMinor pkgVersion}/patches.nix;
|
||||
};
|
||||
kernelPackages = linuxPackage {
|
||||
inherit kernelPatches; version = srcVersion;
|
||||
inherit kernelPatches;
|
||||
version = srcVersion;
|
||||
sha256 = srcHash;
|
||||
ignoreConfigErrors=true;
|
||||
ignoreConfigErrors = true;
|
||||
};
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.hardware.microsoft-surface.kernelVersion = mkOption {
|
||||
description = "Kernel Version to use (patched for MS Surface)";
|
||||
type = types.enum [
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{ lib,
|
||||
{
|
||||
lib,
|
||||
kernel ? lib.kernel,
|
||||
patchSrc,
|
||||
version,
|
||||
@@ -11,87 +12,87 @@
|
||||
extraStructuredConfig = with kernel; {
|
||||
STAGING_MEDIA = yes;
|
||||
|
||||
##
|
||||
## 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;
|
||||
##
|
||||
## 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_ACPI_NOTIFY = module;
|
||||
CONFIG_SURFACE_DTX = module;
|
||||
CONFIG_SURFACE_PLATFORM_PROFILE = module;
|
||||
|
||||
CONFIG_SURFACE_HID= module;
|
||||
CONFIG_SURFACE_KBD= module;
|
||||
CONFIG_SURFACE_HID = module;
|
||||
CONFIG_SURFACE_KBD = module;
|
||||
|
||||
CONFIG_BATTERY_SURFACE= module;
|
||||
CONFIG_CHARGER_SURFACE= module;
|
||||
CONFIG_BATTERY_SURFACE = module;
|
||||
CONFIG_CHARGER_SURFACE = module;
|
||||
|
||||
CONFIG_SENSORS_SURFACE_TEMP= module;
|
||||
CONFIG_SENSORS_SURFACE_FAN= module;
|
||||
CONFIG_SENSORS_SURFACE_TEMP = module;
|
||||
CONFIG_SENSORS_SURFACE_FAN = module;
|
||||
|
||||
##
|
||||
## Surface Hotplug
|
||||
##
|
||||
CONFIG_SURFACE_HOTPLUG= 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;
|
||||
##
|
||||
## 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: 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;
|
||||
##
|
||||
## 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
|
||||
##
|
||||
## 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;
|
||||
##
|
||||
## ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
|
||||
##
|
||||
CONFIG_APDS9960 = module;
|
||||
|
||||
##
|
||||
## Build-in UFS support (required for some Surface Go devices)
|
||||
##
|
||||
CONFIG_SCSI_UFSHCD= module;
|
||||
CONFIG_SCSI_UFSHCD_PCI= module;
|
||||
##
|
||||
## Build-in UFS support (required for some Surface Go devices)
|
||||
##
|
||||
CONFIG_SCSI_UFSHCD = module;
|
||||
CONFIG_SCSI_UFSHCD_PCI = 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;
|
||||
##
|
||||
## 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;
|
||||
};
|
||||
}
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{ lib,
|
||||
{
|
||||
lib,
|
||||
kernel ? lib.kernel,
|
||||
patchSrc,
|
||||
version,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{ pkgs,
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
fetchurl,
|
||||
buildLinux,
|
||||
@@ -11,44 +12,73 @@ let
|
||||
inherit (lib) recurseIntoAttrs types versions;
|
||||
|
||||
linuxPackage =
|
||||
{ url ? "mirror://kernel/linux/kernel/v${versions.major version}.x/linux-${version}.tar.xz",
|
||||
{
|
||||
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 ? [],
|
||||
kernelPatches ? [ ],
|
||||
...
|
||||
} @ args: let
|
||||
}@args:
|
||||
let
|
||||
inherit (builtins) removeAttrs;
|
||||
|
||||
args' = {
|
||||
inherit src version modDirVersion kernelPatches;
|
||||
} // removeAttrs args [ "url" "sha256" ];
|
||||
args' =
|
||||
{
|
||||
inherit
|
||||
src
|
||||
version
|
||||
modDirVersion
|
||||
kernelPatches
|
||||
;
|
||||
}
|
||||
// removeAttrs args [
|
||||
"url"
|
||||
"sha256"
|
||||
];
|
||||
linuxPackage = buildLinux args';
|
||||
linuxPackages' = recurseIntoAttrs (linuxPackagesFor linuxPackage);
|
||||
in linuxPackages';
|
||||
in
|
||||
linuxPackages';
|
||||
|
||||
surfacePatches =
|
||||
{ patchSrc ? (repos.linux-surface + "/patches/${versions.majorMinor version}"),
|
||||
{
|
||||
patchSrc ? (repos.linux-surface + "/patches/${versions.majorMinor version}"),
|
||||
version,
|
||||
patchFn,
|
||||
}: pkgs.callPackage patchFn {
|
||||
}:
|
||||
pkgs.callPackage patchFn {
|
||||
inherit (lib) kernel;
|
||||
inherit version patchSrc;
|
||||
};
|
||||
|
||||
versionsOf = version:
|
||||
versionsOf =
|
||||
version:
|
||||
# Provides a list of versions that can be used as an enum option for this full version:
|
||||
[ version (versions.majorMinor version) ];
|
||||
[
|
||||
version
|
||||
(versions.majorMinor version)
|
||||
];
|
||||
|
||||
versionsOfEnum = version:
|
||||
versionsOfEnum =
|
||||
version:
|
||||
# Provide an enum option for versions of this kernel:
|
||||
types.enum (versionsOf version);
|
||||
|
||||
isVersionOf = kernelVersion: version:
|
||||
isVersionOf =
|
||||
kernelVersion: version:
|
||||
# Test if the provided version is considered one of the list of versions from above:
|
||||
elem kernelVersion (versionsOf version);
|
||||
|
||||
in {
|
||||
inherit linuxPackage repos surfacePatches versionsOf isVersionOf versionsOfEnum;
|
||||
in
|
||||
{
|
||||
inherit
|
||||
linuxPackage
|
||||
repos
|
||||
surfacePatches
|
||||
versionsOf
|
||||
isVersionOf
|
||||
versionsOfEnum
|
||||
;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
let
|
||||
inherit (lib) mkDefault;
|
||||
in {
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
../common
|
||||
./firmware/ath10k
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{ stdenv, lib, pkgs, firmwareLinuxNonfree, ... }:
|
||||
{
|
||||
stdenv,
|
||||
lib,
|
||||
pkgs,
|
||||
firmwareLinuxNonfree,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
repos = pkgs.callPackage {
|
||||
@@ -8,14 +14,18 @@ let
|
||||
rev = "74e5409e699383d6ca2bc4da4a8433d16f3850b1";
|
||||
sha256 = "169vgvxpgad9anmchs22fj5qm6ahzjfdnwhd8pc280q705vx6pjk";
|
||||
};
|
||||
} {};
|
||||
} { };
|
||||
killernetworking_firmware = repos.surface-go-ath10k-firmware_backup + "/K1535_Debian";
|
||||
|
||||
in stdenv.mkDerivation {
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "microsoft-surface-go-firmware-linux-nonfree";
|
||||
inherit (firmwareLinuxNonfree) version;
|
||||
src = firmwareLinuxNonfree;
|
||||
phases = [ "unpackPhase" "installPhase" ];
|
||||
phases = [
|
||||
"unpackPhase"
|
||||
"installPhase"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
# Install the Surface Go Wifi firmware:
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib) mkDefault mkEnableOption mkIf;
|
||||
|
||||
cfg = config.hardware.microsoft-surface.firmware.surface-go-ath10k;
|
||||
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
hardware.microsoft-surface.firmware.surface-go-ath10k = {
|
||||
replace = mkEnableOption ''Use the "board.bin" firmware for ath10k-based WiFi on Surface Go.'';
|
||||
@@ -13,18 +19,21 @@ in {
|
||||
};
|
||||
|
||||
config = mkIf cfg.replace {
|
||||
warnings = [''A working version of the ath10k QCA6174 firmware has been added to the kernel.org linux-firmware
|
||||
repo, making this fix obsolete.
|
||||
See:
|
||||
- https://github.com/linux-surface/linux-surface/issues/542#issuecomment-976995453
|
||||
- https://github.com/linux-surface/linux-surface/wiki/Surface-Go#wi-fi-firmware
|
||||
warnings = [
|
||||
''
|
||||
A working version of the ath10k QCA6174 firmware has been added to the kernel.org linux-firmware
|
||||
repo, making this fix obsolete.
|
||||
See:
|
||||
- https://github.com/linux-surface/linux-surface/issues/542#issuecomment-976995453
|
||||
- https://github.com/linux-surface/linux-surface/wiki/Surface-Go#wi-fi-firmware
|
||||
|
||||
NOTE: This module option will probably be removed in the near future.
|
||||
''];
|
||||
NOTE: This module option will probably be removed in the near future.
|
||||
''
|
||||
];
|
||||
|
||||
hardware.enableAllFirmware = true;
|
||||
hardware.firmware = [
|
||||
(pkgs.callPackage ./ath10k-replace.nix {})
|
||||
(pkgs.callPackage ./ath10k-replace.nix { })
|
||||
];
|
||||
|
||||
boot.extraModprobeConfig = mkDefault ''
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
services.iptsd.enable = lib.mkDefault true;
|
||||
environment.systemPackages = [ pkgs.surface-control ];
|
||||
|
||||
|
||||
services.thermald = lib.mkDefault {
|
||||
enable = true;
|
||||
configFile = ./thermal-conf.xml;
|
||||
|
||||
Reference in New Issue
Block a user