2020-02-17 17:00:59 +04:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
|
|
|
|
with rec { inherit (config) device devices deviceSpecific; };
|
|
|
|
with deviceSpecific; {
|
|
|
|
|
|
|
|
hardware.sensor.iio.enable = (device == "HP-Laptop");
|
|
|
|
hardware.cpu.${devices.${device}.cpu.vendor}.updateMicrocode =
|
|
|
|
true; # Update microcode
|
|
|
|
|
|
|
|
hardware.enableRedistributableFirmware = true; # For some unfree drivers
|
|
|
|
|
|
|
|
hardware.opengl.enable = true;
|
|
|
|
hardware.opengl.driSupport = true;
|
|
|
|
hardware.opengl.driSupport32Bit = true; # For steam
|
2020-07-31 16:11:51 +04:00
|
|
|
hardware.opengl.package = pkgs.mesa_drivers;
|
2020-02-17 17:00:59 +04:00
|
|
|
|
|
|
|
hardware.bluetooth.enable = true;
|
2020-08-04 19:03:41 +04:00
|
|
|
hardware.bluetooth.package = pkgs.bluezFull.overrideAttrs (_: {
|
|
|
|
patches = [
|
|
|
|
(pkgs.fetchurl {
|
|
|
|
name = "volume-patch";
|
|
|
|
url = "https://marc.info/?l=linux-bluetooth&m=159446824521591&q=raw";
|
|
|
|
sha256 =
|
|
|
|
"448ce22b6fec2746d075390a898d1d08828c4008a6efcd8b98825ec60e5d1b81";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
2020-02-17 17:00:59 +04:00
|
|
|
|
|
|
|
services.throttled = {
|
|
|
|
enable = device == "T490s-Laptop";
|
|
|
|
extraConfig = ''
|
|
|
|
[GENERAL]
|
|
|
|
# Enable or disable the script execution
|
|
|
|
Enabled: True
|
|
|
|
# SYSFS path for checking if the system is running on AC power
|
|
|
|
Sysfs_Power_Path: /sys/class/power_supply/AC*/online
|
|
|
|
|
|
|
|
## Settings to apply while connected to Battery power
|
|
|
|
[BATTERY]
|
|
|
|
# Update the registers every this many seconds
|
|
|
|
Update_Rate_s: 30
|
|
|
|
# Max package power for time window #1
|
|
|
|
PL1_Tdp_W: 29
|
|
|
|
# Time window #1 duration
|
|
|
|
PL1_Duration_s: 28
|
|
|
|
# Max package power for time window #2
|
|
|
|
PL2_Tdp_W: 44
|
|
|
|
# Time window #2 duration
|
|
|
|
PL2_Duration_S: 0.002
|
|
|
|
# Max allowed temperature before throttling
|
|
|
|
Trip_Temp_C: 85
|
|
|
|
# Set cTDP to normal=0, down=1 or up=2 (EXPERIMENTAL)
|
|
|
|
cTDP: 1
|
|
|
|
|
|
|
|
## Settings to apply while connected to AC power
|
|
|
|
[AC]
|
|
|
|
# Update the registers every this many seconds
|
|
|
|
Update_Rate_s: 5
|
|
|
|
# Max package power for time window #1
|
|
|
|
PL1_Tdp_W: 44
|
|
|
|
# Time window #1 duration
|
|
|
|
PL1_Duration_s: 28
|
|
|
|
# Max package power for time window #2
|
|
|
|
PL2_Tdp_W: 44
|
|
|
|
# Time window #2 duration
|
|
|
|
PL2_Duration_S: 0.002
|
|
|
|
# Max allowed temperature before throttling
|
|
|
|
Trip_Temp_C: 95
|
|
|
|
# Set HWP energy performance hints to 'performance' on high load (EXPERIMENTAL)
|
|
|
|
HWP_Mode: True
|
|
|
|
# Set cTDP to normal=0, down=1 or up=2 (EXPERIMENTAL)
|
|
|
|
cTDP: 2
|
|
|
|
|
|
|
|
[UNDERVOLT]
|
|
|
|
# CPU core voltage offset (mV)
|
|
|
|
CORE: -200
|
|
|
|
# Integrated GPU voltage offset (mV)
|
|
|
|
GPU: -60
|
|
|
|
# CPU cache voltage offset (mV)
|
|
|
|
CACHE: -50
|
|
|
|
# System Agent voltage offset (mV)
|
|
|
|
UNCORE: 0
|
|
|
|
# Analog I/O voltage offset (mV)
|
|
|
|
ANALOGIO: 0
|
|
|
|
'';
|
|
|
|
};
|
2020-03-01 21:37:16 +04:00
|
|
|
boot.kernelModules = [ "ec_sys" ];
|
2020-02-17 17:00:59 +04:00
|
|
|
systemd.services.thinkpad_leds = {
|
|
|
|
enable = config.device == "T490s-Laptop";
|
|
|
|
description = "Set up thinkpad leds";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2020-08-04 19:03:41 +04:00
|
|
|
script = ''
|
|
|
|
echo -n -e "\x0e" | dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null'';
|
2020-02-17 17:00:59 +04:00
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
};
|
|
|
|
|
|
|
|
boot = {
|
|
|
|
loader = {
|
2020-08-14 13:20:05 +04:00
|
|
|
timeout = 1;
|
|
|
|
} // (if deviceSpecific.devInfo.legacy or false then { # Non-UEFI config
|
2020-02-17 17:00:59 +04:00
|
|
|
grub.enable = true;
|
|
|
|
grub.version = 2;
|
|
|
|
grub.useOSProber = true;
|
|
|
|
grub.device = "/dev/sda";
|
|
|
|
} else { # UEFI config
|
2020-08-14 13:20:05 +04:00
|
|
|
systemd-boot.enable = true;
|
2020-02-17 17:00:59 +04:00
|
|
|
});
|
2020-08-05 16:56:47 +04:00
|
|
|
kernelPackages = pkgs.linuxPackages_latest;
|
2020-02-17 17:00:59 +04:00
|
|
|
consoleLogLevel = 3;
|
2020-11-10 14:45:36 +04:00
|
|
|
extraModprobeConfig = ''
|
|
|
|
options ec_sys write_support=1
|
|
|
|
'' + lib.optionalString (device == "X2100-Laptop") ''
|
|
|
|
options iwlwifi bt_coex_active=0
|
|
|
|
'';
|
2020-02-17 17:00:59 +04:00
|
|
|
kernel.sysctl."vm.swappiness" = 0;
|
|
|
|
kernel.sysctl."kernel/sysrq" = 1;
|
|
|
|
kernelParams = [
|
|
|
|
"quiet"
|
|
|
|
"scsi_mod.use_blk_mq=1"
|
|
|
|
"modeset"
|
|
|
|
"nofb"
|
|
|
|
"rd.systemd.show_status=auto"
|
|
|
|
"rd.udev.log_priority=3"
|
|
|
|
"pti=off"
|
|
|
|
"spectre_v2=off"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.logind.lidSwitchExternalPower = "ignore";
|
|
|
|
|
|
|
|
services.logind.extraConfig = "HandlePowerKey=suspend";
|
|
|
|
sound.enable = true;
|
|
|
|
hardware.pulseaudio = {
|
|
|
|
enable = true;
|
2020-08-04 19:03:41 +04:00
|
|
|
package = pkgs.pulseaudioFull.overrideAttrs (oa: {
|
|
|
|
patches = [
|
|
|
|
(pkgs.fetchurl {
|
|
|
|
url =
|
|
|
|
"https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/239.diff";
|
|
|
|
sha256 = "07qrpqwvn9sr87z2kn1yaza5bs9ivywd7sl194zwphlq94xrlzdf";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
});
|
2020-02-17 17:00:59 +04:00
|
|
|
support32Bit = true;
|
|
|
|
extraConfig = ''
|
|
|
|
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1
|
2020-08-05 16:56:47 +04:00
|
|
|
load-module module-bluetooth-policy auto_switch=2
|
2020-02-17 17:00:59 +04:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|