-
-
Notifications
You must be signed in to change notification settings - Fork 729
/
Copy pathdefault.nix
89 lines (77 loc) · 2.7 KB
/
default.nix
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
88
89
{ 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.19"
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-1zvwV77ARDSxadG2FkGTb30Ml865I6KB8y413U3MZTE="
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;
};
};
}