# Hyprland desktop, both halves of one feature: # NixOS UWSM-managed compositor, SDDM with autologin of the owner, # portals, keyring and the small services a desktop needs. # home-manager the user configuration. Hyprland reads Lua: the real config # is in the .lua files next to this file; Nix only passes in the # values that come from elsewhere (`require("nixvars")`). # The NixOS half adds the home-manager half to the owner, so a host imports # `nixos.hyprland` once. Noctalia, audio and fonts are separate aspects. { config, ... }: let inherit (config.meta) owner; hmHyprland = config.flake.modules.homeManager.hyprland; in { flake.modules.nixos.hyprland = { pkgs, ... }: { home-manager.users.${owner.name}.imports = [ hmHyprland ]; # package/portalPackage stay default: the overlay swaps in the flake builds. programs.hyprland = { enable = true; withUWSM = true; xwayland.enable = true; }; services.displayManager.sddm = { enable = true; wayland.enable = true; settings.Autologin = { Session = "hyprland.desktop"; User = owner.name; }; }; xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-hyprland ]; security.polkit.enable = true; services.gnome.gnome-keyring.enable = true; programs.dconf.enable = true; # Electron/Chromium apps use native Wayland. environment.sessionVariables.NIXOS_OZONE_WL = "1"; # Removable drives and trash/mounts in the file manager. services.udisks2.enable = true; services.gvfs.enable = true; hardware.bluetooth = { enable = true; powerOnBoot = true; }; environment.systemPackages = with pkgs; [ wl-clipboard cliphist grim slurp brightnessctl playerctl pavucontrol kdePackages.dolphin kdePackages.dolphin-plugins hyprpicker ]; }; flake.modules.homeManager.hyprland = { config, lib, pkgs, osConfig, ... }: let cursor = config.home.pointerCursor; # Exposed to the Lua files as `require("nixvars")`. Keyboard layouts come # from the NixOS configuration (services.xserver.xkb, set by the host), # the cursor from home-manager (set by Stylix, theme/stylix.nix). nixVars = { kbLayout = osConfig.services.xserver.xkb.layout; kbOptions = osConfig.services.xserver.xkb.options; terminal = "wezterm"; fileManager = "dolphin"; cursorSize = if cursor.enable then cursor.size else 24; cursorTheme = if cursor.enable then cursor.name else ""; }; in { wayland.windowManager.hyprland = { enable = true; configType = "lua"; # The NixOS half (programs.hyprland) installs the compositor and the # portal, built from the flake overlay. Installing them again here would # put a second copy in the user profile. package = null; portalPackage = null; # UWSM owns the session and graphical-session.target; HM's own # hyprland-session.target and dbus import would only duplicate that. systemd.enable = false; xwayland.enable = true; # Loaded in name order; `nixvars` is a helper module, not loaded on its # own. Stylix's colours are rendered after these files (hl.config in # hyprland.lua), so they override the colours in settings.lua. extraLuaFiles = { nixvars = { content = "return ${lib.generators.toLua { } nixVars}\n"; autoLoad = false; }; "10-settings" = ./settings.lua; "20-binds" = ./binds.lua; "30-rules" = ./rules.lua; }; }; # Tools the binds call (screenshots, file manager). home.packages = with pkgs; [ grim slurp wl-clipboard kdePackages.dolphin kdePackages.dolphin-plugins ]; }; }