mirror of
https://github.com/NixOS/nixos-hardware.git
synced 2025-11-03 16:57:14 +08:00
Add `hardware` to option name Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
90 lines
2.7 KiB
Nix
90 lines
2.7 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib) mkDefault mkOption types versions;
|
|
|
|
# Set the version and hash for the kernel sources
|
|
srcVersion = with config.hardware.microsoft-surface;
|
|
if kernelVersion == "longterm" then
|
|
"6.12.22"
|
|
else if kernelVersion == "stable" then
|
|
"6.14.2"
|
|
else
|
|
abort "Invalid kernel version: ${kernelVersion}";
|
|
|
|
srcHash = with config.hardware.microsoft-surface;
|
|
if kernelVersion == "longterm" then
|
|
"sha256-q0iACrSZhaeNIxiuisXyj9PhI+oXNX7yFJgQWlMzczY="
|
|
else if kernelVersion == "stable" then
|
|
"sha256-xcaCo1TqMZATk1elfTSnnlw3IhrOgjqTjhARa1d6Lhs="
|
|
else
|
|
abort "Invalid kernel version: ${kernelVersion}";
|
|
|
|
# Set the version and hash for the linux-surface releases
|
|
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;
|
|
if kernelVersion == "longterm" then
|
|
"sha256-Pv7O8D8ma+MPLhYP3HSGQki+Yczp8b7d63qMb6l4+mY="
|
|
else if kernelVersion == "stable" then
|
|
"sha256-Pzn+C52TtDcqDVepM5z2cVNCsnRDy0Wwn+FLwgsuicQ="
|
|
else
|
|
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"; };
|
|
|
|
# Fetch and build the kernel package
|
|
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;
|
|
sha256 = srcHash;
|
|
ignoreConfigErrors=true;
|
|
};
|
|
|
|
in {
|
|
options.hardware.microsoft-surface.kernelVersion = mkOption {
|
|
description = "Kernel Version to use (patched for MS Surface)";
|
|
type = types.enum [
|
|
"longterm"
|
|
"stable"
|
|
];
|
|
default = "longterm";
|
|
};
|
|
|
|
config = {
|
|
boot = {
|
|
inherit kernelPackages;
|
|
|
|
# Seems to be required to properly enable S0ix "Modern Standby":
|
|
kernelParams = mkDefault [ "mem_sleep_default=deep" ];
|
|
};
|
|
|
|
# NOTE: Check the README before enabling TLP:
|
|
services.tlp.enable = mkDefault false;
|
|
|
|
# Needed for wifi firmware, see https://github.com/NixOS/nixos-hardware/issues/364
|
|
hardware = {
|
|
enableRedistributableFirmware = mkDefault true;
|
|
sensor.iio.enable = mkDefault true;
|
|
};
|
|
};
|
|
}
|