Commit c7e01e8

HPCesia <me@hpcesia.com>
2025-09-30 17:05:23
refactor: migrate plasma6 config
1 parent edf608d
home/linux/gui/plasma/options/appearance.nix
@@ -1,54 +0,0 @@
-{
-  pkgs,
-  lib,
-  config,
-  wallpapers,
-  ...
-}: let
-  catppuccin-kde = pkgs.catppuccin-kde.override {
-    flavour = [config.catppuccin.flavor];
-    accents = [config.catppuccin.accent];
-  };
-in {
-  home.packages = with pkgs; [
-    catppuccin-kde
-  ];
-
-  programs.plasma = {
-    kscreenlocker.appearance.wallpaper = "${wallpapers}/default_wallpaper";
-
-    workspace = {
-      wallpaper = "${wallpapers}/default_wallpaper";
-      theme = "default";
-      colorScheme = "CatppuccinMacchiatoMauve";
-      iconTheme = "breeze-dark";
-    };
-
-    panels = [
-      {
-        height = 44;
-        location = "bottom";
-        lengthMode = "fill";
-        alignment = "center";
-        hiding = "none";
-        floating = true;
-        widgets = [
-          "org.kde.plasma.kickoff"
-          "org.kde.plasma.pager"
-          "org.kde.plasma.icontasks"
-          "org.kde.plasma.marginsseparator"
-          "org.kde.plasma.systemtray"
-          "org.kde.plasma.digitalclock"
-          "org.kde.plasma.showdesktop"
-        ];
-        screen = "all";
-        opacity = "translucent";
-      }
-    ];
-
-    configFile.dolphinrc.IconsMode = {
-      IconSize = 128;
-      PreviewSize = 128;
-    };
-  };
-}
home/linux/gui/plasma/options/configs.nix
@@ -1,20 +0,0 @@
-{...}: {
-  programs.plasma.configFile = {
-    kdeglobals = {
-      General = {
-        TerminalApplication = "ghostty";
-        TerminalService = "com.mitchellh.ghostty";
-      };
-    };
-    plasma-localerc = {
-      Formats.LANG = "zh_CN.UTF-8";
-      Translations.LANGUAGE = "zh_CN";
-    };
-    kwinrc = {
-      Wayland.InputMethod = {
-        shellExpand = true;
-        value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
-      };
-    };
-  };
-}
home/linux/gui/plasma/options/default.nix
@@ -1,3 +0,0 @@
-{mylib, ...}: {
-  imports = mylib.scanModules ./.;
-}
home/linux/gui/plasma/options/fonts.nix
@@ -1,30 +0,0 @@
-{...}: {
-  # Fonts used here should be added to
-  # [flakeRoot]/os-modules/nixos/desktop/fonts.nix
-  programs.plasma.fonts = {
-    general = {
-      family = "Source Han Sans SC";
-      pointSize = 11;
-    };
-    fixedWidth = {
-      family = "Maple Mono NF CN";
-      pointSize = 11;
-    };
-    menu = {
-      family = "Source Han Sans SC";
-      pointSize = 11;
-    };
-    small = {
-      family = "Source Han Sans SC";
-      pointSize = 9;
-    };
-    toolbar = {
-      family = "Source Han Sans SC";
-      pointSize = 11;
-    };
-    windowTitle = {
-      family = "Source Han Sans SC";
-      pointSize = 11;
-    };
-  };
-}
home/linux/gui/plasma/options/misc.nix
@@ -1,5 +0,0 @@
-{...}: {
-  programs.plasma = {
-    kscreenlocker.lockOnStartup = true;
-  };
-}
home/linux/gui/plasma/options/powerdevil.nix
@@ -1,17 +0,0 @@
-{...}: {
-  # AC is compatible for all hosts
-  programs.plasma.powerdevil.AC = {
-    powerProfile = "performance";
-    # Auto Power Save
-    autoSuspend.action = "nothing";
-    turnOffDisplay = {
-      idleTimeout = 14400;
-      idleTimeoutWhenLocked = 600;
-    };
-    dimDisplay.enable = false;
-    # Actions
-    whenLaptopLidClosed = "sleep";
-    whenSleepingEnter = "standby";
-    powerButtonAction = "hibernate";
-  };
-}
home/linux/gui/plasma/options/shortcuts.nix
@@ -1,14 +0,0 @@
-{...}: {
-  programs.plasma = {
-    shortcuts = {
-      "services/com.mitchellh.ghostty.desktop"._launch = "Meta+`";
-    };
-    hotkeys.commands = {
-      pot = {
-        comment = "Pot 划词翻译";
-        command = "curl \"127.0.0.1:60828/selection_translate\"";
-        key = "Meta+Alt+Q";
-      };
-    };
-  };
-}
home/linux/gui/plasma/options/windowrules.nix
@@ -1,12 +0,0 @@
-{...}: {
-  programs.plasma.window-rules = [
-    {
-      description = "Pot";
-      match = {
-        window-class.value = "pot";
-        window-types = ["normal"];
-      };
-      apply.noborder.value = true;
-    }
-  ];
-}
home/linux/gui/plasma/default.nix
@@ -1,12 +1,5 @@
-{plasma-manager, ...}: {
+{
   imports = [
-    plasma-manager.homeModules.plasma-manager
-    ./options
     ./application.nix
   ];
-
-  programs.plasma = {
-    enable = true;
-    overrideConfig = true;
-  };
 }
modules/desktop/shell/plasma6/options/appearance.nix
@@ -0,0 +1,52 @@
+{inputs, ...}: {
+  flake.modules.homeManager.plasma6 = {
+    pkgs,
+    config,
+    ...
+  }: {
+    home.packages = [
+      (pkgs.catppuccin-kde.override {
+        flavour = [config.catppuccin.flavor];
+        accents = [config.catppuccin.accent];
+      })
+    ];
+
+    programs.plasma = {
+      kscreenlocker.appearance.wallpaper = "${inputs.wallpapers}/default_wallpaper";
+
+      workspace = {
+        wallpaper = "${inputs.wallpapers}/default_wallpaper";
+        theme = "default";
+        colorScheme = "CatppuccinMacchiatoMauve";
+        iconTheme = "breeze-dark";
+      };
+
+      panels = [
+        {
+          height = 44;
+          location = "bottom";
+          lengthMode = "fill";
+          alignment = "center";
+          hiding = "none";
+          floating = true;
+          widgets = [
+            "org.kde.plasma.kickoff"
+            "org.kde.plasma.pager"
+            "org.kde.plasma.icontasks"
+            "org.kde.plasma.marginsseparator"
+            "org.kde.plasma.systemtray"
+            "org.kde.plasma.digitalclock"
+            "org.kde.plasma.showdesktop"
+          ];
+          screen = "all";
+          opacity = "translucent";
+        }
+      ];
+
+      configFile.dolphinrc.IconsMode = {
+        IconSize = 128;
+        PreviewSize = 128;
+      };
+    };
+  };
+}
modules/desktop/shell/plasma6/options/configs.nix
@@ -0,0 +1,22 @@
+{
+  flake.modules.homeManager.plasma6 = _: {
+    programs.plasma.configFile = {
+      kdeglobals = {
+        General = {
+          TerminalApplication = "ghostty";
+          TerminalService = "com.mitchellh.ghostty";
+        };
+      };
+      plasma-localerc = {
+        Formats.LANG = "zh_CN.UTF-8";
+        Translations.LANGUAGE = "zh_CN";
+      };
+      kwinrc = {
+        Wayland.InputMethod = {
+          shellExpand = true;
+          value = "/etc/profiles/per-user/hpcesia/share/applications/fcitx5-wayland-launcher.desktop";
+        };
+      };
+    };
+  };
+}
modules/desktop/shell/plasma6/options/misc.nix
@@ -0,0 +1,7 @@
+{
+  flake.modules.homeManager.plasma6 = _: {
+    programs.plasma = {
+      kscreenlocker.lockOnStartup = true;
+    };
+  };
+}
modules/desktop/shell/plasma6/options/powerdevil.nix
@@ -0,0 +1,19 @@
+{
+  flake.modules.homeManager.plasma6 = _: {
+    # AC is compatible for all hosts
+    programs.plasma.powerdevil.AC = {
+      powerProfile = "performance";
+      # Auto Power Save
+      autoSuspend.action = "nothing";
+      turnOffDisplay = {
+        idleTimeout = 14400;
+        idleTimeoutWhenLocked = 600;
+      };
+      dimDisplay.enable = false;
+      # Actions
+      whenLaptopLidClosed = "sleep";
+      whenSleepingEnter = "standby";
+      powerButtonAction = "hibernate";
+    };
+  };
+}
modules/desktop/shell/plasma6/options/shortcuts.nix
@@ -0,0 +1,9 @@
+{
+  flake.modules.homeManager.plasma6 = _: {
+    programs.plasma = {
+      shortcuts = {
+        "services/com.mitchellh.ghostty.desktop"._launch = "Meta+`";
+      };
+    };
+  };
+}
modules/desktop/shell/plasma6/default.nix
@@ -0,0 +1,20 @@
+{inputs, ...}: {
+  flake.modules.nixos.plasma6 = _: {
+    services = {
+      xserver.enable = true;
+      displayManager.sddm.enable = true;
+      displayManager.defaultSession = "plasma";
+      desktopManager.plasma6.enable = true;
+    };
+  };
+
+  flake.modules.homeManager.plasma6 = _: {
+    imports = [
+      inputs.plasma-manager.homeModules.plasma-manager
+    ];
+    programs.plasma = {
+      enable = true;
+      overrideConfig = true;
+    };
+  };
+}
modules/desktop/shell/default.nix
@@ -0,0 +1,14 @@
+{config, ...}: {
+  # Import manually to switch desktop environment.
+  flake.modules.nixos.desktop = {
+    imports = with config.flake.modules.nixos; [
+      plasma6
+    ];
+  };
+
+  flake.modules.homeManager.desktop = {
+    imports = with config.flake.modules.homeManager; [
+      plasma6
+    ];
+  };
+}
modules/hosts/chaser-kevin/default.nix
@@ -12,6 +12,7 @@
     imports =
       (with config.flake.modules.nixos; [
         core
+        desktop
         user-root
         user-hpcesia
       ])
@@ -21,6 +22,7 @@
             imports =
               (with config.flake.modules.homeManager; [
                 core
+                desktop
                 user-hpcesia
               ])
               # TODO: remove below after migrated all config to Dendritic Pattern
os-modules/nixos/desktop.nix
@@ -15,21 +15,17 @@
     gvfs.enable = true; # Mount, trash, and other functionalities
     tumbler.enable = true; # Thumbnail support for images
     xserver = {
-      enable = true;
       xkb.layout = "us";
       excludePackages = with pkgs; [
         xterm
       ];
     };
     displayManager = {
-      sddm.enable = true;
       autoLogin = {
         enable = true;
         user = myvars.username;
       };
-      defaultSession = "plasma";
     };
-    desktopManager.plasma6.enable = true;
   };
 
   environment.plasma6.excludePackages = with pkgs.kdePackages; [