summary refs log tree commit diff stats
path: root/modules/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'modules/hardware')
-rw-r--r--modules/hardware/adb.nix9
-rw-r--r--modules/hardware/audio.nix12
-rw-r--r--modules/hardware/bare-metal.nix18
-rw-r--r--modules/hardware/colemak.nix17
-rw-r--r--modules/hardware/connman.nix14
-rw-r--r--modules/hardware/grub2.nix13
-rw-r--r--modules/hardware/hidpi.nix9
-rw-r--r--modules/hardware/intel-gpu.nix14
-rw-r--r--modules/hardware/laptop.nix77
-rw-r--r--modules/hardware/network-manager.nix10
-rw-r--r--modules/hardware/nitrokey.nix26
-rw-r--r--modules/hardware/printing.nix8
-rw-r--r--modules/hardware/synaptics.nix27
-rw-r--r--modules/hardware/systemd-boot.nix10
-rw-r--r--modules/hardware/thinkpad.nix36
-rw-r--r--modules/hardware/trackball.nix13
16 files changed, 313 insertions, 0 deletions
diff --git a/modules/hardware/adb.nix b/modules/hardware/adb.nix
new file mode 100644
index 0000000..8b511f5
--- /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 0000000..f504657
--- /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 0000000..b5e0fc7
--- /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 0000000..3b1c058
--- /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 0000000..0361f9c
--- /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 0000000..70e86e7
--- /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 0000000..1f4644c
--- /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 0000000..b44ddad
--- /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 0000000..55dcbd1
--- /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 0000000..b85b8f4
--- /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 0000000..ac85e35
--- /dev/null
+++ b/modules/hardware/nitrokey.nix
@@ -0,0 +1,26 @@
+{ config, nixpkgs, ... }:
+
+let
+  pkgsUnstable = import <nixos-unstable> {};
+  # 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 0000000..beba72e
--- /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 0000000..9f075cc
--- /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 0000000..80e79fd
--- /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 0000000..1e97f06
--- /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 0000000..9aa5abc
--- /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
+  '';
+}