From 0f2c55992677e78d5d2908d0648e410ef9b27436 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 23 Sep 2017 13:59:19 +0200 Subject: Organise modules into folders --- modules/hardware/adb.nix | 9 +++++ modules/hardware/audio.nix | 12 ++++++ modules/hardware/bare-metal.nix | 18 +++++++++ modules/hardware/colemak.nix | 17 ++++++++ modules/hardware/connman.nix | 14 +++++++ modules/hardware/grub2.nix | 13 ++++++ modules/hardware/hidpi.nix | 9 +++++ modules/hardware/intel-gpu.nix | 14 +++++++ modules/hardware/laptop.nix | 77 ++++++++++++++++++++++++++++++++++++ modules/hardware/network-manager.nix | 10 +++++ modules/hardware/nitrokey.nix | 26 ++++++++++++ modules/hardware/printing.nix | 8 ++++ modules/hardware/synaptics.nix | 27 +++++++++++++ modules/hardware/systemd-boot.nix | 10 +++++ modules/hardware/thinkpad.nix | 36 +++++++++++++++++ modules/hardware/trackball.nix | 13 ++++++ 16 files changed, 313 insertions(+) create mode 100644 modules/hardware/adb.nix create mode 100644 modules/hardware/audio.nix create mode 100644 modules/hardware/bare-metal.nix create mode 100644 modules/hardware/colemak.nix create mode 100644 modules/hardware/connman.nix create mode 100644 modules/hardware/grub2.nix create mode 100644 modules/hardware/hidpi.nix create mode 100644 modules/hardware/intel-gpu.nix create mode 100644 modules/hardware/laptop.nix create mode 100644 modules/hardware/network-manager.nix create mode 100644 modules/hardware/nitrokey.nix create mode 100644 modules/hardware/printing.nix create mode 100644 modules/hardware/synaptics.nix create mode 100644 modules/hardware/systemd-boot.nix create mode 100644 modules/hardware/thinkpad.nix create mode 100644 modules/hardware/trackball.nix (limited to 'modules/hardware') diff --git a/modules/hardware/adb.nix b/modules/hardware/adb.nix new file mode 100644 index 00000000..8b511f55 --- /dev/null +++ b/modules/hardware/adb.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ programs.adb.enable = true; + users.groups.adbusers = {}; + + services.udev = { + packages = [ pkgs.android-udev-rules ]; + }; +} diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix new file mode 100644 index 00000000..f5046574 --- /dev/null +++ b/modules/hardware/audio.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: + +{ hardware.pulseaudio = { + enable = true; + support32Bit = true; + }; + + environment.systemPackages = with pkgs; [ + pamixer + pavucontrol + ]; +} diff --git a/modules/hardware/bare-metal.nix b/modules/hardware/bare-metal.nix new file mode 100644 index 00000000..b5e0fc7b --- /dev/null +++ b/modules/hardware/bare-metal.nix @@ -0,0 +1,18 @@ +{ config, pkgs, ... }: + +{ environment.systemPackages = with pkgs; [ + fuse_exfat + cryptsetup + dmidecode + hdparm + pciutils + usbutils + ]; + + boot.kernelPackages = pkgs.linuxPackages_4_12; + + boot.tmpOnTmpfs = true; + + fileSystems."/".options = [ "noatime" "nodiratime" ]; + fileSystems."/home".options = [ "noatime" "nodiratime" ]; +} diff --git a/modules/hardware/colemak.nix b/modules/hardware/colemak.nix new file mode 100644 index 00000000..3b1c0582 --- /dev/null +++ b/modules/hardware/colemak.nix @@ -0,0 +1,17 @@ +{ config, pkgs, ... }: + +{ i18n.consoleKeyMap = "colemak/en-latin9"; + services.kmscon = { + extraConfig = '' + xkb-model=pc104 + xkb-layout=us + xkb-variant=colemak + xkb-options="altwin:prtsc_rwin" + ''; + }; + services.xserver = { + layout = "us,us"; + xkbVariant = "colemak,"; + xkbOptions = "grp:shifts_toggle,altwin:prtsc_rwin"; + }; +} diff --git a/modules/hardware/connman.nix b/modules/hardware/connman.nix new file mode 100644 index 00000000..0361f9cb --- /dev/null +++ b/modules/hardware/connman.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ networking.connman = { + enable = true; + enableVPN = false; + }; + networking.wireless.enable = true; + + environment.systemPackages = with pkgs; [ + cmst + connman-notify + connman_dmenu + ]; +} diff --git a/modules/hardware/grub2.nix b/modules/hardware/grub2.nix new file mode 100644 index 00000000..70e86e71 --- /dev/null +++ b/modules/hardware/grub2.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ boot.loader = { + grub = { + enable = true; + splashImage = null; + version = 2; + device = "nodev"; + efiSupport = true; + }; + efi.canTouchEfiVariables = true; + }; +} diff --git a/modules/hardware/hidpi.nix b/modules/hardware/hidpi.nix new file mode 100644 index 00000000..1f4644c5 --- /dev/null +++ b/modules/hardware/hidpi.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ i18n = { + consoleFont = "ter-v24b"; + consolePackages = with pkgs; [ + terminus_font + ]; + }; +} diff --git a/modules/hardware/intel-gpu.nix b/modules/hardware/intel-gpu.nix new file mode 100644 index 00000000..b44ddadf --- /dev/null +++ b/modules/hardware/intel-gpu.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ hardware.opengl.extraPackages = with pkgs; [ + vaapiIntel + ]; + + boot.earlyVconsoleSetup = true; + boot.initrd.kernelModules = [ + "i915" + ]; + boot.kernelModules = [ + "i915" + ]; +} diff --git a/modules/hardware/laptop.nix b/modules/hardware/laptop.nix new file mode 100644 index 00000000..55dcbd17 --- /dev/null +++ b/modules/hardware/laptop.nix @@ -0,0 +1,77 @@ +{ config, pkgs, lib, ... }: + +{ boot.kernelModules = [ "coretemp" ]; + boot.extraModulePackages = with config.boot.kernelPackages; [ + x86_energy_perf_policy + ]; + + hardware = { + bluetooth.enable = true; + }; + + environment.systemPackages = with pkgs; [ + powerstat + powertop + + arandr + autorandr + disper + ]; + + # powerManagement.resumeCommands = '' + # AUTORANDR="autorandr -c" + + # detect_display() + # { + # for X in /tmp/.X11-unix/X*; do + # D="''${X##/tmp/.X11-unix/X}" + # user=$(who | awk -vD="$D" '$5 ~ "\\(:"D"\\)$" {print $1}') + # if [ x"$user" != x"" ]; then + # export DISPLAY=":$D" + # /bin/su -c "''${AUTORANDR}" "$user" + # fi + # done + # } + + # case "$1" in + # thaw|resume) + # detect_display + # ;; + # esac + # ''; + + programs.light.enable = true; + + services.logind.extraConfig = '' + IdleAction=suspend + IdleActionSec=600 + ''; + + services.physlock.enable = false; + + services.tlp = { + enable = true; + extraConfig = '' + CPU_SCALING_GOVERNOR_ON_BAT=powersave + ''; + }; + + services.udev.extraRules = '' + # ACTION=="change", SUBSYSTEM=="drm", ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/alan/.Xauthority", RUN+="${pkgs.autorandr}/bin/autorandr -c" + ''; + + services.xserver = { + libinput = { + enable = lib.mkDefault true; + naturalScrolling = true; + disableWhileTyping = true; + }; + }; + + systemd.services.nixos-upgrade.unitConfig.ConditionACPower = true; + systemd.services.nix-gc.unitConfig.ConditionACPower = true; + + imports = [ + ../user-interface.nix + ]; +} diff --git a/modules/hardware/network-manager.nix b/modules/hardware/network-manager.nix new file mode 100644 index 00000000..b85b8f41 --- /dev/null +++ b/modules/hardware/network-manager.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ networking.networkmanager = { + enable = true; + }; + + environment.systemPackages = with pkgs; [ + networkmanagerapplet + ]; +} diff --git a/modules/hardware/nitrokey.nix b/modules/hardware/nitrokey.nix new file mode 100644 index 00000000..ac85e352 --- /dev/null +++ b/modules/hardware/nitrokey.nix @@ -0,0 +1,26 @@ +{ config, nixpkgs, ... }: + +let + pkgsUnstable = import {}; + # pkgsUnstable = pkgs; +in +{ programs.ssh.startAgent = false; + + services.pcscd.enable = true; + + services.tor = { + enable = true; + client = { + enable = true; + socksListenAddress = "9050 IPv6Traffic"; + }; + torsocks = { + enable = true; + }; + }; + + environment.systemPackages = [ + pkgsUnstable.gnupg + pkgsUnstable.nitrokey-app + ]; +} diff --git a/modules/hardware/printing.nix b/modules/hardware/printing.nix new file mode 100644 index 00000000..beba72ed --- /dev/null +++ b/modules/hardware/printing.nix @@ -0,0 +1,8 @@ +{ config, pkgs, lib, ... }: + +{ services.printing.enable = true; + + imports = [ + ../services/zeroconf.nix + ]; +} diff --git a/modules/hardware/synaptics.nix b/modules/hardware/synaptics.nix new file mode 100644 index 00000000..9f075cce --- /dev/null +++ b/modules/hardware/synaptics.nix @@ -0,0 +1,27 @@ +{ config, pkgs, ... }: + +{ services.xserver = { + libinput.enable = false; + synaptics = { + enable = true; + + accelFactor = "0.04"; + + minSpeed = "0.3"; + maxSpeed = "0.6"; + + palmDetect = true; + palmMinWidth = 5; + palmMinZ = 20; + + twoFingerScroll = true; + vertTwoFingerScroll = true; + horizTwoFingerScroll = true; + additionalOptions = '' + Option "RBCornerButton" "3" + Option "VertScrollDelta" "-111" + Option "HorizScrollDelta" "-111" + ''; + }; + }; +} diff --git a/modules/hardware/systemd-boot.nix b/modules/hardware/systemd-boot.nix new file mode 100644 index 00000000..80e79fdc --- /dev/null +++ b/modules/hardware/systemd-boot.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ boot.loader.systemd-boot = { + enable = true; + editor = false; # Don't allow modification + }; + boot.loader.efi.canTouchEfiVariables = true; + boot.vesa = true; + boot.earlyVconsoleSetup = true; +} diff --git a/modules/hardware/thinkpad.nix b/modules/hardware/thinkpad.nix new file mode 100644 index 00000000..1e97f06c --- /dev/null +++ b/modules/hardware/thinkpad.nix @@ -0,0 +1,36 @@ +{ config, pkgs, ... }: + +{ boot.kernelModules = [ "tp_smapi" ]; + boot.blacklistedKernelModules = [ "thinkpad_ec" ]; + boot.extraModulePackages = with config.boot.kernelPackages; [ + # acpi_call + tp_smapi + ]; + + hardware.trackpoint = { + enable = true; + emulateWheel = true; + }; + + services.thinkfan = { + enable = true; + sensor = "/sys/class/thermal/thermal_zone0/temp"; + }; + + services.tlp = { + enable = true; + extraConfig = '' + # Newer Thinkpads have a battery firmware + # it conflicts with TLP if stop thresholds are set + START_CHARGE_THRESH_BAT0=70 + STOP_CHARGE_THRESH_BAT0=80 + START_CHARGE_THRESH_BAT1=70 + STOP_CHARGE_THRESH_BAT1=80 + ''; + }; + + imports = [ + ./bare-metal.nix + ./laptop.nix + ]; +} diff --git a/modules/hardware/trackball.nix b/modules/hardware/trackball.nix new file mode 100644 index 00000000..9aa5abc0 --- /dev/null +++ b/modules/hardware/trackball.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ services.xserver.config = '' + Section "InputClass" + Identifier "Trackball (No Acceleration)" + MatchIsPointer "yes" + MatchIsTouchpad "no" + MatchProduct "Trackball" + Option "AccelerationProfile" "-1" + Option "AccelerationScheme" "none" + EndSection + ''; +} -- cgit 1.4.1