[desktop] Refactor into multiple components

This commit is contained in:
2025-02-15 10:21:22 -08:00
parent 16fa4a641c
commit d6e031efd0
11 changed files with 139 additions and 79 deletions

View File

@@ -14,7 +14,10 @@
bluetooth.enable = true;
desktop = {
enable = true;
waylandOnly = true;
wayland = true;
gaming = true;
kde = true;
sddm = true;
};
nfs-mounts.enable = true;
printing.enable = true;

View File

@@ -12,7 +12,10 @@
];
roles = {
desktop.enable = true;
desktop = {
enable = true;
wayland = true;
};
};
networking.hostName = "wixos";

View File

@@ -31,6 +31,12 @@ with lib;
};
time.timeZone = "America/Los_Angeles";
services.xserver.xkb = {
layout = "us";
variant = "";
options = "caps:escape";
};
# Don't go to emergency mode if we aren't able to mount filesystems.
# This is silly if you have multiple hard drives or partitions
# configured on a machine and then one goes away intentionally or

View File

@@ -4,88 +4,32 @@ with lib;
let
cfg = config.roles.desktop;
in
{
options.roles.desktop = {
enable = mkEnableOption "Enable the desktop role.";
x11 = mkOption { type = types.bool; default = false; description = "Enable X11 support."; };
wayland = mkOption { type = types.bool; default = false; description = "Enable Wayland support."; };
kde = mkOption { type = types.bool; default = false; description = "Enable KDE."; };
gaming = mkOption { type = types.bool; default = false; description = "Enable gaming support."; };
sddm = mkOption { type = types.bool; default = false; description = "Enable SDDM greeter."; };
};
customPackages = pkgs.callPackage ../../packages {};
imports = [
./x11.nix
./wayland.nix
./gaming.nix
./kde.nix
];
basePackages = with pkgs; [
#bambu-studio
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
brightnessctl
emacs-nox
];
x11BasePackages = with pkgs; [
];
x11OnlyPackages = with pkgs; [
];
waylandBasePackages = with pkgs; [
grim
slurp
wl-clipboard
mako
];
waylandOnlyPackages = with pkgs; [
];
in
{
options.roles.desktop = {
enable = mkEnableOption "Enable the desktop role";
x11Only = mkOption {
type = types.bool;
default = false;
};
waylandOnly = mkOption {
type = types.bool;
default = false;
};
};
config = mkIf cfg.enable
{
services.xserver.xkb = {
layout = "us";
variant = "";
options = "caps:escape";
};
services.xserver.enable = true;
services.displayManager.sddm = {
enable = true;
wayland.enable = !cfg.x11Only;
};
services.desktopManager.plasma6.enable = true;
services.xserver.windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [
dmenu
i3status
i3lock
];
};
programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.sway = mkIf (!cfg.x11Only) {
enable = true;
wrapperFeatures.gtk = true;
};
programs.light.enable = mkIf (!cfg.x11Only) true;
programs.kdeconnect.enable = true;
virtualisation.docker.enable = true;
users.extraGroups.docker.members = [ "johno" ];
environment.systemPackages = with pkgs; mkMerge [
basePackages
(mkIf (!cfg.waylandOnly) x11BasePackages)
(mkIf cfg.x11Only x11OnlyPackages)
(mkIf (!cfg.x11Only) waylandBasePackages)
(mkIf (cfg.waylandOnly) waylandOnlyPackages)
];
};
}

17
roles/desktop/gaming.nix Normal file
View File

@@ -0,0 +1,17 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
in
{
config = mkIf (cfg.enable && cfg.gaming) {
environment.systemPackages = with pkgs; [
steam
lutris
];
# Possibly other gaming specific services or settings
};
}

12
roles/desktop/kde.nix Normal file
View File

@@ -0,0 +1,12 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
in
{
config = mkIf (cfg.enable && cfg.kde) {
services.desktopManager.plasma6.enable = true;
};
}

View File

@@ -0,0 +1,16 @@
{ lib, config, pkgs, ... }:
with lib;
{
config = {
environment.systemPackages = with pkgs; [
brightnessctl
emacs-nox
];
programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true;
programs.kdeconnect.enable = true;
};
}

15
roles/desktop/sddm.nix Normal file
View File

@@ -0,0 +1,15 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
in
{
config = mkIf (cfg.enable && cfg.sddm) {
services.displayManager.sddm = {
enable = true;
wayland.enable = (!cfg.x11 && cfg.wayland);
};
};
}

23
roles/desktop/wayland.nix Normal file
View File

@@ -0,0 +1,23 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
in
{
config = mkIf (cfg.enable && cfg.wayland) {
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
programs.light.enable = true;
environment.systemPackages = with pkgs; [
grim
slurp
wl-clipboard
mako
];
};
}

19
roles/desktop/x11.nix Normal file
View File

@@ -0,0 +1,19 @@
{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.roles.desktop;
in
{
config = mkIf (cfg.enable && cfg.x11) {
services.xserver = {
enable = true;
windowManager.i3 = {
enable = true;
extraPackages = with pkgs; [ dmenu i3status i3lock ];
};
};
};
}

View File

@@ -14,5 +14,7 @@ in
{
virtualisation.libvirtd.enable = true;
programs.virt-manager.enable = true;
virtualisation.docker.enable = true;
users.extraGroups.docker.members = [ "johno" ];
};
}