From 3b0a0ef579bc5b32b100c31fa2ec673136769918 Mon Sep 17 00:00:00 2001 From: Andre Date: Sat, 29 Jun 2024 12:23:26 -0400 Subject: [PATCH] refactor(system): fix conflicts between desktop environment login managers --- system/host/configuration.nix | 2 +- system/modules/system/bootloader.nix | 6 +++--- system/modules/system/system.nix | 3 +++ system/modules/ui/desktops/budgie.nix | 17 +++++++++-------- system/modules/ui/desktops/common.nix | 20 ++++++++++++++++++++ system/modules/ui/desktops/gnome.nix | 11 ++++++++--- system/modules/ui/desktops/kde.nix | 16 +++++----------- system/modules/ui/desktops/xfce.nix | 19 ++++++++++++------- 8 files changed, 61 insertions(+), 33 deletions(-) diff --git a/system/host/configuration.nix b/system/host/configuration.nix index 96f8c6c..16af6c8 100644 --- a/system/host/configuration.nix +++ b/system/host/configuration.nix @@ -116,7 +116,7 @@ in # Enable the KDE desktop environment. # https://kde.org/ - kde.enable = false; + kde.useX11 = false; # Enable the XFCE desktop environment. # https://xfce.org/ diff --git a/system/modules/system/bootloader.nix b/system/modules/system/bootloader.nix index 27e0f06..f38a1ac 100644 --- a/system/modules/system/bootloader.nix +++ b/system/modules/system/bootloader.nix @@ -48,9 +48,9 @@ in boot.initrd = { # Enable systemd for TPM auto-unlocking systemd.enable = true; - - availableKernelModules = [ "tpm_crb"]; - kernelModules = ["tpm_crb"]; + + availableKernelModules = [ "tpm_crb" ]; + kernelModules = [ "tpm_crb" ]; }; # After installing and rebooting, set it up via https://wiki.archlinux.org/title/Systemd-cryptenroll#Trusted_Platform_Module environment.systemPackages = with pkgs; [ tpm2-tss ]; diff --git a/system/modules/system/system.nix b/system/modules/system/system.nix index 8b32469..c00816e 100644 --- a/system/modules/system/system.nix +++ b/system/modules/system/system.nix @@ -18,6 +18,9 @@ in }; }; config = { + # Install the latest kernel + boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + # Set up the environment environment = { # Install base packages diff --git a/system/modules/ui/desktops/budgie.nix b/system/modules/ui/desktops/budgie.nix index dbfe0ff..b0afca8 100644 --- a/system/modules/ui/desktops/budgie.nix +++ b/system/modules/ui/desktops/budgie.nix @@ -16,17 +16,18 @@ in }; config = lib.mkIf cfg.enable { - aux.system.ui.desktops.enable = true; + aux.system.ui.desktops = { + enable = true; + displayManager = lib.mkOptionDefault "lightdm"; + }; services.xserver = { enable = true; - desktopManager.budgie.enable = true; - displayManager.lightdm.enable = lib.mkIf ( - !( - config.services.xserver.displayManager.gdm.enable - || config.services.xserver.displayManager.sddm.enable - ) - ) true; + desktopManager.budgie.enable = + if config.services.xserver.desktopManager.gnome.enable then + builtins.abort "Budgie and Gnome cannot be enabled at the same time due to a bug. For details and a possible workaround, please see https://discourse.nixos.org/t/help-i-cant-have-pantheon-gnome-and-plasma-installed-on-my-system-at-the-same-time/47346" + else + true; }; }; } diff --git a/system/modules/ui/desktops/common.nix b/system/modules/ui/desktops/common.nix index 11cfa7a..96f5744 100644 --- a/system/modules/ui/desktops/common.nix +++ b/system/modules/ui/desktops/common.nix @@ -21,6 +21,15 @@ in variant = ""; }; }; + displayManager = lib.mkOption { + description = "The display manager to use to start a desktop session."; + type = lib.types.enum [ + "gdm" + "lightdm" + "sddm" + "sddm_wayland" + ]; + }; }; }; @@ -49,6 +58,17 @@ in # Configure keymap in X11 xkb = config.aux.system.ui.desktops.xkb; + + # Set the display manager + displayManager = { + gdm.enable = (cfg.displayManager == "gdm"); + lightdm.enable = (cfg.displayManager == "lightdm"); + }; + }; + + displayManager = { + sddm.enable = (cfg.displayManager == "sddm"); + sddm.wayland.enable = (cfg.displayManager == "sddm_wayland"); }; # Enable touchpad support (enabled by default in most desktop managers, buuuut just in case). diff --git a/system/modules/ui/desktops/gnome.nix b/system/modules/ui/desktops/gnome.nix index e7fd89c..043744b 100644 --- a/system/modules/ui/desktops/gnome.nix +++ b/system/modules/ui/desktops/gnome.nix @@ -16,15 +16,17 @@ in }; config = lib.mkIf cfg.enable { - aux.system.ui.desktops.enable = true; + aux.system.ui.desktops = { + enable = true; + displayManager = lib.mkOverride 500 "gdm"; + }; # Enable Gnome services.xserver = { # Remove default packages that came with the install excludePackages = [ pkgs.xterm ]; - desktopManager.gnome.enable = true; - displayManager.gdm.enable = true; + desktopManager.gnome.enable = lib.mkDefault true; }; environment = { @@ -44,6 +46,9 @@ in ]; }; + # Manually set askPassword to avoid a conflict with KDE + programs.ssh.askPassword = "${pkgs.gnome.seahorse}/libexec/seahorse/ssh-askpass"; + # Gnome UI integration for KDE apps qt = { enable = true; diff --git a/system/modules/ui/desktops/kde.nix b/system/modules/ui/desktops/kde.nix index d5b6f32..96a1baf 100644 --- a/system/modules/ui/desktops/kde.nix +++ b/system/modules/ui/desktops/kde.nix @@ -18,7 +18,10 @@ in }; config = lib.mkIf cfg.enable { - aux.system.ui.desktops.enable = true; + aux.system.ui.desktops = { + enable = true; + displayManager = if cfg.useX11 then lib.mkDefault "sddm" else lib.mkDefault "sddm_wayland"; + }; programs.dconf.enable = true; @@ -30,18 +33,9 @@ in }; services = { - displayManager.sddm.enable = true; desktopManager.plasma6.enable = true; - xserver.displayManager = lib.mkIf cfg.useX11 { - defaultSession = "plasmaX11"; - sddm.wayland.enable = lib.mkIf ( - !( - config.services.xserver.displayManager.gdm.enable - || config.services.xserver.displayManager.lightdm.enable - ) - ) true; - }; + xserver.displayManager = lib.mkIf cfg.useX11 { defaultSession = "plasmaX11"; }; }; # Enable Gnome integration diff --git a/system/modules/ui/desktops/xfce.nix b/system/modules/ui/desktops/xfce.nix index c6583b2..ba0d004 100644 --- a/system/modules/ui/desktops/xfce.nix +++ b/system/modules/ui/desktops/xfce.nix @@ -16,15 +16,20 @@ in }; config = lib.mkIf cfg.enable { - aux.system.ui.desktops.enable = true; - - services.xserver = { + aux.system.ui.desktops = { enable = true; - desktopManager = { - xterm.enable = false; - xfce.enable = true; - }; + displayManager = lib.mkOptionDefault "lightdm"; + }; + + services = { displayManager.defaultSession = "xfce"; + xserver = { + enable = true; + desktopManager = { + xterm.enable = false; + xfce.enable = true; + }; + }; }; }; }