From 07a9c5f510886f730808c2bd892d11692e6ebc73 Mon Sep 17 00:00:00 2001 From: Anthony Rodriguez Date: Tue, 14 Jan 2025 12:34:01 +0100 Subject: [PATCH] treewide: move hardware into modules --- config/nixos/default.nix | 3 -- config/nixos/hardware/fprintd.nix | 3 -- config/nixos/hardware/fwupd.nix | 3 -- config/nixos/hardware/mcuxpresso.nix | 9 ------ config/nixos/hardware/printing.nix | 28 ---------------- config/nixos/hardware/uni-sync.nix | 37 ---------------------- config/nixos/hardware/via.nix | 7 ---- modules/nix/core/default.nix | 2 ++ modules/nix/core/hardware/default.nix | 9 ++++++ modules/nix/core/hardware/fprintd.nix | 9 ++++++ modules/nix/core/hardware/fwupd.nix | 9 ++++++ modules/nix/core/hardware/printing.nix | 36 +++++++++++++++++++++ modules/nix/core/hardware/uni-sync.nix | 44 ++++++++++++++++++++++++++ modules/nix/core/hardware/via.nix | 14 ++++++++ 14 files changed, 123 insertions(+), 90 deletions(-) delete mode 100644 config/nixos/hardware/fprintd.nix delete mode 100644 config/nixos/hardware/fwupd.nix delete mode 100644 config/nixos/hardware/mcuxpresso.nix delete mode 100644 config/nixos/hardware/printing.nix delete mode 100644 config/nixos/hardware/uni-sync.nix delete mode 100644 config/nixos/hardware/via.nix create mode 100644 modules/nix/core/hardware/default.nix create mode 100644 modules/nix/core/hardware/fprintd.nix create mode 100644 modules/nix/core/hardware/fwupd.nix create mode 100644 modules/nix/core/hardware/printing.nix create mode 100644 modules/nix/core/hardware/uni-sync.nix create mode 100644 modules/nix/core/hardware/via.nix diff --git a/config/nixos/default.nix b/config/nixos/default.nix index 8b85f66..6e5f8f8 100644 --- a/config/nixos/default.nix +++ b/config/nixos/default.nix @@ -2,9 +2,6 @@ imports = [ ./nix - ./hardware/printing.nix - ./hardware/fwupd.nix - ./network ./programs diff --git a/config/nixos/hardware/fprintd.nix b/config/nixos/hardware/fprintd.nix deleted file mode 100644 index 366fa60..0000000 --- a/config/nixos/hardware/fprintd.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - services.fprintd.enable = true; -} diff --git a/config/nixos/hardware/fwupd.nix b/config/nixos/hardware/fwupd.nix deleted file mode 100644 index a62f709..0000000 --- a/config/nixos/hardware/fwupd.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - services.fwupd.enable = true; -} diff --git a/config/nixos/hardware/mcuxpresso.nix b/config/nixos/hardware/mcuxpresso.nix deleted file mode 100644 index 57e7ba6..0000000 --- a/config/nixos/hardware/mcuxpresso.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - inputs, - pkgs, - ... -}: { - services.udev.packages = [ - inputs.self.packages.${pkgs.system}.mcuxpresso - ]; -} diff --git a/config/nixos/hardware/printing.nix b/config/nixos/hardware/printing.nix deleted file mode 100644 index 09c1f43..0000000 --- a/config/nixos/hardware/printing.nix +++ /dev/null @@ -1,28 +0,0 @@ -{pkgs, ...}: { - services = { - # setup printing service - printing.enable = true; - - avahi = { - enable = true; - nssmdns4 = true; - openFirewall = true; - }; - - printing.drivers = [ - pkgs.gutenprint - pkgs.hplip - ]; - udev.packages = [ - pkgs.sane-airscan - pkgs.utsushi - ]; - }; - - hardware.sane.enable = true; # enables support for SANE scanners - hardware.sane.extraBackends = [ - pkgs.sane-airscan # generic - pkgs.hplip # HP - pkgs.utsushi # other printers - ]; -} diff --git a/config/nixos/hardware/uni-sync.nix b/config/nixos/hardware/uni-sync.nix deleted file mode 100644 index 41c238d..0000000 --- a/config/nixos/hardware/uni-sync.nix +++ /dev/null @@ -1,37 +0,0 @@ -{pkgs, ...}: { - hardware.uni-sync = { - enable = true; - devices = [ - { - device_id = "VID:3314/PID:41218/SN:6243168001"; - sync_rgb = true; - channels = [ - { - mode = "Manual"; - speed = 60; - } - { - mode = "Manual"; - speed = 60; - } - { - mode = "Manual"; - speed = 60; - } - { - mode = "Manual"; - speed = 60; - } - ]; - } - ]; - }; - - systemd.services.uni-sync = { - enable = true; - serviceConfig = { - ExecStart = "${pkgs.uni-sync}/bin/uni-sync"; - }; - wantedBy = ["multi-user.target"]; - }; -} diff --git a/config/nixos/hardware/via.nix b/config/nixos/hardware/via.nix deleted file mode 100644 index 05c1c48..0000000 --- a/config/nixos/hardware/via.nix +++ /dev/null @@ -1,7 +0,0 @@ -{pkgs, ...}: { - hardware.keyboard.qmk.enable = true; - environment.systemPackages = with pkgs; [ - via - ]; - services.udev.packages = [pkgs.via]; -} diff --git a/modules/nix/core/default.nix b/modules/nix/core/default.nix index 8f83d15..3a603de 100644 --- a/modules/nix/core/default.nix +++ b/modules/nix/core/default.nix @@ -1,5 +1,7 @@ {lib, ...}: { imports = [ + ./hardware + ./boot.nix ./home-manager.nix ./locales.nix diff --git a/modules/nix/core/hardware/default.nix b/modules/nix/core/hardware/default.nix new file mode 100644 index 0000000..660a10f --- /dev/null +++ b/modules/nix/core/hardware/default.nix @@ -0,0 +1,9 @@ +{ + imports = [ + ./fprintd.nix + ./fwupd.nix + ./printing.nix + ./uni-sync.nix + ./via.nix + ]; +} diff --git a/modules/nix/core/hardware/fprintd.nix b/modules/nix/core/hardware/fprintd.nix new file mode 100644 index 0000000..d5b4fc3 --- /dev/null +++ b/modules/nix/core/hardware/fprintd.nix @@ -0,0 +1,9 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.laptop.enable { + services.fprintd.enable = true; + }; +} diff --git a/modules/nix/core/hardware/fwupd.nix b/modules/nix/core/hardware/fwupd.nix new file mode 100644 index 0000000..db3e785 --- /dev/null +++ b/modules/nix/core/hardware/fwupd.nix @@ -0,0 +1,9 @@ +{ + lib, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services.fwupd.enable = true; + }; +} diff --git a/modules/nix/core/hardware/printing.nix b/modules/nix/core/hardware/printing.nix new file mode 100644 index 0000000..39b1bc9 --- /dev/null +++ b/modules/nix/core/hardware/printing.nix @@ -0,0 +1,36 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.desktop.enable { + services = { + # setup printing service + printing.enable = true; + + avahi = { + enable = true; + nssmdns4 = true; + openFirewall = true; + }; + + printing.drivers = [ + pkgs.gutenprint + pkgs.hplip + ]; + + udev.packages = [ + pkgs.sane-airscan + pkgs.utsushi + ]; + }; + + hardware.sane.enable = true; # enables support for SANE scanners + hardware.sane.extraBackends = [ + pkgs.sane-airscan # generic + pkgs.hplip # HP + pkgs.utsushi # other printers + ]; + }; +} diff --git a/modules/nix/core/hardware/uni-sync.nix b/modules/nix/core/hardware/uni-sync.nix new file mode 100644 index 0000000..15e061a --- /dev/null +++ b/modules/nix/core/hardware/uni-sync.nix @@ -0,0 +1,44 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.gaming.enable { + hardware.uni-sync = { + enable = true; + devices = [ + { + device_id = "VID:3314/PID:41218/SN:6243168001"; + sync_rgb = true; + channels = [ + { + mode = "Manual"; + speed = 60; + } + { + mode = "Manual"; + speed = 60; + } + { + mode = "Manual"; + speed = 60; + } + { + mode = "Manual"; + speed = 60; + } + ]; + } + ]; + }; + + systemd.services.uni-sync = { + enable = true; + serviceConfig = { + ExecStart = "${pkgs.uni-sync}/bin/uni-sync"; + }; + wantedBy = ["multi-user.target"]; + }; + }; +} diff --git a/modules/nix/core/hardware/via.nix b/modules/nix/core/hardware/via.nix new file mode 100644 index 0000000..8b1b22e --- /dev/null +++ b/modules/nix/core/hardware/via.nix @@ -0,0 +1,14 @@ +{ + lib, + pkgs, + config, + ... +}: { + config = lib.mkIf config.local.profiles.gaming.enable { + hardware.keyboard.qmk.enable = true; + environment.systemPackages = with pkgs; [ + via + ]; + services.udev.packages = [pkgs.via]; + }; +}