Commit 59f5e06

HPCesia <me@hpcesia.com>
2025-10-14 13:41:06
refactor: desktop environment file structure
1 parent 1cac4cd
modules/desktop/desktop-environment/discrete/shell/noctalia/keybindings/niri.nix
@@ -0,0 +1,55 @@
+{lib, ...}: {
+  flake.modules.homeManager.de-shell-noctalia = {
+    config,
+    osConfig,
+    ...
+  }:
+    lib.mkIf osConfig.programs.niri.enable {
+      programs.niri.settings.binds = with config.lib.niri.actions; let
+        noctalia = spawn "noctalia-shell" "ipc" "call";
+      in {
+        "Mod+Space" = {
+          action = noctalia "launcher" "toggle";
+          hotkey-overlay.title = "Toggle Application Launcher";
+        };
+        "Super+Alt+L" = {
+          action = noctalia "lockScreen" "toggle";
+          hotkey-overlay.title = "Toggle Lock Screen";
+        };
+        "Mod+Escape" = {
+          action = noctalia "settings" "toggle";
+          hotkey-overlay.title = "Toggle Settings Menu";
+        };
+        "Mod+X" = {
+          action = noctalia "controlCenter" "toggle";
+          hotkey-overlay.title = "Toggle Control Center";
+        };
+
+        "XF86AudioRaiseVolume" = {
+          allow-when-locked = true;
+          action = noctalia "volume" "increase";
+        };
+        "XF86AudioLowerVolume" = {
+          allow-when-locked = true;
+          action = noctalia "volume" "decrease";
+        };
+        "XF86AudioMute" = {
+          allow-when-locked = true;
+          action = noctalia "volume" "muteOutput";
+        };
+        "XF86AudioMicMute" = {
+          allow-when-locked = true;
+          action = noctalia "volume" "muteInput";
+        };
+
+        "XF86MonBrightnessUp" = {
+          allow-when-locked = true;
+          action = noctalia "brightness" "increase";
+        };
+        "XF86MonBrightnessDown" = {
+          allow-when-locked = true;
+          action = noctalia "brightness" "decrease";
+        };
+      };
+    };
+}
modules/desktop/desktop-environment/discrete/shell/noctalia/bar.nix
@@ -0,0 +1,57 @@
+{
+  flake.modules.homeManager.de-shell-noctalia = {config, ...}: {
+    programs.noctalia-shell.settings.bar = {
+      backgroundOpacity = config.stylix.opacity.desktop;
+      density = "comfortable";
+      floating = true;
+      marginHorizontal = 0.4;
+      marginVertical = 0.4;
+      widgets = {
+        center = [
+          {
+            id = "Workspace";
+            hideUnoccupied = true;
+            labelMode = "index";
+          }
+        ];
+        left = [
+          {
+            id = "ControlCenter";
+            useDistroLogo = true;
+          }
+          {id = "SystemMonitor";}
+          {id = "ActiveWindow";}
+          {
+            id = "MediaMini";
+            autoHide = true;
+            showAlbumArt = true;
+            showVisualizer = true;
+            visualizerType = "linear";
+          }
+        ];
+        right = [
+          {id = "ScreenRecorder";}
+          {
+            id = "Tray";
+            blacklist = ["Bluetooth *"]; # I don't want double bluetooth applet.
+          }
+          {
+            id = "NotificationHistory";
+            hideWhenZero = true;
+            showUnreadBadge = true;
+          }
+          {id = "WiFi";}
+          {id = "Bluetooth";}
+          {id = "Volume";}
+          {id = "Brightness";}
+          {id = "Battery";}
+          {
+            id = "Clock";
+            formatHorizontal = "yyyy年M月d日 HH:mm";
+            formatVertical = "yyyy年M月d日 dddd-AP HH:mm:ss";
+          }
+        ];
+      };
+    };
+  };
+}
modules/desktop/desktop-environment/discrete/shell/noctalia/colors.nix
@@ -0,0 +1,20 @@
+{
+  flake.modules.homeManager.de-shell-noctalia = {config, ...}: {
+    programs.noctalia-shell.colors = {
+      mPrimary = config.lib.stylix.colors.base0E;
+      mOnPrimary = config.lib.stylix.colors.base11;
+      mSecondary = config.lib.stylix.colors.base09;
+      mOnSecondary = config.lib.stylix.colors.base11;
+      mTertiary = config.lib.stylix.colors.base15;
+      mOnTertiary = config.lib.stylix.colors.base11;
+      mError = config.lib.stylix.colors.base08;
+      mOnError = config.lib.stylix.colors.base11;
+      mSurface = config.lib.stylix.colors.base00;
+      mOnSurface = config.lib.stylix.colors.base05;
+      mSurfaceVariant = config.lib.stylix.colors.base02;
+      mOnSurfaceVariant = config.lib.stylix.colors.base04;
+      mOutline = config.lib.stylix.colors.base03;
+      mShadow = config.lib.stylix.colors.base11;
+    };
+  };
+}
modules/desktop/desktop-environment/discrete/shell/noctalia/default.nix
@@ -0,0 +1,31 @@
+{inputs, ...}: {
+  flake.modules.homeManager.de-shell-noctalia = {config, ...}: {
+    imports = [inputs.noctalia.homeModules.default];
+
+    programs.noctalia-shell = {
+      enable = true;
+      settings = {
+        ui = {
+          fontDefault = config.stylix.fonts.sansSerif.name;
+          fontFixed = config.stylix.fonts.monospace.name;
+        };
+        general = {
+          avatarImage = "${config.home.homeDirectory}/.face";
+          radiusRatio = 0.75;
+          screenRadiusRatio = 0.5;
+        };
+        wallpaper = {
+          enabled = true;
+          defaultWallpaper = config.stylix.image;
+        };
+        appLauncher = {
+          backgroundOpacity = config.stylix.opacity.popups;
+          enableClipboardHistory = true;
+          terminalCommand = "ghostty -e";
+        };
+        location.name = "重庆, 中国";
+        screenRecorder.directory = config.xdg.userDirs.videos;
+      };
+    };
+  };
+}
modules/desktop/desktop-environment/discrete/shell/defualt.nix
@@ -0,0 +1,7 @@
+{config, ...}: {
+  flake.modules.homeManager.de-shell = _: {
+    imports = with config.flake.modules.homeManager; [
+      de-shell-noctalia
+    ];
+  };
+}
modules/desktop/shell/niri/default.nix → modules/desktop/desktop-environment/discrete/wm/niri/default.nix
@@ -1,5 +1,5 @@
 {inputs, ...}: {
-  flake.modules.nixos.niri = _: {
+  flake.modules.nixos.wm-niri = _: {
     imports = [
       inputs.niri-flake.nixosModules.niri
       inputs.noctalia.nixosModules.default
@@ -14,15 +14,7 @@
     services.noctalia-shell.enable = true;
   };
 
-  flake.modules.homeManager.niri = {config, ...}: {
-    imports = [
-      inputs.noctalia.homeModules.default
-    ];
-
+  flake.modules.homeManager.wm-niri = {config, ...}: {
     programs.niri.settings.screenshot-path = "${config.xdg.userDirs.pictures}/Screenshots";
-
-    programs.noctalia-shell = {
-      enable = true;
-    };
   };
 }
modules/desktop/shell/niri/keybinding.nix → modules/desktop/desktop-environment/discrete/wm/niri/keybinding.nix
@@ -1,8 +1,6 @@
 {
-  flake.modules.homeManager.niri = {config, ...}: {
-    programs.niri.settings.binds = with config.lib.niri.actions; let
-      noctalia = spawn "noctalia-shell" "ipc" "call";
-    in {
+  flake.modules.homeManager.wm-niri = {config, ...}: {
+    programs.niri.settings.binds = with config.lib.niri.actions; {
       # Mod-Shift-/, which is usually the same as Mod-?,
       # shows a list of important hotkeys.
       "Mod+Shift+Slash".action = show-hotkey-overlay;
@@ -17,51 +15,6 @@
 
       "Mod+Grave".action = spawn "ghostty";
 
-      # === DankMaterialShell Actions ===
-      # Partially copy from DMS' niri home manager module
-      "Mod+Space" = {
-        action = noctalia "launcher" "toggle";
-        hotkey-overlay.title = "Toggle Application Launcher";
-      };
-      "Super+Alt+L" = {
-        action = noctalia "lockScreen" "toggle";
-        hotkey-overlay.title = "Toggle Lock Screen";
-      };
-      "Mod+Escape" = {
-        action = noctalia "settings" "toggle";
-        hotkey-overlay.title = "Toggle Settings Menu";
-      };
-      "Mod+X" = {
-        action = noctalia "controlCenter" "toggle";
-        hotkey-overlay.title = "Toggle Control Center";
-      };
-
-      "XF86AudioRaiseVolume" = {
-        allow-when-locked = true;
-        action = noctalia "volume" "increase";
-      };
-      "XF86AudioLowerVolume" = {
-        allow-when-locked = true;
-        action = noctalia "volume" "decrease";
-      };
-      "XF86AudioMute" = {
-        allow-when-locked = true;
-        action = noctalia "volume" "muteOutput";
-      };
-      "XF86AudioMicMute" = {
-        allow-when-locked = true;
-        action = noctalia "volume" "muteInput";
-      };
-
-      "XF86MonBrightnessUp" = {
-        allow-when-locked = true;
-        action = noctalia "brightness" "increase";
-      };
-      "XF86MonBrightnessDown" = {
-        allow-when-locked = true;
-        action = noctalia "brightness" "decrease";
-      };
-
       # === Window and Column Actions ===
       "Mod+Q".action = close-window;
 
modules/desktop/shell/niri/appearance/layer-rules.nix → modules/desktop/desktop-environment/discrete/wm/niri/layer-rules.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.niri = _: {
+  flake.modules.homeManager.wm-niri = _: {
     programs.niri.settings.layer-rules = [
       {
         matches = [{namespace = "^quickshell-overview$";}];
modules/desktop/shell/niri/appearance/layout.nix → modules/desktop/desktop-environment/discrete/wm/niri/layout.nix
@@ -1,6 +1,8 @@
 {
-  flake.modules.homeManager.niri = {config, ...}: let
+  flake.modules.homeManager.wm-niri = {config, ...}: let
   in {
+    programs.niri.settings.prefer-no-csd = true;
+
     programs.niri.settings.layout = {
       gaps = 10;
       focus-ring = {
modules/desktop/shell/niri/appearance/window-rules.nix → modules/desktop/desktop-environment/discrete/wm/niri/window-rules.nix
@@ -1,5 +1,5 @@
 {lib, ...}: {
-  flake.modules.homeManager.niri = {config, ...}: {
+  flake.modules.homeManager.wm-niri = {config, ...}: {
     programs.niri.settings.window-rules = [
       {
         # rules for all windows
modules/desktop/shell/niri/workspaces.nix → modules/desktop/desktop-environment/discrete/wm/niri/workspaces.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.niri = _: {
+  flake.modules.homeManager.wm-niri = _: {
     programs.niri.settings.workspaces = {
       "1terminal" = {};
       "2browser" = {};
modules/desktop/shell/niri/clipboard.nix → modules/desktop/desktop-environment/discrete/clipboard.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.niri = {pkgs, ...}: {
+  flake.modules.homeManager.de-discrete = {pkgs, ...}: {
     home.packages = [pkgs.wl-clipboard];
 
     services.cliphist = {
modules/desktop/desktop-environment/discrete/default.nix
@@ -0,0 +1,15 @@
+{config, ...}: {
+  flake.modules.nixos.de-discrete = _: {
+    imports = with config.flake.modules.nixos; [
+      wm-niri
+      # de-shell # No de-shell nixos module yet
+    ];
+  };
+
+  flake.modules.homeManager.de-discrete = _: {
+    imports = with config.flake.modules.homeManager; [
+      wm-niri
+      de-shell
+    ];
+  };
+}
modules/desktop/shell/niri/greeter.nix → modules/desktop/desktop-environment/discrete/greeter.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.niri = _: {
+  flake.modules.nixos.de-discrete = _: {
     programs.regreet = {
       enable = true;
       font.size = 24;
modules/desktop/shell/niri/secret-store.nix → modules/desktop/desktop-environment/discrete/secret-store.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.niri = _: {
+  flake.modules.nixos.de-discrete = _: {
     services.gnome.gnome-keyring = {
       enable = true;
     };
modules/desktop/shell/niri/xdg-portal.nix → modules/desktop/desktop-environment/discrete/xdg-portal.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.niri = {pkgs, ...}: {
+  flake.modules.nixos.de-discrete = {pkgs, ...}: {
     xdg.portal = {
       enable = true;
       extraPortals = [
modules/desktop/shell/plasma6/options/appearance.nix → modules/desktop/desktop-environment/plasma6/options/appearance.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.plasma6 = {
+  flake.modules.homeManager.de-plasma6 = {
     programs.plasma = {
       workspace = {
         theme = "default";
modules/desktop/shell/plasma6/options/configs.nix → modules/desktop/desktop-environment/plasma6/options/configs.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.plasma6 = _: {
+  flake.modules.homeManager.de-plasma6 = _: {
     programs.plasma.configFile = {
       kdeglobals = {
         General = {
modules/desktop/shell/plasma6/options/powerdevil.nix → modules/desktop/desktop-environment/plasma6/options/powerdevil.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.plasma6 = _: {
+  flake.modules.homeManager.de-plasma6 = _: {
     # AC is compatible for all hosts
     programs.plasma.powerdevil.AC = {
       powerProfile = "performance";
modules/desktop/shell/plasma6/options/shortcuts.nix → modules/desktop/desktop-environment/plasma6/options/shortcuts.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.homeManager.plasma6 = _: {
+  flake.modules.homeManager.de-plasma6 = _: {
     programs.plasma = {
       shortcuts = {
         "services/com.mitchellh.ghostty.desktop"._launch = "Meta+`";
modules/desktop/shell/plasma6/default.nix → modules/desktop/desktop-environment/plasma6/default.nix
@@ -1,5 +1,5 @@
 {inputs, ...}: {
-  flake.modules.nixos.plasma6 = _: {
+  flake.modules.nixos.de-plasma6 = _: {
     services = {
       xserver.enable = true;
       displayManager.defaultSession = "plasma";
@@ -7,7 +7,7 @@
     };
   };
 
-  flake.modules.homeManager.plasma6 = _: {
+  flake.modules.homeManager.de-plasma6 = _: {
     imports = [
       inputs.plasma-manager.homeModules.plasma-manager
     ];
modules/desktop/shell/plasma6/misc.nix → modules/desktop/desktop-environment/plasma6/misc.nix
@@ -1,5 +1,5 @@
 {
-  flake.modules.nixos.plasma6 = _: {
+  flake.modules.nixos.de-plasma6 = _: {
     security.pam.services.hpcesia.kwallet.enable = true;
   };
 }
modules/desktop/shell/plasma6/sddm.nix → modules/desktop/desktop-environment/plasma6/sddm.nix
@@ -3,7 +3,7 @@
   lib,
   ...
 }: {
-  flake.modules.nixos.plasma6 = {pkgs, ...}: let
+  flake.modules.nixos.de-plasma6 = {pkgs, ...}: let
     sddm-theme = inputs.silentSDDM.packages.${pkgs.system}.default.override {
       theme = "catppuccin-macchiato";
     };
modules/desktop/shell/default.nix → modules/desktop/desktop-environment/default.nix
@@ -2,15 +2,15 @@
   # Import manually to switch desktop environment.
   flake.modules.nixos.desktop = {
     imports = with config.flake.modules.nixos; [
-      # plasma6
-      niri
+      # de-plasma
+      de-discrete
     ];
   };
 
   flake.modules.homeManager.desktop = {
     imports = with config.flake.modules.homeManager; [
-      # plasma6
-      niri
+      # de-plasma
+      de-discrete
     ];
   };
 }
modules/desktop/shell/niri/appearance/default.nix
@@ -1,7 +0,0 @@
-{
-  flake.modules.homeManger.niri = _: {
-    programs.niri.settings = {
-      prefer-no-csd = true;
-    };
-  };
-}
modules/desktop/shell/niri/noctalia.nix
@@ -1,98 +0,0 @@
-{
-  flake.modules.homeManager.niri = {config, ...}: {
-    programs.noctalia-shell = {
-      settings = {
-        ui = {
-          fontDefault = config.stylix.fonts.sansSerif.name;
-          fontFixed = config.stylix.fonts.monospace.name;
-        };
-        general = {
-          avatarImage = "${config.home.homeDirectory}/.face";
-          radiusRatio = 0.75;
-          screenRadiusRatio = 0.5;
-        };
-        wallpaper = {
-          enabled = true;
-          defaultWallpaper = config.stylix.image;
-        };
-        appLauncher = {
-          backgroundOpacity = config.stylix.opacity.popups;
-          enableClipboardHistory = true;
-          terminalCommand = "ghostty -e";
-        };
-        location.name = "重庆, 中国";
-        screenRecorder.directory = config.xdg.userDirs.videos;
-        bar = {
-          backgroundOpacity = config.stylix.opacity.desktop;
-          density = "comfortable";
-          floating = true;
-          marginHorizontal = 0.4;
-          marginVertical = 0.4;
-          widgets = {
-            center = [
-              {
-                id = "Workspace";
-                hideUnoccupied = true;
-                labelMode = "index";
-              }
-            ];
-            left = [
-              {
-                id = "ControlCenter";
-                useDistroLogo = true;
-              }
-              {id = "SystemMonitor";}
-              {id = "ActiveWindow";}
-              {
-                id = "MediaMini";
-                autoHide = true;
-                showAlbumArt = true;
-                showVisualizer = true;
-                visualizerType = "linear";
-              }
-            ];
-            right = [
-              {id = "ScreenRecorder";}
-              {
-                id = "Tray";
-                blacklist = ["Bluetooth *"]; # I don't want double bluetooth applet.
-              }
-              {
-                id = "NotificationHistory";
-                hideWhenZero = true;
-                showUnreadBadge = true;
-              }
-              {id = "WiFi";}
-              {id = "Bluetooth";}
-              {id = "Volume";}
-              {id = "Brightness";}
-              {id = "Battery";}
-              {
-                id = "Clock";
-                formatHorizontal = "yyyy年M月d日 HH:mm";
-                formatVertical = "yyyy年M月d日 dddd-AP HH:mm:ss";
-              }
-            ];
-          };
-        };
-      };
-    };
-
-    programs.noctalia-shell.colors = {
-      mPrimary = config.lib.stylix.colors.base0E;
-      mOnPrimary = config.lib.stylix.colors.base11;
-      mSecondary = config.lib.stylix.colors.base09;
-      mOnSecondary = config.lib.stylix.colors.base11;
-      mTertiary = config.lib.stylix.colors.base15;
-      mOnTertiary = config.lib.stylix.colors.base11;
-      mError = config.lib.stylix.colors.base08;
-      mOnError = config.lib.stylix.colors.base11;
-      mSurface = config.lib.stylix.colors.base00;
-      mOnSurface = config.lib.stylix.colors.base05;
-      mSurfaceVariant = config.lib.stylix.colors.base02;
-      mOnSurfaceVariant = config.lib.stylix.colors.base04;
-      mOutline = config.lib.stylix.colors.base03;
-      mShadow = config.lib.stylix.colors.base11;
-    };
-  };
-}