about summary refs log tree commit diff
path: root/modules/nixos/solaar.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
committerAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
commit9a5427e3a0c0ccf2a82dc503149a26b23fbd6004 (patch)
treef28beec29deeea36038615a8fb98a810891940b5 /modules/nixos/solaar.nix
parent2024-03-19 (diff)
2024-03-31
Diffstat (limited to 'modules/nixos/solaar.nix')
-rw-r--r--modules/nixos/solaar.nix48
1 files changed, 29 insertions, 19 deletions
diff --git a/modules/nixos/solaar.nix b/modules/nixos/solaar.nix
index ccfff4a..17a04de 100644
--- a/modules/nixos/solaar.nix
+++ b/modules/nixos/solaar.nix
@@ -4,49 +4,59 @@
   pkgs,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.solaar;
-in {
+in
+{
   options.nixfiles.modules.solaar = {
     enable = mkEnableOption "Solaar";
   };
 
   config = mkIf cfg.enable {
     hm = {
-      home.packages = with pkgs; [solaar];
+      home.packages = with pkgs; [ solaar ];
 
       systemd.user.services.solaar = {
         Unit = {
           Description = "Device manager for Logitech devices";
-          After = ["graphical-session-pre.target"];
-          PartOf = ["graphical-session.target"];
+          After = [ "graphical-session-pre.target" ];
+          PartOf = [ "graphical-session.target" ];
         };
         Service = {
           # The dirtiest hack I've ever implemented... I should be ashamed of
           # it. Regardless, that shit still doesn't work because each reconnect,
           # /dev/hidraw* is recreated and has default permissions which breaks
           # Solaar. Fuck this shit.
-          ExecStartPre = getExe (pkgs.writeShellApplication {
-            name = "solaar-pre";
-            text = ''
-              for i in /dev/hidraw*; do
-                if [ -c "$i" ]; then
-                  sudo chown root:input "$i"
-                  sudo chmod 0660 "$i"
-                fi
-              done
-            '';
-          });
+          ExecStartPre = getExe (
+            pkgs.writeShellApplication {
+              name = "solaar-pre";
+              text = ''
+                for i in /dev/hidraw*; do
+                  if [ -c "$i" ]; then
+                    sudo chown root:input "$i"
+                    sudo chmod 0660 "$i"
+                  fi
+                done
+              '';
+            }
+          );
           ExecStart = "${getExe pkgs.solaar "solaar"} --window=hide";
         };
-        Install.WantedBy = ["graphical-session.target"];
+        Install.WantedBy = [ "graphical-session.target" ];
       };
     };
 
-    boot.kernelModules = ["hid_logitech_dj" "hid_logitech_hidpp"];
+    boot.kernelModules = [
+      "hid_logitech_dj"
+      "hid_logitech_hidpp"
+    ];
 
     hardware.uinput.enable = true;
 
-    my.extraGroups = ["uinput" "input"];
+    my.extraGroups = [
+      "uinput"
+      "input"
+    ];
   };
 }

Consider giving Nix/NixOS a try! <3