main
 1{lib, ...}: {
 2  den.aspects.desktop.aesthetic.qt = {
 3    nixos = {
 4      qt = {
 5        enable = true;
 6        platformTheme = "qt5ct";
 7      };
 8    };
 9
10    provides.to-users.hjem = {
11      host,
12      pkgs,
13      ...
14    }: let
15      fonts = host.settings.desktop.aesthetic.fonts;
16      icon = host.settings.desktop.aesthetic.icon;
17
18      qtctFormat = pkgs.formats.ini {
19        listToValue = values: lib.concatStringsSep ", " values;
20      };
21
22      qtctConf = {
23        Appearance =
24          lib.optionalAttrs (icon.name != null) {icon_theme = icon.name;};
25        Fonts = {
26          fixed = ''"${(lib.head fonts.monospace).name},${toString fonts.size}"'';
27          general = ''"${(lib.head fonts.sansSerif).name},${toString fonts.size}"'';
28        };
29      };
30    in {
31      packages = [
32        pkgs.libsForQt5.qt5ct
33        pkgs.qt6Packages.qt6ct
34      ];
35
36      xdg.config.files = {
37        "qt5ct/qt5ct.conf" = {
38          type = "symlink";
39          generator = qtctFormat.generate "qt5ct-config";
40          value = qtctConf;
41        };
42        "qt6ct/qt6ct.conf" = {
43          type = "symlink";
44          generator = qtctFormat.generate "qt6ct-config";
45          value = qtctConf;
46        };
47      };
48
49      environment.sessionVariables.QT_QPA_PLATFORMTHEME = "qt5ct";
50    };
51  };
52
53  den.aspects.desktop.aesthetic.qt.themes = {
54    catppuccin = {
55      hjem = {pkgs, ...}: let
56        qtctThemeConf = s: {
57          Appearance = {
58            custom_palette = true;
59            color_scheme_path = "${pkgs.catppuccin-qt5ct}/share/${s}/colors/catppuccin-mocha-mauve.conf";
60          };
61        };
62      in {
63        xdg.config.files = {
64          "qt5ct/qt5ct.conf".value = qtctThemeConf "qt5ct";
65          "qt6ct/qt6ct.conf".value = qtctThemeConf "qt6ct";
66        };
67
68        xdg.data.files."color-schemes".source = pkgs.fetchzip {
69          name = "Catppuccin-KDE-Mocha-color-schemes";
70          url = "https://github.com/catppuccin/kde/releases/download/v0.3.1/Mocha-color-schemes.tar.gz";
71          hash = "sha256-HlinXVRAPLKMGe+Puf91beYerdpfY7mbLX1SsNDXRho=";
72        };
73      };
74    };
75  };
76}