Commit 4cabf05

HPCesia <me@hpcesia.com>
2025-10-08 13:54:55
fix: correctly disable plasma configs when not using plasma
1 parent 8dc7a01
Changed files (6)
modules
desktop
hosts
modules/desktop/fonts/plasma.nix
@@ -1,39 +1,33 @@
 {lib, ...}: {
-  flake.modules.homeManager.desktop = {
-    config,
-    osConfig,
-    ...
-  }: let
-    hasPlasma =
-      osConfig.services.desktopManager.plasma6.enable
-      && lib.hasAttr "plasma" config.programs
-      && config.programs.plasma.enable;
-  in {
-    programs.plasma.fonts = lib.mkIf hasPlasma {
-      general = {
-        family = "Source Han Sans SC";
-        pointSize = 12;
-      };
-      fixedWidth = {
-        family = "Maple Mono CN";
-        pointSize = 12;
-      };
-      menu = {
-        family = "Source Han Sans SC";
-        pointSize = 12;
-      };
-      small = {
-        family = "Source Han Sans SC";
-        pointSize = 10;
-      };
-      toolbar = {
-        family = "Source Han Sans SC";
-        pointSize = 12;
-      };
-      windowTitle = {
-        family = "Source Han Sans SC";
-        pointSize = 12;
+  flake.modules.homeManager.desktop = {osConfig, ...}: let
+    hasPlasma = osConfig.services.desktopManager.plasma6.enable;
+  in
+    lib.optionalAttrs hasPlasma {
+      programs.plasma.fonts = {
+        general = {
+          family = "Source Han Sans SC";
+          pointSize = 12;
+        };
+        fixedWidth = {
+          family = "Maple Mono CN";
+          pointSize = 12;
+        };
+        menu = {
+          family = "Source Han Sans SC";
+          pointSize = 12;
+        };
+        small = {
+          family = "Source Han Sans SC";
+          pointSize = 10;
+        };
+        toolbar = {
+          family = "Source Han Sans SC";
+          pointSize = 12;
+        };
+        windowTitle = {
+          family = "Source Han Sans SC";
+          pointSize = 12;
+        };
       };
     };
-  };
 }
modules/desktop/input-method/fcitx5/default.nix
@@ -1,18 +1,8 @@
 {lib, ...}: {
-  flake.modules.homeManager.desktop = {
-    pkgs,
-    config,
-    osConfig,
-    ...
-  }: let
+  flake.modules.homeManager.desktop = {pkgs, ...}: let
     fcitx5-rime = pkgs.fcitx5-rime.override {
       rimeDataPkgs = [pkgs.nur.repos.xyenon.rime-ice];
     };
-
-    hasPlasma =
-      osConfig.services.desktopManager.plasma6.enable
-      && lib.hasAttr "plasma" config.programs
-      && config.programs.plasma.enable;
   in {
     xdg.configFile = lib.mkIf pkgs.stdenv.hostPlatform.isLinux {
       "fcitx5/profile" = {
@@ -36,10 +26,5 @@
         waylandFrontend = true;
       };
     };
-
-    programs.plasma.configFile.kwinrc.Wayland.InputMethod = lib.mkIf hasPlasma {
-      shellExpand = true;
-      value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
-    };
   };
 }
modules/desktop/input-method/fcitx5/plasma.nix
@@ -0,0 +1,11 @@
+{lib, ...}: {
+  flake.modules.homeManager.desktop = {osConfig, ...}: let
+    hasPlasma = osConfig.services.desktopManager.plasma6.enable;
+  in
+    lib.optionalAttrs hasPlasma {
+      programs.plasma.configFile.kwinrc.Wayland.InputMethod = {
+        shellExpand = true;
+        value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
+      };
+    };
+}
modules/hosts/chaser-kevin/home/default.nix
@@ -0,0 +1,14 @@
+{
+  inputs,
+  lib,
+  ...
+}: {
+  flake.modules.homeManager."hosts/kevin" = {config, ...}: {
+    programs.fastfetch.settings.logo = lib.mkIf config.programs.fastfetch.enable {
+      type = "kitty-direct";
+      source = "${inputs.nixos-logo}/nixos-griseo.png";
+      height = 15;
+      width = 32;
+    };
+  };
+}
modules/hosts/chaser-kevin/home/plasma.nix
@@ -0,0 +1,68 @@
+{lib, ...}: {
+  flake.modules.homeManager."hosts/kevin" = {osConfig, ...}: let
+    hasPlasma = osConfig.services.desktopManager.plasma6.enable;
+  in
+    lib.optionalAttrs hasPlasma {
+      # Power Control
+      programs.plasma.powerdevil = {
+        AC.inhibitLidActionWhenExternalMonitorConnected = true;
+        battery = {
+          powerProfile = "powerSaving";
+          # Auto Power Save
+          autoSuspend = {
+            action = "sleep";
+            idleTimeout = 600;
+          };
+          turnOffDisplay = {
+            idleTimeout = 360;
+            idleTimeoutWhenLocked = 120;
+          };
+          dimDisplay = {
+            enable = true;
+            idleTimeout = 120;
+          };
+          # Actions
+          whenLaptopLidClosed = "hibernate";
+          whenSleepingEnter = "standbyThenHibernate";
+          powerButtonAction = "shutDown";
+          inhibitLidActionWhenExternalMonitorConnected = true;
+        };
+        lowBattery = {
+          powerProfile = "powerSaving";
+          # Auto Power Save
+          autoSuspend = {
+            action = "sleep";
+            idleTimeout = 300;
+          };
+          turnOffDisplay = {
+            idleTimeout = 180;
+            idleTimeoutWhenLocked = 60;
+          };
+          dimDisplay = {
+            enable = true;
+            idleTimeout = 60;
+          };
+          # Actions
+          whenLaptopLidClosed = "hibernate";
+          whenSleepingEnter = "standbyThenHibernate";
+          powerButtonAction = "shutDown";
+          inhibitLidActionWhenExternalMonitorConnected = true;
+        };
+      };
+
+      programs.plasma.input = {
+        touchpads = [
+          {
+            enable = true;
+            name = "SYNA2BA6:00 06CB:CF00 Touchpad";
+            productId = "cf00";
+            vendorId = "06cb";
+            disableWhileTyping = true;
+            naturalScroll = true;
+            tapToClick = true;
+            tapAndDrag = true;
+          }
+        ];
+      };
+    };
+}
modules/hosts/chaser-kevin/home.nix
@@ -1,85 +0,0 @@
-{
-  inputs,
-  lib,
-  ...
-}: {
-  flake.modules.homeManager."hosts/kevin" = {
-    config,
-    osConfig,
-    ...
-  }: let
-    hasPlasma =
-      osConfig.services.desktopManager.plasma6.enable
-      && lib.hasAttr "plasma" config.programs
-      && config.programs.plasma.enable;
-  in {
-    programs.fastfetch.settings.logo = lib.mkIf config.programs.fastfetch.enable {
-      type = "kitty-direct";
-      source = "${inputs.nixos-logo}/nixos-griseo.png";
-      height = 15;
-      width = 32;
-    };
-
-    # Power Control
-    programs.plasma.powerdevil = lib.mkIf hasPlasma {
-      AC.inhibitLidActionWhenExternalMonitorConnected = true;
-      battery = {
-        powerProfile = "powerSaving";
-        # Auto Power Save
-        autoSuspend = {
-          action = "sleep";
-          idleTimeout = 600;
-        };
-        turnOffDisplay = {
-          idleTimeout = 360;
-          idleTimeoutWhenLocked = 120;
-        };
-        dimDisplay = {
-          enable = true;
-          idleTimeout = 120;
-        };
-        # Actions
-        whenLaptopLidClosed = "hibernate";
-        whenSleepingEnter = "standbyThenHibernate";
-        powerButtonAction = "shutDown";
-        inhibitLidActionWhenExternalMonitorConnected = true;
-      };
-      lowBattery = {
-        powerProfile = "powerSaving";
-        # Auto Power Save
-        autoSuspend = {
-          action = "sleep";
-          idleTimeout = 300;
-        };
-        turnOffDisplay = {
-          idleTimeout = 180;
-          idleTimeoutWhenLocked = 60;
-        };
-        dimDisplay = {
-          enable = true;
-          idleTimeout = 60;
-        };
-        # Actions
-        whenLaptopLidClosed = "hibernate";
-        whenSleepingEnter = "standbyThenHibernate";
-        powerButtonAction = "shutDown";
-        inhibitLidActionWhenExternalMonitorConnected = true;
-      };
-    };
-
-    programs.plasma.input = lib.mkIf hasPlasma {
-      touchpads = [
-        {
-          enable = true;
-          name = "SYNA2BA6:00 06CB:CF00 Touchpad";
-          productId = "cf00";
-          vendorId = "06cb";
-          disableWhileTyping = true;
-          naturalScroll = true;
-          tapToClick = true;
-          tapAndDrag = true;
-        }
-      ];
-    };
-  };
-}