summaryrefslogtreecommitdiff
path: root/sys/hardware
diff options
context:
space:
mode:
Diffstat (limited to 'sys/hardware')
-rw-r--r--sys/hardware/altera.nix22
-rw-r--r--sys/hardware/apc.nix30
-rw-r--r--sys/hardware/bluetooth.nix16
-rw-r--r--sys/hardware/default.nix12
-rw-r--r--sys/hardware/epson.nix29
-rw-r--r--sys/hardware/laptop.nix16
-rw-r--r--sys/hardware/printing.nix32
-rw-r--r--sys/hardware/thinkpad.nix38
-rw-r--r--sys/hardware/yubico.nix14
9 files changed, 209 insertions, 0 deletions
diff --git a/sys/hardware/altera.nix b/sys/hardware/altera.nix
new file mode 100644
index 0000000..2fc1bb6
--- /dev/null
+++ b/sys/hardware/altera.nix
@@ -0,0 +1,22 @@
+{ config, lib, ... }:
+with lib; let
+ cfg = config.local.hardware.altera;
+in
+{
+ options.local.hardware.altera = {
+ enable = mkEnableOption "Altera USB Blaster";
+ };
+
+ config = mkIf cfg.enable {
+ services.udev.extraRules = ''
+ # USB-Blaster
+ ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6001", MODE="660", GROUP="users", TAG+="uaccess"
+ ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6002", MODE="660", GROUP="users", TAG+="uaccess"
+ ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6003", MODE="660", GROUP="users", TAG+="uaccess"
+
+ # USB-Blaster II
+ ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6010", MODE="660", GROUP="users", TAG+="uaccess"
+ ATTRS{idVendor}=="09fb", ATTRS{idProduct}=="6810", MODE="660", GROUP="users", TAG+="uaccess"
+ '';
+ };
+}
diff --git a/sys/hardware/apc.nix b/sys/hardware/apc.nix
new file mode 100644
index 0000000..2a7adaa
--- /dev/null
+++ b/sys/hardware/apc.nix
@@ -0,0 +1,30 @@
+{ config, lib, ... }:
+with lib; let
+ cfg = config.local.hardware.apc;
+in
+{
+ options.local.hardware.apc = {
+ enable = mkEnableOption "APC UPS support";
+ };
+
+ config = mkIf cfg.enable {
+ services.apcupsd = {
+ enable = true;
+
+ configText = concatStrings (mapAttrsToList (k: v: "${k} ${v}\n") {
+ UPSMODE = "disable";
+ UPSTYPE = "usb";
+ UPSCABLE = "usb";
+ UPSCLASS = "standalone";
+
+ NISIP = "127.0.0.1";
+ NETSERVER = "on";
+
+ MINUTES = "10";
+ BATTERYLEVEL = "15";
+
+ NOLOGON = "disable";
+ });
+ };
+ };
+}
diff --git a/sys/hardware/bluetooth.nix b/sys/hardware/bluetooth.nix
new file mode 100644
index 0000000..0d53750
--- /dev/null
+++ b/sys/hardware/bluetooth.nix
@@ -0,0 +1,16 @@
+{ config, lib, ... }:
+with lib; let
+ cfg = config.local.hardware.bluetooth;
+in
+{
+ options.local.hardware.bluetooth = {
+ enable = mkEnableOption "bluetooth services";
+ };
+
+ config = mkIf cfg.enable {
+ hardware.bluetooth = {
+ enable = true;
+ powerOnBoot = mkDefault false;
+ };
+ };
+}
diff --git a/sys/hardware/default.nix b/sys/hardware/default.nix
new file mode 100644
index 0000000..10bdece
--- /dev/null
+++ b/sys/hardware/default.nix
@@ -0,0 +1,12 @@
+{
+ imports = [
+ ./altera.nix
+ ./apc.nix
+ ./bluetooth.nix
+ ./epson.nix
+ ./laptop.nix
+ ./printing.nix
+ ./thinkpad.nix
+ ./yubico.nix
+ ];
+}
diff --git a/sys/hardware/epson.nix b/sys/hardware/epson.nix
new file mode 100644
index 0000000..3900a2c
--- /dev/null
+++ b/sys/hardware/epson.nix
@@ -0,0 +1,29 @@
+{ config, lib, pkgs, ... }:
+with lib; let
+ cfg = config.local.hardware.epson;
+in
+{
+ options.local.hardware.epson = {
+ enable = mkEnableOption "Epson printers and scanners";
+ };
+
+ config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = config.local.hardware.printing.enable;
+ message = "epson requires printing";
+ }
+ ];
+
+ services.printing.enable = true;
+ hardware.sane.enable = true;
+
+ hardware.sane.extraBackends = [
+ pkgs.epkowa
+ ];
+
+ services.printing.drivers = [
+ pkgs.epson_201207w
+ ];
+ };
+}
diff --git a/sys/hardware/laptop.nix b/sys/hardware/laptop.nix
new file mode 100644
index 0000000..d9ba753
--- /dev/null
+++ b/sys/hardware/laptop.nix
@@ -0,0 +1,16 @@
+{ config, lib, ... }:
+with lib; let
+ cfg = config.local.hardware.laptop;
+in
+{
+ options.local.hardware.laptop = {
+ enable = mkEnableOption "laptop stuff";
+ };
+
+ config = mkIf cfg.enable {
+ services = {
+ tlp.enable = true;
+ upower.enable = true;
+ };
+ };
+}
diff --git a/sys/hardware/printing.nix b/sys/hardware/printing.nix
new file mode 100644
index 0000000..8280da9
--- /dev/null
+++ b/sys/hardware/printing.nix
@@ -0,0 +1,32 @@
+{ config, lib, ... }:
+with lib; let
+ cfg = config.local.hardware.printing;
+in
+{
+ options.local.hardware.printing = {
+ enable = mkEnableOption "print and scan services";
+
+ users = mkOption {
+ type = with types; listOf str;
+ default = [ ];
+ };
+ };
+
+ config = mkIf cfg.enable {
+ services.avahi = {
+ enable = true;
+ nssmdns4 = true;
+ openFirewall = true;
+ };
+
+ hardware.sane.enable = true;
+ services.printing.enable = true;
+
+ users.users = listToAttrs (map
+ (user: {
+ name = user;
+ value.extraGroups = [ "scanner" "lp" ];
+ })
+ cfg.users);
+ };
+}
diff --git a/sys/hardware/thinkpad.nix b/sys/hardware/thinkpad.nix
new file mode 100644
index 0000000..a65ffb2
--- /dev/null
+++ b/sys/hardware/thinkpad.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, ... }:
+with lib; let
+ cfg = config.local.hardware.thinkpad;
+in
+{
+ options.local.hardware.thinkpad = {
+ enable = mkEnableOption "Thinkpad hardware support";
+ };
+
+ config = mkIf cfg.enable {
+ # For suspending to RAM to work, set Config -> Power -> Sleep State to "Linux" in EFI.
+ # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Suspend_issues
+ # Fingerprint sensor requires a firmware-update to work.
+
+ boot = {
+ extraModulePackages = with config.boot.kernelPackages; [ acpi_call digimend ];
+ extraModprobeConfig = "options iwlwifi 11n_disable=1 wd_disable=1";
+
+ # acpi_call makes tlp work for newer thinkpads
+ kernelModules = [ "acpi_call" "digimend" ];
+
+ # Force use of the thinkpad_acpi driver for backlight control.
+ # This allows the backlight save/load systemd service to work.
+ kernelParams = [ "acpi_backlight=native" ];
+ };
+
+ hardware.firmware = [ pkgs.sof-firmware ];
+
+ local.hardware.laptop.enable = true;
+
+ services = {
+ fprintd.enable = true;
+ thinkfan.enable = true;
+ tlp.enable = true;
+ tp-auto-kbbl.enable = true;
+ };
+ };
+}
diff --git a/sys/hardware/yubico.nix b/sys/hardware/yubico.nix
new file mode 100644
index 0000000..a3440c3
--- /dev/null
+++ b/sys/hardware/yubico.nix
@@ -0,0 +1,14 @@
+{ config, lib, pkgs, ... }:
+with lib; let
+ cfg = config.local.hardware.yubico;
+in
+{
+ options.local.hardware.yubico = {
+ enable = mkEnableOption "Yubico hardware support";
+ };
+
+ config = mkIf cfg.enable {
+ services.pcscd.enable = true;
+ services.udev.packages = [ pkgs.yubikey-personalization ];
+ };
+}