Commit a2da893

HPCesia <me@hpcesia.com>
2026-06-19 05:32:08
Add desktop style control
1 parent a511fd7
Changed files (7)
modules/desktop/style/cursor.nix
@@ -0,0 +1,40 @@
+{lib, ...}: {
+  den.aspects.desktop.style.cursor = {
+    settings = {
+      name = lib.mkOption {
+        type = lib.types.str;
+        default = "Bibata-Modern-Classic";
+      };
+      package = lib.mkOption {
+        type = lib.types.functionTo lib.types.package;
+        default = pkgs: pkgs.bibata-cursors;
+      };
+      size = lib.mkOption {
+        type = lib.types.ints.positive;
+        default = 24;
+      };
+    };
+
+    nixos = {host, ...}: {
+      environment.variables.XCURSOR_SIZE = toString host.settings.desktop.style.cursor.size;
+    };
+
+    homeManager = {
+      host,
+      pkgs,
+      ...
+    }: let
+      cfg = host.settings.desktop.style.cursor;
+    in {
+      home.pointerCursor = {
+        enable = true;
+
+        inherit (cfg) name;
+        package = cfg.package pkgs;
+        size = builtins.floor (cfg.size + 0.5);
+        x11.enable = true;
+        gtk.enable = true;
+      };
+    };
+  };
+}
modules/desktop/style/fonts.nix
@@ -0,0 +1,98 @@
+{lib, ...}: {
+  den.aspects.desktop.style.fonts = {
+    settings = let
+      inherit (lib) mkOption types;
+
+      fontType = types.submodule {
+        options = {
+          name = mkOption {
+            type = types.str;
+          };
+          package = mkOption {
+            type = types.functionTo types.package;
+            example = lib.literalExpression "pkgs: pkgs.dejavu_fonts";
+          };
+        };
+      };
+    in {
+      sizes = {
+        applications = mkOption {
+          type = types.ints.positive;
+          default = 12;
+        };
+        desktop = mkOption {
+          type = types.ints.positive;
+          default = 12;
+        };
+        terminal = mkOption {
+          type = types.ints.positive;
+          default = 12;
+        };
+      };
+      serif = mkOption {
+        type = types.listOf fontType;
+        default = [
+          {
+            name = "Noto Serif CJK SC";
+            package = pkgs: pkgs.noto-fonts-cjk-serif;
+          }
+        ];
+      };
+      sansSerif = mkOption {
+        type = types.listOf fontType;
+        default = [
+          {
+            name = "Sarasa Gothic SC";
+            package = pkgs: pkgs.sarasa-gothic;
+          }
+          {
+            name = "Noto Sans CJK SC";
+            package = pkgs: pkgs.noto-fonts-cjk-sans;
+          }
+        ];
+      };
+      monospace = mkOption {
+        type = types.listOf fontType;
+        default = [
+          {
+            name = "Maple Mono NF CN";
+            package = pkgs: pkgs.maple-mono.NF-CN;
+          }
+        ];
+      };
+      emoji = mkOption {
+        type = types.listOf fontType;
+        default = [
+          {
+            name = "Noto Color Emoji";
+            package = pkgs: pkgs.noto-fonts-color-emoji;
+          }
+        ];
+      };
+    };
+
+    nixos = {
+      host,
+      pkgs,
+      ...
+    }: let
+      cfg = host.settings.desktop.style.fonts;
+    in {
+      fonts = {
+        enableDefaultPackages = false;
+        fontDir.enable = true;
+
+        packages =
+          (map (x: x.package pkgs)
+            (lib.concatMap (x: cfg.${x}) ["serif" "sansSerif" "monospace" "emoji"]))
+          ++ (with pkgs; [
+            dejavu_fonts
+            noto-fonts-lgc-plus
+          ]);
+        fontconfig.defaultFonts =
+          lib.genAttrs ["serif" "sansSerif" "monospace" "emoji"]
+          (x: lib.unique (map (x: x.name) cfg.${x}));
+      };
+    };
+  };
+}
modules/desktop/style/gtk.nix
@@ -0,0 +1,50 @@
+{den, ...}: {
+  den.aspects.desktop.style.gtk = {
+    includes = [
+      den.aspects.desktop.style.fonts
+    ];
+
+    nixos = {
+      programs.dconf.enable = true;
+    };
+
+    homeManager = {
+      host,
+      pkgs,
+      config,
+      ...
+    }: let
+      style = host.settings.desktop.style;
+    in {
+      gtk = {
+        enable = true;
+        colorScheme = "dark";
+        font = {
+          inherit (builtins.elemAt style.fonts.sansSerif 0) name;
+          size = style.fonts.sizes.applications;
+        };
+        theme = {
+          package = pkgs.adw-gtk3;
+          name = "adw-gtk3";
+        };
+        gtk4.theme = config.gtk.theme;
+      };
+    };
+  };
+
+  den.aspects.desktop.style.gtk.themes = {
+    catppuccin = {
+      homeManager = {pkgs, ...}: let
+        adw-color-catppuccin-mocha-mauve = pkgs.fetchurl {
+          url = "https://github.com/claymorwan/catppuccin/raw/54f7393990e672d3648c1bc8c4cc6d26e6bde852/adw/themes/mocha/catppuccin-mocha-mauve.css";
+          hash = "sha256-sj36YMvkpRym6FgzQzHuG0K8Nq/t/RHTZpxDdBiQybY=";
+        };
+      in {
+        xdg.configFile = {
+          "gtk-3.0/gtk.css".source = adw-color-catppuccin-mocha-mauve;
+          "gtk-4.0/gtk.css".source = adw-color-catppuccin-mocha-mauve;
+        };
+      };
+    };
+  };
+}
modules/desktop/style/icon.nix
@@ -0,0 +1,33 @@
+{lib, ...}: {
+  den.aspects.desktop.style.icon = {
+    settings = {
+      name = lib.mkOption {
+        type = lib.types.str;
+        default = "WhiteSur";
+      };
+      package = lib.mkOption {
+        type = lib.types.functionTo lib.types.package;
+        default = pkgs:
+          pkgs.whitesur-icon-theme.override {
+            boldPanelIcons = true;
+            alternativeIcons = true;
+          };
+      };
+    };
+
+    homeManager = {
+      host,
+      pkgs,
+      ...
+    }: let
+      cfg = host.settings.desktop.style.icon;
+    in {
+      gtk = {
+        iconTheme = {
+          inherit (cfg) name;
+          package = cfg.package pkgs;
+        };
+      };
+    };
+  };
+}
modules/desktop/style/qt.nix
@@ -0,0 +1,31 @@
+{lib, ...}: {
+  den.aspects.desktop.style.qt = {
+    nixos = {
+      qt = {
+        enable = true;
+        platformTheme = "qt5ct";
+      };
+    };
+
+    homeManager = {
+      qt = {
+        enable = true;
+        platformTheme.name = "qtct";
+      };
+    };
+  };
+
+  den.aspects.desktop.style.qt.themes = {
+    catppuccin = {
+      homeManager = {pkgs, ...}: {
+        qt = lib.genAttrs' ["qt5ct" "qt6ct"] (s:
+          lib.nameValuePair "${s}Settings" {
+            Appearance = {
+              custom_palette = true;
+              color_scheme_path = "${pkgs.catppuccin-qt5ct}/share/${s}/colors/catppuccin-mocha-mauve.conf";
+            };
+          });
+      };
+    };
+  };
+}
modules/hosts/kevin/hardware.nix
@@ -1,4 +1,14 @@
 {
+  den.hosts.kevin.settings = {
+    desktop.style = {
+      fonts.sizes = {
+        applications = 13;
+        desktop = 13;
+        terminal = 13;
+      };
+    };
+  };
+
   den.aspects.kevin = {
     nixos = {
       hardware.facter.reportPath = ./facter.json;
modules/roles/desktop.nix
@@ -1,6 +1,12 @@
 {den, ...}: {
   den.aspects.roles.desktop = {
     includes = with den.aspects; [
+      desktop.style.cursor
+      desktop.style.fonts
+      desktop.style.gtk
+      desktop.style.icon
+      desktop.style.qt
+
       desktop.power-management
       desktop.xdg-user-dirs
       desktop.yubikey