From acada9b054f442538c265bab0d724a1a73c87346 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Mon, 15 Sep 2025 12:52:50 -0600 Subject: [PATCH] trivionomicon: thinkpad: move thinkpad config into laptop module --- trivionomicon/modules/laptop/default.nix | 1 + trivionomicon/modules/laptop/options.nix | 10 +++++++ trivionomicon/modules/laptop/sys.nix | 5 ++++ trivionomicon/modules/laptop/thinkpad.nix | 33 ++++++++++++++++++++++ trivionomicon/modules/thinkpad/default.nix | 11 -------- trivionomicon/modules/thinkpad/sys.nix | 30 -------------------- 6 files changed, 49 insertions(+), 41 deletions(-) create mode 100644 trivionomicon/modules/laptop/options.nix create mode 100644 trivionomicon/modules/laptop/thinkpad.nix delete mode 100644 trivionomicon/modules/thinkpad/default.nix delete mode 100644 trivionomicon/modules/thinkpad/sys.nix diff --git a/trivionomicon/modules/laptop/default.nix b/trivionomicon/modules/laptop/default.nix index b908d47..7c9abd6 100644 --- a/trivionomicon/modules/laptop/default.nix +++ b/trivionomicon/modules/laptop/default.nix @@ -7,4 +7,5 @@ doctrine.lib.mkModule { inherit config; name = "laptop"; sys = ./sys.nix; + options = ./options.nix; } diff --git a/trivionomicon/modules/laptop/options.nix b/trivionomicon/modules/laptop/options.nix new file mode 100644 index 0000000..75209a0 --- /dev/null +++ b/trivionomicon/modules/laptop/options.nix @@ -0,0 +1,10 @@ +{lib, ...}: +with lib.types; { + sys = { + thinkpad = lib.mkOption { + type = boolean; + default = false; + description = "set to true if your laptop is a thinkpad"; + }; + }; +} diff --git a/trivionomicon/modules/laptop/sys.nix b/trivionomicon/modules/laptop/sys.nix index 252f49c..5bbcddd 100644 --- a/trivionomicon/modules/laptop/sys.nix +++ b/trivionomicon/modules/laptop/sys.nix @@ -2,10 +2,15 @@ config, lib, pkgs, + cfg, ... }: { services = { tlp.enable = lib.mkDefault true; upower.enable = lib.mkDefault true; }; + + imports = [ + ./thinkpad.nix + ]; } diff --git a/trivionomicon/modules/laptop/thinkpad.nix b/trivionomicon/modules/laptop/thinkpad.nix new file mode 100644 index 0000000..07ab809 --- /dev/null +++ b/trivionomicon/modules/laptop/thinkpad.nix @@ -0,0 +1,33 @@ +{ + config, + pkgs, + lib, + cfg, + ... +}: { + config = lib.mkIf cfg.thinkpad { + # For suspending to RAM to work, set Config -> Power -> Sleep State to "Linux" in EFI. + # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Suspend_issues + # Fingerprint sensor requires a firmware-update to work. + + boot = { + extraModulePackages = with config.boot.kernelPackages; [acpi_call]; + extraModprobeConfig = "options iwlwifi 11n_disable=1 wd_disable=1"; + + # acpi_call makes tlp work for newer thinkpads + kernelModules = ["acpi_call"]; + + # Force use of the thinkpad_acpi driver for backlight control. + # This allows the backlight save/load systemd service to work. + kernelParams = ["acpi_backlight=native"]; + }; + + hardware.firmware = [pkgs.sof-firmware]; + + services = { + fprintd.enable = lib.mkDefault true; + thinkfan.enable = lib.mkDefault true; + tp-auto-kbbl.enable = lib.mkDefault true; + }; + }; +} diff --git a/trivionomicon/modules/thinkpad/default.nix b/trivionomicon/modules/thinkpad/default.nix deleted file mode 100644 index e210947..0000000 --- a/trivionomicon/modules/thinkpad/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ - config, - doctrine, - ... -}: -doctrine.lib.mkModule { - inherit config; - name = "thinkpad"; - sys = ./sys.nix; - requires = ["laptop"]; -} diff --git a/trivionomicon/modules/thinkpad/sys.nix b/trivionomicon/modules/thinkpad/sys.nix deleted file mode 100644 index bc96146..0000000 --- a/trivionomicon/modules/thinkpad/sys.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: { - # For suspending to RAM to work, set Config -> Power -> Sleep State to "Linux" in EFI. - # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Suspend_issues - # Fingerprint sensor requires a firmware-update to work. - - boot = { - extraModulePackages = with config.boot.kernelPackages; [acpi_call]; - extraModprobeConfig = "options iwlwifi 11n_disable=1 wd_disable=1"; - - # acpi_call makes tlp work for newer thinkpads - kernelModules = ["acpi_call"]; - - # Force use of the thinkpad_acpi driver for backlight control. - # This allows the backlight save/load systemd service to work. - kernelParams = ["acpi_backlight=native"]; - }; - - hardware.firmware = [pkgs.sof-firmware]; - - services = { - fprintd.enable = lib.mkDefault true; - thinkfan.enable = lib.mkDefault true; - tp-auto-kbbl.enable = lib.mkDefault true; - }; -}