|
1 | 1 | { |
2 | 2 | config, |
3 | 3 | lib, |
4 | | - pkgs, |
5 | 4 | ... |
6 | 5 | }: |
7 | | -let |
8 | | - kernel_version_compatible = lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.10"; |
9 | | -in |
10 | 6 | { |
11 | 7 | options.hardware.framework.enableKmod = |
12 | | - (lib.mkEnableOption "Enable the community created Framework kernel module that allows interacting with the embedded controller from sysfs.") |
| 8 | + (lib.mkEnableOption "the community-created Framework kernel module that allows interacting with the embedded controller from sysfs.") |
13 | 9 | // { |
14 | 10 | # enable by default on NixOS >= 24.05 and kernel >= 6.10 |
15 | | - default = lib.and (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.05") kernel_version_compatible; |
16 | | - defaultText = "enabled by default on NixOS >= 24.05 and kernel >= 6.10"; |
| 11 | + default = lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.10"; |
| 12 | + defaultText = "enabled by default if kernel >= 6.10"; |
17 | 13 | }; |
18 | 14 |
|
19 | | - config.boot = lib.mkIf config.hardware.framework.enableKmod { |
20 | | - extraModulePackages = with config.boot.kernelPackages; [ |
21 | | - framework-laptop-kmod |
22 | | - ]; |
23 | | - |
24 | | - # https://github.com/DHowett/framework-laptop-kmod?tab=readme-ov-file#usage |
25 | | - kernelModules = [ |
26 | | - "cros_ec" |
27 | | - "cros_ec_lpcs" |
| 15 | + config = lib.mkIf config.hardware.framework.enableKmod { |
| 16 | + assertions = [ |
| 17 | + { |
| 18 | + assertion = lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.10"; |
| 19 | + message = "The framework laptop kernel module requires Linux 6.10 or above"; |
| 20 | + } |
28 | 21 | ]; |
29 | 22 |
|
30 | | - # add required patch if enabled on kernel <6.10 |
31 | | - kernelPatches = lib.mkIf (!kernel_version_compatible) [ |
32 | | - rec { |
33 | | - name = "platform/chrome: cros_ec_lpc: add support for AMD Framework Laptops"; |
34 | | - |
35 | | - version = "3"; |
36 | | - hash = "sha256-aQSyys8CMzlj9EdNhg8vtp76fg1qEwUVeJL0E+8w5HU="; |
37 | | - patch = |
38 | | - pkgs.runCommandLocal "patch-${msgid}" |
39 | | - { |
40 | | - nativeBuildInputs = with pkgs; [ |
41 | | - b4 |
42 | | - git |
43 | | - cacert |
44 | | - ]; |
45 | | - SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; |
| 23 | + boot = { |
| 24 | + extraModulePackages = with config.boot.kernelPackages; [ |
| 25 | + framework-laptop-kmod |
| 26 | + ]; |
46 | 27 |
|
47 | | - outputHash = hash; |
48 | | - } |
49 | | - '' |
50 | | - export HOME="$TMP" |
51 | | - PYTHONHASHSEED=0 ${pkgs.b4}/bin/b4 -n am -C -T -v ${version} -o- "${msgid}" > "$out" |
52 | | - ''; |
53 | | - } |
54 | | - ]; |
| 28 | + # https://github.com/DHowett/framework-laptop-kmod?tab=readme-ov-file#usage |
| 29 | + kernelModules = [ |
| 30 | + "cros_ec" |
| 31 | + "cros_ec_lpcs" |
| 32 | + ]; |
| 33 | + }; |
55 | 34 | }; |
56 | 35 | } |
0 commit comments