Files
moonix/modules/desktop.nix
T
nevaforget d9d616c45d Fix niri config discovery, polkit path, wallpaper stack
- NIRI_CONFIG points niri at /etc/xdg; without it niri writes its own
  default config, so none of the Moonarch settings applied.
- config.kdl spawns the polkit agent by FHS path, provided via tmpfiles
  instead of diverging the config shared with Arch.
- waypaper was missing entirely, hence no wallpaper. It invokes swww,
  which the maintained awww provides under a different name.
2026-08-07 13:17:46 +02:00

212 lines
6.0 KiB
Nix

# ABOUTME: Deploys the Moonarch XDG configs and desktop package set.
# ABOUTME: Counterpart to the package() function in moonarch-git/PKGBUILD.
{ pkgs, lib, moonarchSrc, moonarchPkgs, ... }:
let
xdg = "${moonarchSrc}/defaults/xdg";
etc = "${moonarchSrc}/defaults/etc";
# The moonarch-* helper scripts from defaults/bin, installed as a single
# package. Counterpart to `install -Dm755 defaults/bin/moonarch-* -t /usr/bin/`.
# waypaper calls `swww`/`swww-daemon`, but the maintained successor ships as
# `awww`. Same compatibility symlinks the Arch package creates.
swww-compat = pkgs.runCommand "swww-compat" { } ''
mkdir -p "$out/bin"
ln -s ${pkgs.awww}/bin/awww "$out/bin/swww"
ln -s ${pkgs.awww}/bin/awww-daemon "$out/bin/swww-daemon"
'';
moonarch-scripts = pkgs.stdenv.mkDerivation {
pname = "moonarch-scripts";
version = "0-unstable";
src = moonarchSrc;
dontBuild = true;
installPhase = ''
runHook preInstall
install -Dm755 defaults/bin/moonarch-* -t "$out/bin/"
runHook postInstall
'';
meta.description = "Moonarch helper scripts for Waybar, power and devices";
};
in
{
# --- XDG configs -> /etc/xdg/ ---
#
# Deployed verbatim from the moonarch repo; defaults/ stays the single
# source of truth for both distros.
#
# Deliberately excluded: defaults/xdg/walker/ — walker is not part of this
# setup, the Quickshell launcher replaced it.
environment.etc = {
"xdg/niri/config.kdl".source = "${xdg}/niri/config.kdl";
"xdg/quickshell/moonarch".source = "${xdg}/quickshell/moonarch";
"xdg/waybar".source = "${xdg}/waybar";
"xdg/swaync".source = "${xdg}/swaync";
"xdg/foot/foot.ini".source = "${xdg}/foot/foot.ini";
"xdg/fastfetch/config.jsonc".source = "${xdg}/fastfetch/config.jsonc";
"xdg/kanshi/config".source = "${xdg}/kanshi/config";
"xdg/Kvantum/kvantum.kvconfig".source = "${xdg}/Kvantum/kvantum.kvconfig";
"xdg/qt6ct/qt6ct.conf".source = "${xdg}/qt6ct/qt6ct.conf";
"xdg/gtk-3.0/settings.ini".source = "${xdg}/gtk-3.0/settings.ini";
"xdg/gtk-4.0/settings.ini".source = "${xdg}/gtk-4.0/settings.ini";
"xdg/pipewire/pipewire.conf.d/99-input-denoising.conf".source =
"${xdg}/pipewire/pipewire.conf.d/99-input-denoising.conf";
# stasis reads /etc/stasis/ as its system-wide fallback, never /etc/xdg/.
"stasis/stasis.rune".source = "${xdg}/stasis/stasis.rune";
# Configs outside /etc/xdg/ in the Arch package as well.
"mpv/mpv.conf".source = "${etc}/mpv/mpv.conf";
"xdg-desktop-portal/niri-portals.conf".source =
"${etc}/xdg-desktop-portal/niri-portals.conf";
};
# Generic-family defaults. Same content as
# defaults/etc/fonts/conf.d/65-moonarch-fonts.conf, but routed through the
# fontconfig module: /etc/fonts/conf.d/ is owned by NixOS and rejects
# environment.etc entries.
fonts.fontconfig.localConf = ''
<description>Moonarch generic-family defaults</description>
<!-- binding="strong" required: the default weak <prefer> ranks behind
stock generic fallbacks, so it would not take effect. -->
<alias binding="strong">
<family>sans-serif</family>
<prefer>
<family>UbuntuSans Nerd Font</family>
</prefer>
</alias>
<alias binding="strong">
<family>monospace</family>
<prefer>
<family>UbuntuSansMono Nerd Font</family>
</prefer>
</alias>
'';
# --- Compositor ---
programs.niri.enable = true;
# niri only looks at $XDG_CONFIG_HOME/niri/config.kdl; it does not fall back
# to /etc/xdg. On Arch a one-line ~/.config/niri/config.kdl bridges there via
# `include`. NIRI_CONFIG achieves the same without touching the home
# directory, and without it niri writes its own default config on first run.
environment.sessionVariables.NIRI_CONFIG = "/etc/xdg/niri/config.kdl";
# config.kdl spawns the polkit agent by its FHS path
# (/usr/lib/polkit-gnome/...). Provide that path rather than diverging the
# config, which is shared with Arch.
systemd.tmpfiles.rules = [
"d /usr/lib 0755 root root -"
"L+ /usr/lib/polkit-gnome - - - - ${pkgs.polkit_gnome}/libexec"
];
# --- Shell ---
programs.zsh.enable = true;
# --- Theme, systemwide instead of the gsettings calls in post-install.sh ---
programs.dconf = {
enable = true;
profiles.user.databases = [{
settings."org/gnome/desktop/interface" = {
gtk-theme = "Colloid-Grey-Dark-Catppuccin";
icon-theme = "Colloid-Grey-Catppuccin-Dark";
color-scheme = "prefer-dark";
font-name = "UbuntuSans Nerd Font 11";
};
}];
};
# --- Portals ---
xdg.portal = {
enable = true;
extraPortals = with pkgs; [ xdg-desktop-portal-gnome xdg-desktop-portal-gtk ];
};
fonts.packages = with pkgs; [
nerd-fonts.ubuntu-sans
openmoji-color
];
environment.systemPackages = with pkgs; [
# Moonarch's own programs
moonarchPkgs.moonlock
moonarchPkgs.moonset
moonarchPkgs.sweet-cursors
moonarch-scripts
# Compositor extras
xwayland-satellite
kanshi
# Bar, notifications, clipboard
waybar
quickshell
swaynotificationcenter
libnotify
cliphist
wl-clipboard
# Display and wallpaper
wlsunset
nwg-look
brightnessctl
awww
swww-compat
waypaper
# Terminal
foot
# Audio
pavucontrol
alsa-utils
# Network and bluetooth
networkmanagerapplet
blueman
# File manager stack
gvfs
udisks2
ntfs3g
# Theming
(colloid-gtk-theme.override {
themeVariants = [ "grey" ];
colorVariants = [ "dark" ];
tweaks = [ "catppuccin" ];
})
colloid-icon-theme
libsForQt5.qtstyleplugin-kvantum
qt6Packages.qtstyleplugin-kvantum
qt6Packages.qt6ct
qt6.qt5compat
# CLI tools referenced by zshrc and the helper scripts
bat
btop
eza
fastfetch
fd
fzf
jq
lazygit
ripgrep
neovim
git
# System
fwupd
upower
polkit_gnome
wdisplays
wl-color-picker
];
# Polkit agent for privilege prompts inside the session.
security.polkit.enable = true;
}