From 92a701653963111efdf1f6de383b5cf48474d803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Thu, 18 Jul 2019 22:17:36 +0100 Subject: [PATCH] Extract out more nix config files --- nixos/boxes/foureighty.nix | 36 ++--------------------- nixos/common-hardware.nix | 26 +++++++++++++++++ nixos/common.nix | 37 +++++------------------- nixos/quirks/thinkpad-cpu-throttling.nix | 34 ++++++++++++++++++++++ 4 files changed, 70 insertions(+), 63 deletions(-) create mode 100644 nixos/common-hardware.nix create mode 100644 nixos/quirks/thinkpad-cpu-throttling.nix diff --git a/nixos/boxes/foureighty.nix b/nixos/boxes/foureighty.nix index 2ec25e11..494717b9 100644 --- a/nixos/boxes/foureighty.nix +++ b/nixos/boxes/foureighty.nix @@ -1,4 +1,3 @@ - { config, pkgs, ... }: { @@ -17,6 +16,7 @@ "i915.enable_fbc=1" "i915.enable_psr=2" "i915.enable_rc6=7" + "mds=full" ]; initrd.luks.devices = [ { @@ -36,43 +36,11 @@ time.timeZone = "Europe/London"; hardware.trackpoint.enable = true; - services.fprintd.enable = true; - systemd.services.cpu-throttling = { - enable = true; - description = "CPU Throttling Fix"; - documentation = [ - "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues" - ]; - path = [ pkgs.msr-tools ]; - script = "wrmsr -a 0x1a2 0x3000000"; - serviceConfig = { - Type = "oneshot"; - }; - wantedBy = [ - "timers.target" - ]; - }; - - systemd.timers.cpu-throttling = { - enable = true; - description = "CPU Throttling Fix"; - documentation = [ - "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues" - ]; - timerConfig = { - OnActiveSec = 60; - OnUnitActiveSec = 60; - Unit = "cpu-throttling.service"; - }; - wantedBy = [ - "timers.target" - ]; - }; - imports = [ /etc/nixos/hardware-configuration.nix + ../quirks/thinkpad-cpu-throttling.nix ../boot.nix ../common.nix ../gfx-intel.nix diff --git a/nixos/common-hardware.nix b/nixos/common-hardware.nix new file mode 100644 index 00000000..ae86af3a --- /dev/null +++ b/nixos/common-hardware.nix @@ -0,0 +1,26 @@ +{ config, pkgs, lib, ... }: +{ + sound.enable = true; + networking.networkmanager.enable = true; + hardware.enableRedistributableFirmware = true; + hardware.cpu.intel.updateMicrocode = true; + hardware.pulseaudio = { + enable = true; + package = pkgs.pulseaudioFull; + extraModules = [ pkgs.pulseaudio-modules-bt ]; + }; + hardware.u2f.enable = true; + hardware.brightnessctl.enable = true; + hardware.sane.enable = true; + hardware.bluetooth = { + enable = true; + package = pkgs.bluezFull; + extraConfig = '' + [General] + Enable=Source,Sink,Media,Socket + ''; + }; + powerManagement.cpuFreqGovernor = (lib.mkForce null); + + hardware.nvidiaOptimus.disable = true; +} diff --git a/nixos/common.nix b/nixos/common.nix index 1501dfe1..8353228e 100644 --- a/nixos/common.nix +++ b/nixos/common.nix @@ -1,4 +1,4 @@ -{ config, pkgs, lib , ... }: +{ config, pkgs, ... }: let unstableTarball = fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz; @@ -10,6 +10,7 @@ in ./vscode.nix ./syncthing.nix ./gsconnect.nix + ./common-hardware.nix ]; nixpkgs.config = { @@ -51,10 +52,16 @@ in tlp.enable = true; fstrim.enable = true; + physlock = { + enable = true; + allowAnyUser = true; + }; + printing = { enable = true; drivers = [ pkgs.epson-escpr pkgs.samsung-unified-linux-driver pkgs.splix ]; }; + avahi = { enable = true; nssmdns = true; @@ -83,35 +90,8 @@ in }; }; - security.pam.services.gdm.enableGnomeKeyring = true; - fonts.fonts = [ pkgs.powerline-fonts ]; - sound.enable = true; - networking.networkmanager.enable = true; - hardware.enableRedistributableFirmware = true; - hardware.cpu.intel.updateMicrocode = true; - hardware.pulseaudio = { - enable = true; - package = pkgs.pulseaudioFull; - }; - hardware.u2f.enable = true; - hardware.brightnessctl.enable = true; - hardware.sane.enable = true; - hardware.bluetooth = { - enable = true; - package = pkgs.bluezFull; - powerOnBoot = true; - }; - powerManagement.cpuFreqGovernor = (lib.mkForce null); - - hardware.nvidiaOptimus.disable = true; - - services.physlock = { - enable = true; - allowAnyUser = true; - }; - nix.gc.automatic = true; nix.autoOptimiseStore = true; nix.optimise.automatic = true; @@ -120,4 +100,3 @@ in system.autoUpgrade.enable = true; system.stateVersion = "19.03"; } - diff --git a/nixos/quirks/thinkpad-cpu-throttling.nix b/nixos/quirks/thinkpad-cpu-throttling.nix new file mode 100644 index 00000000..e8a91252 --- /dev/null +++ b/nixos/quirks/thinkpad-cpu-throttling.nix @@ -0,0 +1,34 @@ +{ config, pkgs, ... }: +{ + systemd.services.cpu-throttling = { + enable = true; + description = "CPU Throttling Fix"; + documentation = [ + "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues" + ]; + path = [ pkgs.msr-tools ]; + script = "wrmsr -a 0x1a2 0x3000000"; + serviceConfig = { + Type = "oneshot"; + }; + wantedBy = [ + "timers.target" + ]; + }; + + systemd.timers.cpu-throttling = { + enable = true; + description = "CPU Throttling Fix"; + documentation = [ + "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues" + ]; + timerConfig = { + OnActiveSec = 60; + OnUnitActiveSec = 60; + Unit = "cpu-throttling.service"; + }; + wantedBy = [ + "timers.target" + ]; + }; +}