From ae18b6af0fa2a244b2e5932b40885ae4b46abff7 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 3 Sep 2017 23:25:33 +0200 Subject: [PATCH 01/11] Initialize general.nix; merge defaults into all ThinkPad configurations --- lenovo/general.nix | 10 ++++++++++ lenovo/t410.nix | 2 ++ lenovo/t440p.nix | 2 ++ lenovo/t460s.nix | 11 +---------- lenovo/x140e.nix | 8 ++------ lenovo/x220i-tablet.nix | 6 ++---- lenovo/x250.nix | 3 ++- lenovo/z510.nix | 3 +++ 8 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 lenovo/general.nix diff --git a/lenovo/general.nix b/lenovo/general.nix new file mode 100644 index 0000000..51d5060 --- /dev/null +++ b/lenovo/general.nix @@ -0,0 +1,10 @@ +{ lib, ... }: + +with lib; + +{ + hardware.trackpoint = mkDefault { + enable = true; + emulateWheel = true; + }; +} diff --git a/lenovo/t410.nix b/lenovo/t410.nix index 912ae66..56e49cb 100644 --- a/lenovo/t410.nix +++ b/lenovo/t410.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { + imports = [ ./general.nix ]; + boot = { kernelParams = [ # Kernel GPU Savings Options (NOTE i915 chipset only) diff --git a/lenovo/t440p.nix b/lenovo/t440p.nix index 47f5f66..af4e764 100644 --- a/lenovo/t440p.nix +++ b/lenovo/t440p.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { + imports = [ ./general.nix ]; + boot = { extraModprobeConfig = '' options bbswitch use_acpi_to_detect_card_state=1 diff --git a/lenovo/t460s.nix b/lenovo/t460s.nix index 4aaed14..da79956 100644 --- a/lenovo/t460s.nix +++ b/lenovo/t460s.nix @@ -3,6 +3,7 @@ { imports = [ ../lib/kernel-version.nix + ./general.nix ]; ## BEGIN from generated hardware-configuration @@ -45,15 +46,5 @@ services.xserver = { libinput.enable = true; synaptics.enable = false; - - config = '' - Section "InputClass" - Identifier "Enable libinput for TrackPoint" - MatchIsPointer "on" - Driver "libinput" - Option "ScrollMethod" "button" - Option "ScrollButton" "8" - EndSection - ''; }; } diff --git a/lenovo/x140e.nix b/lenovo/x140e.nix index f825f44..897d473 100644 --- a/lenovo/x140e.nix +++ b/lenovo/x140e.nix @@ -1,6 +1,8 @@ { config, lib, pkgs, ... }: { + imports = [ ./general.nix ]; + boot = { # wireless kernelModules = [ "kvm-amd" "wl" ]; @@ -15,12 +17,6 @@ # video card services.xserver.videoDrivers = ["ati"]; - # trackpad (touchpad disabled) - hardware.trackpoint = { - enable = true; - emulateWheel = true; - }; - # media keys sound.enableMediaKeys = true; } diff --git a/lenovo/x220i-tablet.nix b/lenovo/x220i-tablet.nix index 7ea8d73..700c87c 100644 --- a/lenovo/x220i-tablet.nix +++ b/lenovo/x220i-tablet.nix @@ -1,6 +1,8 @@ { config, pkgs, ... }: { + imports = [ ./general.nix ]; + # TPM chip countains a RNG security.rngd.enable = true; @@ -15,10 +17,6 @@ # hard disk protection if the laptop falls services.hdapsd.enable = true; - # trackpoint support (touchpad disabled in this config) - hardware.trackpoint.enable = true; - hardware.trackpoint.emulateWheel = true; - # alternatively, touchpad with two-finger scrolling #services.xserver.libinput.enable = true; diff --git a/lenovo/x250.nix b/lenovo/x250.nix index 40d1fb1..52a4426 100644 --- a/lenovo/x250.nix +++ b/lenovo/x250.nix @@ -1,9 +1,10 @@ { config, pkgs, ... }: { + imports = [ ./general.nix ]; + # modesetting driver leads to freezes with newer kernel at the moment (> 4.4) services.xserver.videoDrivers = [ "intel" ]; services.xserver.libinput.enable = true; - hardware.trackpoint.emulateWheel = true; } diff --git a/lenovo/z510.nix b/lenovo/z510.nix index f1f5416..4c45cac 100644 --- a/lenovo/z510.nix +++ b/lenovo/z510.nix @@ -1,3 +1,6 @@ +# NOTE: this doesn't inherit from the `general.nix` +# as z510 is not a ThinkPad + { config, pkgs, ... }: { hardware.cpu.intel.updateMicrocode = true; From 7d130c00612ec0ed80586285e030dc9e0e8513ff Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 3 Sep 2017 23:27:33 +0200 Subject: [PATCH 02/11] `hardware.enableAllFirmware = true;` for intel iwlwifi --- lenovo/general.nix | 2 ++ lenovo/t460s.nix | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lenovo/general.nix b/lenovo/general.nix index 51d5060..c64566b 100644 --- a/lenovo/general.nix +++ b/lenovo/general.nix @@ -7,4 +7,6 @@ with lib; enable = true; emulateWheel = true; }; + + hardware.enableAllFirmware = true; } diff --git a/lenovo/t460s.nix b/lenovo/t460s.nix index da79956..9d68cfd 100644 --- a/lenovo/t460s.nix +++ b/lenovo/t460s.nix @@ -27,9 +27,6 @@ { version = "4.6"; msg = "Suspending the T460s by closing the lid when running on battery causes the machine to freeze up entirely."; } ]; - # For the wifi (intel iwlwifi) - hardware.enableAllFirmware = true; - # For the screen. I don't know what to do with this information, but # the hiDPI support is far from perfect (as of July 2016): From a2e55b93adf6d19d6d7f6cc831224997de84d7dc Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 3 Sep 2017 23:28:34 +0200 Subject: [PATCH 03/11] `services.tlp.enable = true;` for power management --- lenovo/general.nix | 1 + lenovo/x220i-tablet.nix | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lenovo/general.nix b/lenovo/general.nix index c64566b..0afdaaf 100644 --- a/lenovo/general.nix +++ b/lenovo/general.nix @@ -9,4 +9,5 @@ with lib; }; hardware.enableAllFirmware = true; + services.tlp.enable = true; } diff --git a/lenovo/x220i-tablet.nix b/lenovo/x220i-tablet.nix index 700c87c..068baa8 100644 --- a/lenovo/x220i-tablet.nix +++ b/lenovo/x220i-tablet.nix @@ -11,9 +11,6 @@ extraModulePackages = [ config.boot.kernelPackages.tp_smapi ]; }; - # TLP Linux Advanced Power Management - services.tlp.enable = true; - # hard disk protection if the laptop falls services.hdapsd.enable = true; From ed46b99315a10254dfa4753423b45c1782465647 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 3 Sep 2017 23:31:08 +0200 Subject: [PATCH 04/11] Use `libinput` as touchpad driver The recommended driver is libinput, furthermore the packaging of synaptics is officially deprecated in NixOS: https://github.com/NixOS/nixpkgs/commit/9d2777a5a5f861a727d09c3ecdeffd8c72c143b7 --- lenovo/general.nix | 5 +++++ lenovo/t460s.nix | 7 ------- lenovo/x220i-tablet.nix | 3 --- lenovo/x250.nix | 2 -- 4 files changed, 5 insertions(+), 12 deletions(-) diff --git a/lenovo/general.nix b/lenovo/general.nix index 0afdaaf..f539cc2 100644 --- a/lenovo/general.nix +++ b/lenovo/general.nix @@ -10,4 +10,9 @@ with lib; hardware.enableAllFirmware = true; services.tlp.enable = true; + + services.xserver = { + synaptics.enable = false; + libinput.enable = true; + }; } diff --git a/lenovo/t460s.nix b/lenovo/t460s.nix index 9d68cfd..a274b37 100644 --- a/lenovo/t460s.nix +++ b/lenovo/t460s.nix @@ -37,11 +37,4 @@ # Aspect Ratio: 16 × 9 (1.78:1) # Pixel Count: 3,686,400 # Megapixels: 3.69MP - - # Use libinput to let the physical middle button be used to scroll - # with the trackpoint - services.xserver = { - libinput.enable = true; - synaptics.enable = false; - }; } diff --git a/lenovo/x220i-tablet.nix b/lenovo/x220i-tablet.nix index 068baa8..3c729ba 100644 --- a/lenovo/x220i-tablet.nix +++ b/lenovo/x220i-tablet.nix @@ -14,9 +14,6 @@ # hard disk protection if the laptop falls services.hdapsd.enable = true; - # alternatively, touchpad with two-finger scrolling - #services.xserver.libinput.enable = true; - # enable volume control buttons sound.enableMediaKeys = true; diff --git a/lenovo/x250.nix b/lenovo/x250.nix index 52a4426..8ab1aa5 100644 --- a/lenovo/x250.nix +++ b/lenovo/x250.nix @@ -5,6 +5,4 @@ # modesetting driver leads to freezes with newer kernel at the moment (> 4.4) services.xserver.videoDrivers = [ "intel" ]; - - services.xserver.libinput.enable = true; } From d977cf26de7f1b0ffe3cff39b1c2801aac0e695b Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 3 Sep 2017 23:34:57 +0200 Subject: [PATCH 05/11] Segregate `lenovo/` subdir into `thinkpad` and `ideapad` directories There are several significant differences between ThinkPads and the other Lenovo models, so this structure must be more precise --- lenovo/{ => ideapad}/z510.nix | 0 lenovo/{ => thinkpad}/general.nix | 0 lenovo/{ => thinkpad}/t410.nix | 0 lenovo/{ => thinkpad}/t440p.nix | 0 lenovo/{ => thinkpad}/t460s.nix | 0 lenovo/{ => thinkpad}/x140e.nix | 0 lenovo/{ => thinkpad}/x220i-tablet.nix | 0 lenovo/{ => thinkpad}/x250.nix | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename lenovo/{ => ideapad}/z510.nix (100%) rename lenovo/{ => thinkpad}/general.nix (100%) rename lenovo/{ => thinkpad}/t410.nix (100%) rename lenovo/{ => thinkpad}/t440p.nix (100%) rename lenovo/{ => thinkpad}/t460s.nix (100%) rename lenovo/{ => thinkpad}/x140e.nix (100%) rename lenovo/{ => thinkpad}/x220i-tablet.nix (100%) rename lenovo/{ => thinkpad}/x250.nix (100%) diff --git a/lenovo/z510.nix b/lenovo/ideapad/z510.nix similarity index 100% rename from lenovo/z510.nix rename to lenovo/ideapad/z510.nix diff --git a/lenovo/general.nix b/lenovo/thinkpad/general.nix similarity index 100% rename from lenovo/general.nix rename to lenovo/thinkpad/general.nix diff --git a/lenovo/t410.nix b/lenovo/thinkpad/t410.nix similarity index 100% rename from lenovo/t410.nix rename to lenovo/thinkpad/t410.nix diff --git a/lenovo/t440p.nix b/lenovo/thinkpad/t440p.nix similarity index 100% rename from lenovo/t440p.nix rename to lenovo/thinkpad/t440p.nix diff --git a/lenovo/t460s.nix b/lenovo/thinkpad/t460s.nix similarity index 100% rename from lenovo/t460s.nix rename to lenovo/thinkpad/t460s.nix diff --git a/lenovo/x140e.nix b/lenovo/thinkpad/x140e.nix similarity index 100% rename from lenovo/x140e.nix rename to lenovo/thinkpad/x140e.nix diff --git a/lenovo/x220i-tablet.nix b/lenovo/thinkpad/x220i-tablet.nix similarity index 100% rename from lenovo/x220i-tablet.nix rename to lenovo/thinkpad/x220i-tablet.nix diff --git a/lenovo/x250.nix b/lenovo/thinkpad/x250.nix similarity index 100% rename from lenovo/x250.nix rename to lenovo/thinkpad/x250.nix From 5340bd39d174c55b1d5fc17d410cebb54ad6bd5b Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 6 Sep 2017 09:45:30 +0200 Subject: [PATCH 06/11] Don't enable non-dedistributable firmware by default --- lenovo/thinkpad/general.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lenovo/thinkpad/general.nix b/lenovo/thinkpad/general.nix index f539cc2..628e5ab 100644 --- a/lenovo/thinkpad/general.nix +++ b/lenovo/thinkpad/general.nix @@ -8,7 +8,7 @@ with lib; emulateWheel = true; }; - hardware.enableAllFirmware = true; + hardware.enableRedistributableFirmware = mkDefault true; services.tlp.enable = true; services.xserver = { From 0116223524393e40518c62e5616bf918d9338bd7 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 6 Sep 2017 09:49:11 +0200 Subject: [PATCH 07/11] Add `pkgs.acpi` to gather battery status information --- lenovo/thinkpad/general.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lenovo/thinkpad/general.nix b/lenovo/thinkpad/general.nix index 628e5ab..7b6e8eb 100644 --- a/lenovo/thinkpad/general.nix +++ b/lenovo/thinkpad/general.nix @@ -1,4 +1,4 @@ -{ lib, ... }: +{ pkgs, lib, ... }: with lib; @@ -15,4 +15,6 @@ with lib; synaptics.enable = false; libinput.enable = true; }; + + environment.systemPackages = [ pkgs.acpi ]; } From 356ebeaaf77f2019c0c5d6756ec8ded4cabd1353 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 6 Sep 2017 10:01:01 +0200 Subject: [PATCH 08/11] Introduce `general-intel.nix` for defaults with Intel CPU The x1xx series relies on a AMD CPU, but all other (currently supported) ThinkPads use an Intel CPU, so `general-intel.nix` is responsible for all Intel defaults. --- lenovo/thinkpad/general-intel.nix | 6 ++++++ lenovo/thinkpad/t410.nix | 2 +- lenovo/thinkpad/t440p.nix | 4 ++-- lenovo/thinkpad/t460s.nix | 2 +- lenovo/thinkpad/x220i-tablet.nix | 2 +- lenovo/thinkpad/x250.nix | 5 +---- 6 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 lenovo/thinkpad/general-intel.nix diff --git a/lenovo/thinkpad/general-intel.nix b/lenovo/thinkpad/general-intel.nix new file mode 100644 index 0000000..5aeec18 --- /dev/null +++ b/lenovo/thinkpad/general-intel.nix @@ -0,0 +1,6 @@ +{ ... }: + +{ + boot.kernelModules = mkDefault [ "kvm-intel" ]; + services.xserver.videoDrivers = [ "intel" ]; +} diff --git a/lenovo/thinkpad/t410.nix b/lenovo/thinkpad/t410.nix index 56e49cb..5737cc6 100644 --- a/lenovo/thinkpad/t410.nix +++ b/lenovo/thinkpad/t410.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: { - imports = [ ./general.nix ]; + imports = [ ./general-intel.nix ]; boot = { kernelParams = [ diff --git a/lenovo/thinkpad/t440p.nix b/lenovo/thinkpad/t440p.nix index af4e764..4d96bbb 100644 --- a/lenovo/thinkpad/t440p.nix +++ b/lenovo/thinkpad/t440p.nix @@ -1,12 +1,12 @@ { config, pkgs, ... }: { - imports = [ ./general.nix ]; + imports = [ ./general-intel.nix ]; boot = { extraModprobeConfig = '' options bbswitch use_acpi_to_detect_card_state=1 ''; - kernelModules = [ "kvm-intel" "tpm-rng" ]; + kernelModules = [ "tpm-rng" ]; }; } diff --git a/lenovo/thinkpad/t460s.nix b/lenovo/thinkpad/t460s.nix index a274b37..d6f2ba3 100644 --- a/lenovo/thinkpad/t460s.nix +++ b/lenovo/thinkpad/t460s.nix @@ -3,7 +3,7 @@ { imports = [ ../lib/kernel-version.nix - ./general.nix + ./general-intel.nix ]; ## BEGIN from generated hardware-configuration diff --git a/lenovo/thinkpad/x220i-tablet.nix b/lenovo/thinkpad/x220i-tablet.nix index 3c729ba..65a4a3d 100644 --- a/lenovo/thinkpad/x220i-tablet.nix +++ b/lenovo/thinkpad/x220i-tablet.nix @@ -1,7 +1,7 @@ { config, pkgs, ... }: { - imports = [ ./general.nix ]; + imports = [ ./general-intel.nix ]; # TPM chip countains a RNG security.rngd.enable = true; diff --git a/lenovo/thinkpad/x250.nix b/lenovo/thinkpad/x250.nix index 8ab1aa5..200327f 100644 --- a/lenovo/thinkpad/x250.nix +++ b/lenovo/thinkpad/x250.nix @@ -1,8 +1,5 @@ { config, pkgs, ... }: { - imports = [ ./general.nix ]; - - # modesetting driver leads to freezes with newer kernel at the moment (> 4.4) - services.xserver.videoDrivers = [ "intel" ]; + imports = [ ./general-intel.nix ]; } From 348f0466b524987d9310d7ecf5df5fac0dc372be Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 21 Sep 2017 00:09:48 +0200 Subject: [PATCH 09/11] x250 can be configured using all defaults --- lenovo/thinkpad/x250.nix | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 lenovo/thinkpad/x250.nix diff --git a/lenovo/thinkpad/x250.nix b/lenovo/thinkpad/x250.nix deleted file mode 100644 index 200327f..0000000 --- a/lenovo/thinkpad/x250.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ ./general-intel.nix ]; -} From 12f5a724cec2b7fcd69ac2d1e7320a24c2d434aa Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 21 Sep 2017 00:11:34 +0200 Subject: [PATCH 10/11] `sound.enableMediaKeys` can be used on all ThinkPads --- lenovo/thinkpad/general.nix | 2 ++ lenovo/thinkpad/x140e.nix | 3 --- lenovo/thinkpad/x220i-tablet.nix | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lenovo/thinkpad/general.nix b/lenovo/thinkpad/general.nix index 7b6e8eb..0c0e925 100644 --- a/lenovo/thinkpad/general.nix +++ b/lenovo/thinkpad/general.nix @@ -17,4 +17,6 @@ with lib; }; environment.systemPackages = [ pkgs.acpi ]; + + sound.enableMediaKeys = true; } diff --git a/lenovo/thinkpad/x140e.nix b/lenovo/thinkpad/x140e.nix index 897d473..df1f7f3 100644 --- a/lenovo/thinkpad/x140e.nix +++ b/lenovo/thinkpad/x140e.nix @@ -16,7 +16,4 @@ # video card services.xserver.videoDrivers = ["ati"]; - - # media keys - sound.enableMediaKeys = true; } diff --git a/lenovo/thinkpad/x220i-tablet.nix b/lenovo/thinkpad/x220i-tablet.nix index 65a4a3d..c87df3f 100644 --- a/lenovo/thinkpad/x220i-tablet.nix +++ b/lenovo/thinkpad/x220i-tablet.nix @@ -14,9 +14,6 @@ # hard disk protection if the laptop falls services.hdapsd.enable = true; - # enable volume control buttons - sound.enableMediaKeys = true; - # fingerprint reader: login and unlock with fingerprint (if you add one with `fprintd-enroll`) #services.fprintd.enable = true; #security.pam.services.login.fprintAuth = true; From a0e35e53069bd0026165adaf0d6e1a1b8542384e Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 19 Oct 2017 13:56:33 +0200 Subject: [PATCH 11/11] Use `mkDefault` to avoid make override easier --- lenovo/thinkpad/general.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lenovo/thinkpad/general.nix b/lenovo/thinkpad/general.nix index 0c0e925..71db23a 100644 --- a/lenovo/thinkpad/general.nix +++ b/lenovo/thinkpad/general.nix @@ -11,12 +11,12 @@ with lib; hardware.enableRedistributableFirmware = mkDefault true; services.tlp.enable = true; - services.xserver = { + services.xserver = mkDefault { synaptics.enable = false; libinput.enable = true; }; environment.systemPackages = [ pkgs.acpi ]; - sound.enableMediaKeys = true; + sound.enableMediaKeys = mkDefault true; }