From 5407ba7a5242062edeaf3dbcd42d533b9ff96023 Mon Sep 17 00:00:00 2001 From: Yegor Timoshenko Date: Sun, 24 Dec 2017 23:21:05 +0000 Subject: [PATCH] treewide: abstract away common configs into common/ --- acer/aspire/4810t/default.nix | 13 ++++++------- airis/n990/default.nix | 7 +++---- apple/macbook-pro/10-1/default.nix | 9 ++++++--- apple/macbook-pro/12-1/default.nix | 3 ++- apple/macbook-pro/default.nix | 7 +++++++ common/README.org | 2 ++ common/cpu/amd/default.nix | 3 +++ common/cpu/intel/default.nix | 4 ++++ common/pc/default.nix | 5 +++++ common/pc/hdd/default.nix | 7 +++++++ common/pc/laptop/default.nix | 11 +++++++++++ common/pc/laptop/hdd/default.nix | 8 ++++++++ common/pc/laptop/ssd | 1 + common/pc/ssd/default.nix | 7 +++++++ dell/xps/15-9550/default.nix | 8 ++++++-- lenovo/ideapad/default.nix | 3 +++ lenovo/ideapad/z510/default.nix | 5 ++++- lenovo/thinkpad/default.nix | 5 +++-- lenovo/thinkpad/t410/default.nix | 10 +++++----- lenovo/thinkpad/t440p/default.nix | 7 ++++--- lenovo/thinkpad/t460s/default.nix | 9 +++++---- lenovo/thinkpad/x140e/default.nix | 5 ++++- lenovo/thinkpad/x220/default.nix | 11 ++++++----- 23 files changed, 112 insertions(+), 38 deletions(-) create mode 100644 apple/macbook-pro/default.nix create mode 100644 common/README.org create mode 100644 common/cpu/amd/default.nix create mode 100644 common/cpu/intel/default.nix create mode 100644 common/pc/default.nix create mode 100644 common/pc/hdd/default.nix create mode 100644 common/pc/laptop/default.nix create mode 100644 common/pc/laptop/hdd/default.nix create mode 120000 common/pc/laptop/ssd create mode 100644 common/pc/ssd/default.nix create mode 100644 lenovo/ideapad/default.nix diff --git a/acer/aspire/4810t/default.nix b/acer/aspire/4810t/default.nix index ed0e923..f21d630 100644 --- a/acer/aspire/4810t/default.nix +++ b/acer/aspire/4810t/default.nix @@ -1,6 +1,11 @@ { lib, ... }: { + imports = [ + ../../../common/cpu/intel + ../../../common/pc/laptop + ]; + boot = { initrd.kernelModules = [ "ata_piix" ]; kernelParams = [ @@ -8,6 +13,7 @@ "acpi=on" "vga=0x317" "video=vesafb:ywrap" + # Important, to disable Kernel Mode Setting for the graphics card # This will allow backlight regulation "nomodeset" @@ -17,13 +23,6 @@ hardware.opengl.driSupport = false; services.xserver = { - enable = lib.mkDefault true; defaultDepth = lib.mkDefault 24; - videoDrivers = [ "intel" ]; - autorun = lib.mkDefault true; - synaptics = { - enable = lib.mkDefault true; - dev = "/dev/input/event8"; - }; }; } diff --git a/airis/n990/default.nix b/airis/n990/default.nix index 7c45d2a..ae06813 100644 --- a/airis/n990/default.nix +++ b/airis/n990/default.nix @@ -1,6 +1,8 @@ { lib, pkgs, ... }: { + imports = [ ../../common/pc/laptop ]; + boot = { initrd.kernelModules = [ "pata_via" ]; @@ -15,8 +17,5 @@ hardware.firmware = with pkgs; [ intel2200BGFirmware ]; - services.xserver = { - synaptics.enable = lib.mkDefault true; - videoDrivers = [ "unichrome" ]; - }; + services.xserver.videoDrivers = [ "openchrome" ]; } diff --git a/apple/macbook-pro/10-1/default.nix b/apple/macbook-pro/10-1/default.nix index 0fa8a2f..06e7486 100644 --- a/apple/macbook-pro/10-1/default.nix +++ b/apple/macbook-pro/10-1/default.nix @@ -1,16 +1,19 @@ { lib, pkgs, ... }: { - imports = [ ../../. ]; + imports = [ + ../. + ../../../common/pc/laptop/ssd + ]; + # TODO: boot loader boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; + # TODO: drop hardware.opengl.driSupport32Bit = true; services.xserver = { - libinput.enable = lib.mkDefault true; - # TODO: we should not enable unfree drivers # when there is an alternative (i.e. nouveau) videoDrivers = [ "nvidia" ]; diff --git a/apple/macbook-pro/12-1/default.nix b/apple/macbook-pro/12-1/default.nix index 63c36db..02c6f32 100644 --- a/apple/macbook-pro/12-1/default.nix +++ b/apple/macbook-pro/12-1/default.nix @@ -2,7 +2,8 @@ { imports = [ - ../../. + ../. + ../../../common/pc/laptop/ssd ]; diff --git a/apple/macbook-pro/default.nix b/apple/macbook-pro/default.nix new file mode 100644 index 0000000..4ced65a --- /dev/null +++ b/apple/macbook-pro/default.nix @@ -0,0 +1,7 @@ +{ + imports = [ + ../. + ../../common/cpu/intel + ../../common/pc/laptop + ]; +} diff --git a/common/README.org b/common/README.org new file mode 100644 index 0000000..3239e2f --- /dev/null +++ b/common/README.org @@ -0,0 +1,2 @@ +*NB!* This subtree is subject to change. Please don't import from here directly +for now, unless you're OK that things might break at any point in time. diff --git a/common/cpu/amd/default.nix b/common/cpu/amd/default.nix new file mode 100644 index 0000000..a8a36b2 --- /dev/null +++ b/common/cpu/amd/default.nix @@ -0,0 +1,3 @@ +{ + hardware.cpu.amd.updateMicrocode = true; +} diff --git a/common/cpu/intel/default.nix b/common/cpu/intel/default.nix new file mode 100644 index 0000000..e3ce919 --- /dev/null +++ b/common/cpu/intel/default.nix @@ -0,0 +1,4 @@ +{ + hardware.cpu.intel.updateMicrocode = true; + services.xserver.videoDrivers = [ "intel" ]; +} diff --git a/common/pc/default.nix b/common/pc/default.nix new file mode 100644 index 0000000..0b498ff --- /dev/null +++ b/common/pc/default.nix @@ -0,0 +1,5 @@ +{ lib, ... }: + +{ + services.xserver.libinput.enable = lib.mkDefault true; +} diff --git a/common/pc/hdd/default.nix b/common/pc/hdd/default.nix new file mode 100644 index 0000000..8cc5ada --- /dev/null +++ b/common/pc/hdd/default.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + boot.kernel.sysctl = { + "vm.swappiness" = lib.mkDefault 10; + }; +} diff --git a/common/pc/laptop/default.nix b/common/pc/laptop/default.nix new file mode 100644 index 0000000..305c160 --- /dev/null +++ b/common/pc/laptop/default.nix @@ -0,0 +1,11 @@ +{ lib, ... }: + +{ + imports = [ ../. ]; + + boot.kernel.sysctl = { + "vm.laptop_mode" = lib.mkDefault 5; + }; + + services.tlp.enable = lib.mkDefault true; +} diff --git a/common/pc/laptop/hdd/default.nix b/common/pc/laptop/hdd/default.nix new file mode 100644 index 0000000..63f29d4 --- /dev/null +++ b/common/pc/laptop/hdd/default.nix @@ -0,0 +1,8 @@ +{ lib, ... }: + +{ + imports = [ ../../hdd ]; + + # Hard disk protection if the laptop falls: + services.hdapsd.enable = lib.mkDefault true; +} diff --git a/common/pc/laptop/ssd b/common/pc/laptop/ssd new file mode 120000 index 0000000..e313834 --- /dev/null +++ b/common/pc/laptop/ssd @@ -0,0 +1 @@ +../ssd \ No newline at end of file diff --git a/common/pc/ssd/default.nix b/common/pc/ssd/default.nix new file mode 100644 index 0000000..af0b495 --- /dev/null +++ b/common/pc/ssd/default.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +{ + boot.kernel.sysctl = { + "vm.swappiness" = lib.mkDefault 1; + }; +} diff --git a/dell/xps/15-9550/default.nix b/dell/xps/15-9550/default.nix index e0bb700..90cfc6e 100644 --- a/dell/xps/15-9550/default.nix +++ b/dell/xps/15-9550/default.nix @@ -1,11 +1,15 @@ { lib, ... }: { + imports = [ + ../../../common/cpu/intel + ../../../common/pc/laptop + ]; + + # TODO: boot loader boot.loader.systemd-boot.enable = lib.mkDefault true; boot.loader.efi.canTouchEfiVariables = lib.mkDefault true; # To just use Intel integrated graphics with Intel's open source driver # hardware.nvidiaOptimus.disable = true; - - services.xserver.libinput.enable = lib.mkDefault true; } diff --git a/lenovo/ideapad/default.nix b/lenovo/ideapad/default.nix new file mode 100644 index 0000000..d774ba3 --- /dev/null +++ b/lenovo/ideapad/default.nix @@ -0,0 +1,3 @@ +{ + imports = [ ../../common/pc/laptop ]; +} diff --git a/lenovo/ideapad/z510/default.nix b/lenovo/ideapad/z510/default.nix index 4c8edf3..83f6568 100644 --- a/lenovo/ideapad/z510/default.nix +++ b/lenovo/ideapad/z510/default.nix @@ -1,7 +1,10 @@ { lib, ... }: { - hardware.cpu.intel.updateMicrocode = lib.mkDefault true; + imports = [ + ../. + ../../../common/cpu/intel + ]; # https://github.com/NixOS/nixpkgs/issues/18356 boot.blacklistedKernelModules = [ "nouveau" ]; diff --git a/lenovo/thinkpad/default.nix b/lenovo/thinkpad/default.nix index ae9804b..52d09bc 100644 --- a/lenovo/thinkpad/default.nix +++ b/lenovo/thinkpad/default.nix @@ -1,9 +1,10 @@ { lib, pkgs, ... }: { + imports = [ ../../common/pc/laptop ]; + hardware.trackpoint.enable = lib.mkDefault true; - services.tlp.enable = lib.mkDefault true; - services.xserver.libinput.enable = lib.mkDefault true; + services.thinkfan.enable = lib.mkDefault true; # Fingerprint reader: login and unlock with fingerprint (if you add one with `fprintd-enroll`) # services.fprintd.enable = true; diff --git a/lenovo/thinkpad/t410/default.nix b/lenovo/thinkpad/t410/default.nix index 568d9e6..737e91f 100644 --- a/lenovo/thinkpad/t410/default.nix +++ b/lenovo/thinkpad/t410/default.nix @@ -1,7 +1,11 @@ { config, lib, pkgs, ... }: { - imports = [ ../. ../tp-smapi.nix ]; + imports = [ + ../. + ../tp-smapi.nix + ../../../common/cpu/intel + ]; boot = { kernelParams = [ @@ -27,8 +31,4 @@ "sierra_net" "cdc_mbim" "cdc_ncm" "btusb" ]; }; - - hardware.cpu.intel.updateMicrocode = lib.mkDefault true; - - services.xserver.videoDrivers = [ "intel" ]; } diff --git a/lenovo/thinkpad/t440p/default.nix b/lenovo/thinkpad/t440p/default.nix index ddf6bd8..464c874 100644 --- a/lenovo/thinkpad/t440p/default.nix +++ b/lenovo/thinkpad/t440p/default.nix @@ -1,7 +1,10 @@ { config, lib, pkgs, ... }: { - imports = [ ../. ]; + imports = [ + ../. + ../../../common/cpu/intel + ]; boot = { extraModprobeConfig = lib.mkDefault '' @@ -9,6 +12,4 @@ ''; kernelModules = [ "tpm-rng" ]; }; - - services.xserver.videoDrivers = [ "intel" ]; } diff --git a/lenovo/thinkpad/t460s/default.nix b/lenovo/thinkpad/t460s/default.nix index ffe6ec3..41558a3 100644 --- a/lenovo/thinkpad/t460s/default.nix +++ b/lenovo/thinkpad/t460s/default.nix @@ -1,11 +1,12 @@ { config, lib, pkgs, ... }: { - imports = [ ../. ]; + imports = [ + ../../../common/cpu/intel + ../. + ]; - # Use the gummiboot efi boot loader. (From default generated configuration.nix) + # TODO: boot loader boot.loader.systemd-boot.enable = lib.mkDefault true; boot.loader.efi.canTouchEfiVariables = lib.mkDefault true; - - services.xserver.videoDrivers = [ "intel" ]; } diff --git a/lenovo/thinkpad/x140e/default.nix b/lenovo/thinkpad/x140e/default.nix index 81f67ad..c03410e 100644 --- a/lenovo/thinkpad/x140e/default.nix +++ b/lenovo/thinkpad/x140e/default.nix @@ -1,7 +1,10 @@ { config, lib, pkgs, ... }: { - imports = [ ../. ]; + imports = [ + ../. + ../../../common/cpu/amd + ]; boot.extraModprobeConfig = lib.mkDefault '' options snd_hda_intel enable=0,1 diff --git a/lenovo/thinkpad/x220/default.nix b/lenovo/thinkpad/x220/default.nix index efa67fc..e821f96 100644 --- a/lenovo/thinkpad/x220/default.nix +++ b/lenovo/thinkpad/x220/default.nix @@ -1,9 +1,10 @@ { config, lib, pkgs, ... }: { - imports = [ ../. ../tp-smapi.nix ]; - - # hard disk protection if the laptop falls - services.hdapsd.enable = lib.mkDefault true; - services.xserver.videoDrivers = [ "intel" ]; + imports = [ + ../. + ../../../common/cpu/intel + ../../../common/pc/laptop/hdd + ../tp-smapi.nix + ]; }