OFFSET偏移
← All articlesOFFSET / FIELD NOTESNO. 035

Desktop and theme configuration with Home Manager

Separate system-session and user-appearance responsibilities when configuring Hyprland, Plasma, and GTK.

English translation · Code and commands follow the Chinese original.

IN THESE READING PATHSHome Manager: managing user configuration ↗
About 2 min readStart reading

Division of responsibilities: system layer vs. user layer#

  • System layer (NixOS): installs base packages, enables the display manager (SDDM/GDM), and loads drivers.
  • User layer (Home Manager): sets the wallpaper, desktop shortcuts, font sizes, and taskbar layout.

Hands-on: declarative Hyprland configuration#

On NixOS, you do not even need to edit hyprland.conf manually.

{
  wayland.windowManager.hyprland = {
    enable = true;
    settings = {
      # 这里就是原生的 hyprland 配置,只不过写成了 Nix 语法
      monitor = ",preferred,auto,auto";
      "$mod" = "SUPER";
      bind = [
        "$mod, RETURN, exec, kitty"
        "$mod, Q, killactive"
      ];
      decoration = {
        rounding = 10;
        blur.enabled = true;
      };
    };
  };
}

Consistent styling: KDE Plasma#

KDE has a large and intricate set of configuration options. If you want to bring all its settings into Nix, you can use plasma-manager.

# 先在 Flake 输入中引入 plasma-manager,
# 并将 inputs.plasma-manager.homeManagerModules.plasma-manager 加入 HM imports/modules。
# 在 home.nix 中:
{
  programs.plasma = {
    enable = true;
    workspace = {
      theme = "breeze-dark";
      lookAndFeel = "org.kde.breezedark.desktop";
    };
    panels = [
      {
        location = "bottom";
        height = 36;
        widgets = [
          "org.kde.plasma.kickoff"
          "org.kde.plasma.icontasks"
          "org.kde.plasma.systemtray"
          "org.kde.plasma.digitalclock"
        ];
      }
    ];
  };
}

Fonts and themes (GTK/Qt)#

Giving GTK and Qt a consistent appearance is important.

{ pkgs, ... }: {
  gtk = {
    enable = true;
    theme = {
      name = "Adwaita-dark";
      package = pkgs.gnome-themes-extra;
    };
    cursorTheme = {
      name = "Adwaita";
      package = pkgs.adwaita-icon-theme;
    };
  };

  qt = {
    enable = true;
    platformTheme.name = "gtk";
    style.name = "adwaita-dark";
  };
}

Advice for going further#

Do not get too absorbed in configuring every pixel at this stage. Start with a usable environment, then gradually bring individual settings into Nix as you use it day to day.

Module and version prerequisites#

Home Manager's Hyprland configuration does not replace system-level session, permission, and portal configuration. Check desktop-theme examples against your pinned Home Manager, Hyprland, and plasma-manager versions; also verify the GTK/Qt appearance in an actual session.

References & further reading

  1. Home Manager Manual ↗
  2. Home Manager command source code ↗
  3. Home Manager file-option source code ↗
  4. plasma-manager upstream ↗

Adapted from technical notes. Examples use generic names.

Continue along a reading path

Home Manager: managing user configuration

  1. 01Home Manager integration and modular configuration
  2. 02Configuring a terminal environment with Home Manager
  3. 03Desktop and theme configuration with Home Manager
  4. 04Home Manager files and symbolic links
  5. 05Secrets management with Home Manager and NixOS
  6. 06A tutorial on user-level configuration with Home Manager
CONTINUE READING / NEXT ARTICLEHome Manager files and symbolic links

Use home.file and XDG file options to manage read-only configuration and directory links.