From 94bd0d81f5ca0210c4790d005a7b61668b33425d Mon Sep 17 00:00:00 2001
From: matt1432 <matt@nelim.org>
Date: Mon, 5 Aug 2024 16:23:53 -0400
Subject: [PATCH] refactor(desktop): place all theming config in same folder

---
 nixosModules/desktop/environment/default.nix  |  2 +-
 .../desktop/environment/home/style.nix        | 57 -------------------
 .../desktop/environment/modules/packages.nix  |  2 +-
 nixosModules/desktop/home/theme/default.nix   | 48 ----------------
 nixosModules/desktop/manager/hyprland.nix     |  2 +-
 nixosModules/desktop/theme/cursors.nix        | 41 +++++++++++++
 nixosModules/desktop/theme/default.nix        | 42 ++++++++++++++
 .../theme/gtk.nix => theme/gtk/default.nix}   |  2 +-
 .../{home/theme => theme/gtk}/gradience.nix   |  0
 .../desktop/{home => theme}/hyprpaper.nix     |  0
 nixosModules/desktop/{home => }/theme/qt.nix  |  3 +-
 nixosModules/desktop/theme/xresources.nix     | 23 ++++++++
 12 files changed, 112 insertions(+), 110 deletions(-)
 delete mode 100644 nixosModules/desktop/environment/home/style.nix
 delete mode 100644 nixosModules/desktop/home/theme/default.nix
 create mode 100644 nixosModules/desktop/theme/cursors.nix
 create mode 100644 nixosModules/desktop/theme/default.nix
 rename nixosModules/desktop/{home/theme/gtk.nix => theme/gtk/default.nix} (98%)
 rename nixosModules/desktop/{home/theme => theme/gtk}/gradience.nix (100%)
 rename nixosModules/desktop/{home => theme}/hyprpaper.nix (100%)
 rename nixosModules/desktop/{home => }/theme/qt.nix (94%)
 create mode 100644 nixosModules/desktop/theme/xresources.nix

diff --git a/nixosModules/desktop/environment/default.nix b/nixosModules/desktop/environment/default.nix
index 88adcdbf..d442480b 100644
--- a/nixosModules/desktop/environment/default.nix
+++ b/nixosModules/desktop/environment/default.nix
@@ -76,7 +76,7 @@ in {
         (import ./home/hyprgrass.nix hyprgrass)
 
         ./home/inputs.nix
-        (import ./home/style.nix self)
+        (import ../theme self)
       ];
 
       wayland.windowManager.hyprland = {
diff --git a/nixosModules/desktop/environment/home/style.nix b/nixosModules/desktop/environment/home/style.nix
deleted file mode 100644
index 0ca8b322..00000000
--- a/nixosModules/desktop/environment/home/style.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-self: {
-  config,
-  lib,
-  pkgs,
-  ...
-}: {
-  imports = [
-    (import ../../home/theme self)
-    (import ../../home/hyprpaper.nix self)
-  ];
-
-  config = let
-    inherit (lib) mkIf;
-
-    cursorTheme = self.legacyPackages.${pkgs.system}.dracula.hyprcursor;
-    cursorThemeName = "Dracula-cursors";
-    hyprcursorThemeName = "Dracula-hyprcursor";
-    cursorSize = "24";
-  in {
-    home.file.".local/share/icons/${hyprcursorThemeName}".source = cursorTheme;
-
-    wayland.windowManager.hyprland = {
-      settings =
-        {
-          envd = [
-            "XCURSOR_THEME, ${cursorThemeName}"
-            "XCURSOR_SIZE, ${cursorSize}"
-          ];
-
-          exec-once = [
-            "hyprctl setcursor ${hyprcursorThemeName} ${cursorSize}"
-          ];
-
-          windowrule = [
-            "size 1231 950,title:^(Open Folder)$"
-            "float,title:^(Open Folder)$"
-
-            "size 1231 950,title:^(Open File)$"
-            "float,title:^(Open File)$"
-          ];
-
-          layerrule = [
-            "noanim, selection"
-          ];
-        }
-        // (
-          mkIf (config.home.username != "greeter") {
-            # This file should only be used for theming
-            source = ["${config.vars.configDir}/hypr/main.conf"];
-          }
-        );
-    };
-  };
-
-  # For accurate stack trace
-  _file = ./style.nix;
-}
diff --git a/nixosModules/desktop/environment/modules/packages.nix b/nixosModules/desktop/environment/modules/packages.nix
index 3f4ba255..f92c0dc6 100644
--- a/nixosModules/desktop/environment/modules/packages.nix
+++ b/nixosModules/desktop/environment/modules/packages.nix
@@ -43,7 +43,7 @@ in {
 
         ({config, ...}: let
           symlink = config.lib.file.mkOutOfStoreSymlink;
-          configDir = "${flakeDir}/nixosModules/desktop/desktop-environment/config";
+          configDir = "${flakeDir}/nixosModules/desktop/environment/config";
         in {
           xdg = {
             configFile = {
diff --git a/nixosModules/desktop/home/theme/default.nix b/nixosModules/desktop/home/theme/default.nix
deleted file mode 100644
index 52d09d3b..00000000
--- a/nixosModules/desktop/home/theme/default.nix
+++ /dev/null
@@ -1,48 +0,0 @@
-self: {pkgs, ...}: {
-  imports = [
-    ./gtk.nix
-    (import ./qt.nix self)
-  ];
-
-  config = let
-    inherit (self.legacyPackages.${pkgs.system}) dracula;
-  in {
-    home.pointerCursor = {
-      name = "Dracula-cursors";
-      package = dracula.gtk;
-      size = 24;
-
-      gtk.enable = true;
-
-      x11 = {
-        enable = true;
-        defaultCursor = "Dracula-cursors";
-      };
-    };
-
-    xresources.extraConfig = ''
-      ! Dracula Xresources palette
-      *.foreground: #F8F8F2
-      *.background: #282A36
-      *.color0:     #000000
-      *.color8:     #4D4D4D
-      *.color1:     #FF5555
-      *.color9:     #FF6E67
-      *.color2:     #50FA7B
-      *.color10:    #5AF78E
-      *.color3:     #F1FA8C
-      *.color11:    #F4F99D
-      *.color4:     #BD93F9
-      *.color12:    #CAA9FA
-      *.color5:     #FF79C6
-      *.color13:    #FF92D0
-      *.color6:     #8BE9FD
-      *.color14:    #9AEDFE
-      *.color7:     #BFBFBF
-      *.color15:    #E6E6E6
-    '';
-  };
-
-  # For accurate stack trace
-  _file = ./default.nix;
-}
diff --git a/nixosModules/desktop/manager/hyprland.nix b/nixosModules/desktop/manager/hyprland.nix
index 8b307360..7dd0fd48 100644
--- a/nixosModules/desktop/manager/hyprland.nix
+++ b/nixosModules/desktop/manager/hyprland.nix
@@ -25,7 +25,7 @@ self: {
   in {
     home-manager.users.greeter = {
       imports = [
-        (import ../environment/home/style.nix self)
+        (import ../theme self)
       ];
 
       wayland.windowManager.hyprland = {
diff --git a/nixosModules/desktop/theme/cursors.nix b/nixosModules/desktop/theme/cursors.nix
new file mode 100644
index 00000000..c38b6ac7
--- /dev/null
+++ b/nixosModules/desktop/theme/cursors.nix
@@ -0,0 +1,41 @@
+self: {pkgs, ...}: {
+  config = let
+    inherit (self.legacyPackages.${pkgs.system}) dracula;
+
+    cursorTheme = dracula.hyprcursor;
+    cursorThemeName = "Dracula-cursors";
+    hyprcursorThemeName = "Dracula-hyprcursor";
+    cursorSize = 24;
+  in {
+    home.pointerCursor = {
+      name = cursorThemeName;
+      package = dracula.gtk;
+      size = cursorSize;
+
+      gtk.enable = true;
+
+      x11 = {
+        enable = true;
+        defaultCursor = cursorThemeName;
+      };
+    };
+
+    home.file.".local/share/icons/${hyprcursorThemeName}".source = cursorTheme;
+
+    wayland.windowManager.hyprland = {
+      settings = {
+        envd = [
+          "XCURSOR_THEME, ${cursorThemeName}"
+          "XCURSOR_SIZE, ${toString cursorSize}"
+        ];
+
+        exec-once = [
+          "hyprctl setcursor ${hyprcursorThemeName} ${toString cursorSize}"
+        ];
+      };
+    };
+  };
+
+  # For accurate stack trace
+  _file = ./cursors.nix;
+}
diff --git a/nixosModules/desktop/theme/default.nix b/nixosModules/desktop/theme/default.nix
new file mode 100644
index 00000000..11c9a5d1
--- /dev/null
+++ b/nixosModules/desktop/theme/default.nix
@@ -0,0 +1,42 @@
+self: {
+  config,
+  lib,
+  ...
+}: let
+  inherit (lib) mkIf;
+in {
+  imports = [
+    ./gtk
+    ./xresources.nix
+
+    (import ./cursors.nix self)
+    (import ./qt.nix self)
+    (import ./hyprpaper.nix self)
+  ];
+
+  config.wayland.windowManager.hyprland = {
+    settings =
+      {
+        windowrule = [
+          "size 1231 950,title:^(Open Folder)$"
+          "float,title:^(Open Folder)$"
+
+          "size 1231 950,title:^(Open File)$"
+          "float,title:^(Open File)$"
+        ];
+
+        layerrule = [
+          "noanim, selection"
+        ];
+      }
+      // (
+        mkIf (config.home.username != "greeter") {
+          # This file should only be used for theming
+          source = ["${config.vars.configDir}/hypr/main.conf"];
+        }
+      );
+  };
+
+  # For accurate stack trace
+  _file = ./default.nix;
+}
diff --git a/nixosModules/desktop/home/theme/gtk.nix b/nixosModules/desktop/theme/gtk/default.nix
similarity index 98%
rename from nixosModules/desktop/home/theme/gtk.nix
rename to nixosModules/desktop/theme/gtk/default.nix
index 2cc0f408..916897e3 100644
--- a/nixosModules/desktop/home/theme/gtk.nix
+++ b/nixosModules/desktop/theme/gtk/default.nix
@@ -65,5 +65,5 @@
   };
 
   # For accurate stack trace
-  _file = ./gtk.nix;
+  _file = ./default.nix;
 }
diff --git a/nixosModules/desktop/home/theme/gradience.nix b/nixosModules/desktop/theme/gtk/gradience.nix
similarity index 100%
rename from nixosModules/desktop/home/theme/gradience.nix
rename to nixosModules/desktop/theme/gtk/gradience.nix
diff --git a/nixosModules/desktop/home/hyprpaper.nix b/nixosModules/desktop/theme/hyprpaper.nix
similarity index 100%
rename from nixosModules/desktop/home/hyprpaper.nix
rename to nixosModules/desktop/theme/hyprpaper.nix
diff --git a/nixosModules/desktop/home/theme/qt.nix b/nixosModules/desktop/theme/qt.nix
similarity index 94%
rename from nixosModules/desktop/home/theme/qt.nix
rename to nixosModules/desktop/theme/qt.nix
index 945db7c9..60456353 100644
--- a/nixosModules/desktop/home/theme/qt.nix
+++ b/nixosModules/desktop/theme/qt.nix
@@ -11,11 +11,12 @@ self: {
   in {
     home.packages = with pkgs; [
       libsForQt5.qtstyleplugin-kvantum
-      qt6Packages.qtstyleplugin-kvantum
+      kdePackages.qtstyleplugin-kvantum
     ];
 
     qt = {
       enable = true;
+      style.name = "kvantum";
       platformTheme.name = "qtct";
     };
 
diff --git a/nixosModules/desktop/theme/xresources.nix b/nixosModules/desktop/theme/xresources.nix
new file mode 100644
index 00000000..16bff955
--- /dev/null
+++ b/nixosModules/desktop/theme/xresources.nix
@@ -0,0 +1,23 @@
+{...}: {
+  xresources.extraConfig = ''
+    ! Dracula Xresources palette
+    *.foreground: #F8F8F2
+    *.background: #282A36
+    *.color0:     #000000
+    *.color8:     #4D4D4D
+    *.color1:     #FF5555
+    *.color9:     #FF6E67
+    *.color2:     #50FA7B
+    *.color10:    #5AF78E
+    *.color3:     #F1FA8C
+    *.color11:    #F4F99D
+    *.color4:     #BD93F9
+    *.color12:    #CAA9FA
+    *.color5:     #FF79C6
+    *.color13:    #FF92D0
+    *.color6:     #8BE9FD
+    *.color14:    #9AEDFE
+    *.color7:     #BFBFBF
+    *.color15:    #E6E6E6
+  '';
+}