forked from NixOS/nixos-hardware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.nix
More file actions
87 lines (75 loc) · 2.06 KB
/
default.nix
File metadata and controls
87 lines (75 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
config,
lib,
pkgs,
...
}:
let
inherit (builtins)
attrNames
;
inherit (lib)
mkDefault
mkOption
types
versions
;
supportedKernels =
let
lts-kernel = {
version = "6.18.13";
hash = "sha256-7Sw8Vf045oNsCU/ONW8lZ/lRYTC3M1SimFeWA2jFaH8=";
};
in
{
"longterm" = lts-kernel;
"stable" = lts-kernel;
};
# Set the version and hash for the kernel sources
srcVersion = supportedKernels.${config.hardware.microsoft-surface.kernelVersion}.version;
srcHash = supportedKernels.${config.hardware.microsoft-surface.kernelVersion}.hash;
# Fetch the latest linux-surface patches
linux-surface = pkgs.fetchFromGitHub {
owner = "linux-surface";
repo = "linux-surface";
rev = "829ceccd5970ed3621a30d9fcfb2fe6584a3aab7";
hash = "sha256-H/qjP2dR5yjUvHUhI6pis+EHHSRXxc4+c4zir/pDA54=";
};
# Fetch and build the kernel
inherit (pkgs.callPackage ./kernel/linux-package.nix { })
linuxPackage
surfacePatches
;
kernelPatches = surfacePatches {
version = srcVersion;
patchFn = ./kernel/${versions.majorMinor srcVersion}/patches.nix;
patchSrc = linux-surface + "/patches/${versions.majorMinor srcVersion}";
};
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 (attrNames supportedKernels);
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;
};
};
}