First commit

This commit is contained in:
2026-02-22 17:28:02 +01:00
parent 7a70268785
commit 6bacf1878e
9011 changed files with 114470 additions and 0 deletions
@@ -0,0 +1,60 @@
# ~/nixos/modules/nixos/desktop/audio.nix
#
# Baseline audio stack:
# - PipeWire as the audio server
# - PulseAudio compatibility via pipewire-pulse
# - ALSA compatibility (+ 32-bit ALSA for games/legacy)
# - WirePlumber session manager
# - RTKit for better realtime scheduling (often reduces crackling under load)
#
# IMPORTANT (NixOS option churn):
# - On some nixpkgs revisions the old `hardware.pulseaudio` option was renamed to
# `services.pulseaudio`. We set the *services* one explicitly.
# - Avoid `lib.mkForce` on pulseaudio enable/disable here because certain revisions
# have had type/override weirdness; use plain booleans instead.
{ config, lib, pkgs, ... }:
let
moduleName = "nixos-audio";
in
{
# ---- Disable the standalone PulseAudio daemon ----
#
# We want PipeWire to provide PulseAudio compatibility (pipewire-pulse),
# not a separate pulseaudio service.
services.pulseaudio.enable = false;
# ---- PipeWire ----
services.pipewire = {
enable = true;
# PulseAudio compatibility server (pipewire-pulse)
pulse.enable = true;
# ALSA compatibility (+ 32-bit for Steam/older apps)
alsa = {
enable = true;
support32Bit = true;
};
# Recommended policy/session manager
wireplumber.enable = true;
# Optional JACK compatibility (leave off unless you need it)
jack.enable = false;
};
# Realtime scheduling broker commonly used by PipeWire
security.rtkit.enable = true;
# Useful tooling
environment.systemPackages = with pkgs; [
pavucontrol
helvum
alsa-utils
];
# Breadcrumb for debugging module load order
environment.etc."nixlog/loaded.${moduleName}".text = "loaded\n";
}
@@ -0,0 +1,91 @@
{ config, pkgs, lib, ... }:
let
cfg = config.desktop.greeter;
in
{
options.desktop.greeter = {
enable = lib.mkEnableOption "greetd + tuigreet greeter (starts Hyprland)";
greeterConfSource = lib.mkOption {
type = lib.types.path;
default = ../../../files/conf/greeter/greeter.conf;
description = "Path to greeter.conf in your repo; will be installed to /etc/xdg/greeter/greeter.conf";
};
vt = lib.mkOption {
type = lib.types.int;
default = 1;
description = "Virtual terminal (VT) greetd runs on (typically 1).";
};
extraArgs = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ "--time" "--remember" "--remember-session" "--asterisks" ];
description = "Extra command-line arguments passed to tuigreet.";
};
useDbusRunSession = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Wrap Hyprland with dbus-run-session (often helps session env).";
};
installGreeterPackages = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Add tuigreet (and optional qtgreet) to systemPackages.";
};
enableTty1Fix = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Ensure greetd owns tty1 (avoids boot console overriding greetd).";
};
};
config = lib.mkIf cfg.enable {
# greetd + tuigreet configuration
services.greetd = {
enable = true;
settings = {
terminal.vt = cfg.vt;
default_session = {
# greetd service runs the greeter as this user
user = "greetd";
# Build: tuigreet ... --cmd <Hyprland>
command =
let
hyprCmd =
if cfg.useDbusRunSession
then "${pkgs.dbus}/bin/dbus-run-session ${pkgs.hyprland}/bin/Hyprland"
else "${pkgs.hyprland}/bin/Hyprland";
tuigreetArgs = lib.concatStringsSep " " cfg.extraArgs;
in
"${pkgs.tuigreet}/bin/tuigreet ${tuigreetArgs} --cmd ${hyprCmd}";
};
};
};
# Install your custom greeter config into /etc/xdg/greeter/greeter.conf
environment.etc."xdg/greeter/greeter.conf".source = cfg.greeterConfSource;
# Supporting bits (Wayland sessions almost always want these)
services.dbus.enable = lib.mkDefault true;
security.polkit.enable = lib.mkDefault true;
# Optional: keep greeter tools available system-wide
environment.systemPackages = lib.mkIf cfg.installGreeterPackages (with pkgs; [
tuigreet
qtgreet
]);
# Fix "Graphical System started" but no greeter: ensure tty1 isnt stolen by console/getty
boot.kernelParams = lib.mkIf cfg.enableTty1Fix [ "console=tty1" ];
systemd.services."getty@tty1".enable = lib.mkIf cfg.enableTty1Fix false;
systemd.services."autovt@tty1".enable = lib.mkIf cfg.enableTty1Fix false;
};
}
@@ -0,0 +1,67 @@
# Atomic responsibility:
# - System-wide XDG basics
# - System-wide xdg-desktop-portal + chosen backends
# - A sane portals.conf selection (prevents “wrong backend” surprises)
#
# Notes:
# - Keep ALL portal-related config here (do not also configure xdg.portal in wm-hyprland.nix).
# - xdg.portal.config.common sets defaults via portals.conf(5) and is supported by NixOS. :contentReference[oaicite:0]{index=0}
# - If you enable xdg.portal.wlr.enable elsewhere, it auto-adds xdg-desktop-portal-wlr to extraPortals. :contentReference[oaicite:1]{index=1}
# (We do NOT do that here because Hyprland typically uses xdg-desktop-portal-hyprland instead.)
# - xdg-desktop-portal-gtk is commonly needed for OpenURI/FileChooser support. :contentReference[oaicite:2]{index=2}
{ config, lib, pkgs, ... }:
{
##########################################################################
# XDG basics (system)
##########################################################################
xdg = {
menus.enable = true;
mime.enable = true;
};
##########################################################################
# Portals (system)
##########################################################################
xdg.portal = {
enable = true;
# Prefer Hyprland portal for compositor-integrated features (screensharing, etc),
# and GTK for things like OpenURI/FileChooser compatibility.
extraPortals = with pkgs; [
xdg-desktop-portal-hyprland
xdg-desktop-portal-gtk
];
# Explicit portal routing via portals.conf (prevents “random backend chosen” issues).
# This writes /etc/xdg/xdg-desktop-portal/portals.conf. :contentReference[oaicite:3]{index=3}
config.common = {
# Default backend order for interfaces where multiple backends exist.
default = [ "hyprland" "gtk" ];
# (Optional, but often helpful) Ensure GTK handles common UX portals reliably.
"org.freedesktop.impl.portal.FileChooser" = [ "gtk" ];
"org.freedesktop.impl.portal.OpenURI" = [ "gtk" ];
};
};
##########################################################################
# Environment defaults (system)
##########################################################################
environment.sessionVariables = {
# Encourage GTK apps to use portals for file picker / open-uri on Wayland.
GTK_USE_PORTAL = "1";
# Desktop identity hints used by some apps / portal logic.
# (Set once here; dont duplicate in HM and NixOS.)
XDG_CURRENT_DESKTOP = "Hyprland";
XDG_SESSION_DESKTOP = "Hyprland";
};
##########################################################################
# Optional: small, non-invasive tooling for troubleshooting
##########################################################################
environment.systemPackages = with pkgs; lib.mkAfter [
xdg-utils
];
}
@@ -0,0 +1,17 @@
{ config, lib, pkgs, ... }:
let
repoHyprDir = ../../../files/conf/hypr;
in
{
programs.hyprland.enable = true;
services.dbus.enable = lib.mkDefault true;
security.polkit.enable = lib.mkDefault true;
# Publish to XDG config dir so Hyprland finds it
environment.etc."xdg/hypr".source = repoHyprDir;
# Optional breadcrumb
environment.etc."nixlog/loaded.nixos-desktop-wm-hyprland".text = "loaded\n";
}