summaryrefslogtreecommitdiff
path: root/modules/solaar.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
committerAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
commite6ed60548397627bf10f561f9438201dbba0a36e (patch)
treef9a84c5957d2cc4fcd148065ee9365a0c851ae1c /modules/solaar.nix
parent9ac64328603d44bd272175942d3ea3eaadcabd04 (diff)
2024-04-21
Diffstat (limited to 'modules/solaar.nix')
-rw-r--r--modules/solaar.nix62
1 files changed, 62 insertions, 0 deletions
diff --git a/modules/solaar.nix b/modules/solaar.nix
new file mode 100644
index 0000000..17a04de
--- /dev/null
+++ b/modules/solaar.nix
@@ -0,0 +1,62 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+with lib;
+let
+ cfg = config.nixfiles.modules.solaar;
+in
+{
+ options.nixfiles.modules.solaar = {
+ enable = mkEnableOption "Solaar";
+ };
+
+ config = mkIf cfg.enable {
+ hm = {
+ 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" ];
+ };
+ 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
+ '';
+ }
+ );
+ ExecStart = "${getExe pkgs.solaar "solaar"} --window=hide";
+ };
+ Install.WantedBy = [ "graphical-session.target" ];
+ };
+ };
+
+ boot.kernelModules = [
+ "hid_logitech_dj"
+ "hid_logitech_hidpp"
+ ];
+
+ hardware.uinput.enable = true;
+
+ my.extraGroups = [
+ "uinput"
+ "input"
+ ];
+ };
+}