modularize desktop components

This commit is contained in:
2024-04-13 16:42:51 +02:00
parent d3da8ba3ac
commit e0176ec2d9
14 changed files with 141 additions and 96 deletions

View File

@@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./hyprland.nix
./plasma.nix
];
}

View File

@@ -0,0 +1,22 @@
{ lib, config, ... }:
let
cfg = config.desktop.de.hyprland;
in
{
options.desktop.de.hyprland = {
enable = lib.mkEnableOption "enable hyprland desktop environment";
};
config = lib.mkIf cfg.enable {
services = {
xserver.libinput.enable = true;
dbus.enable = true;
};
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
};
}

View File

@@ -0,0 +1,14 @@
{ config, lib, ... }:
let
cfg = config.desktop.de.plasma;
in
{
options.desktop.de.plasma = {
enable = lib.mkEnableOption "Enable Plasma desktop environment with sddm";
};
config = lib.mkIf cfg.enable {
services.xserver.desktopManager.plasma5.enable = true;
};
}

View File

@@ -0,0 +1,39 @@
{ config, lib, ... }:
let
cfg = config.desktop.dm;
in
{
options.desktop.dm = with lib; {
name = mkOption {
type = types.nullOr (types.enum ["sddm" "gdm"]);
default = null;
description = "The display manager to use.";
};
autologin = mkOption {
type = types.nullOr types.str;
default = null;
description = "The autologin username or null for no autologin.";
};
wayland = mkOption {
type = types.bool;
default = false;
description = "Enable wayland";
};
};
imports = [
./gdm.nix
./sddm.nix
];
config = {
services.xserver.enable = true;
services.xserver = {
layout = "de";
xkbVariant = "";
};
services.xserver.displayManager.autoLogin.enable = (cfg.autologin != null);
services.xserver.displayManager.autoLogin.user = cfg.autologin;
};
}

View File

@@ -0,0 +1,12 @@
{ lib, config, ... }:
let
cfg = config.desktop.dm;
in
{
config = lib.mkIf (cfg.name == "gdm") {
services.xserver.displayManager.gdm = {
enable = true;
wayland = cfg.wayland;
};
};
}

View File

@@ -0,0 +1,13 @@
{ lib, config, ... }:
let
cfg = config.desktop.dm;
in
{
config = lib.mkIf (cfg.name == "sddm") {
services.xserver.displayManager.sddm = {
enable = true;
wayland.enable = cfg.wayland;
};
};
}

View File

@@ -1,8 +0,0 @@
{ config, pkgs, ... }:
{
programs.hyprland = {
enable = true;
xwayland.enable = true;
};
}

View File

@@ -1,29 +0,0 @@
{ config, pkgs, ... }:
{
# Import unstable plasma6 module
imports = [
"${nixpkgs-unstable}/nixos/modules/services/desktop-managers/plasma6.nix"
];
disable = [
"services/desktop-managers/plasma6.nix"
];
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.wayland.enable = true;
services.desktopManager.plasma6.enable = true;
# Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "jonas";
}

View File

@@ -1,21 +0,0 @@
{ config, ... }:
{
# Enable the X11 windowing system.
services.xserver.enable = true;
# Configure keymap in X11
services.xserver = {
layout = "de";
xkbVariant = "";
};
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Enable automatic login for the user.
services.xserver.displayManager.autoLogin.enable = true;
services.xserver.displayManager.autoLogin.user = "jonas";
}