Modularize desktop service and remove desktop.wms from machine opts.

This commit is contained in:
Kevin Baensch 2023-09-09 22:50:25 +02:00
parent 13a25fe675
commit 483c5d3f39
Signed by: derped
GPG key ID: C0F1D326C7626543
6 changed files with 32 additions and 64 deletions

View file

@ -54,11 +54,11 @@ with lib;
services = [ services = [
"bind" "bind"
"desktop" "desktop"
"desktop::i3"
"udev" "udev"
"cups" "cups"
"mullvad" "mullvad"
"mariaDB" "mariaDB"
"nspawn"
"docker" "podman" "docker" "podman"
]; ];
firewall = { firewall = {
@ -69,7 +69,6 @@ with lib;
allowedUDPPortRanges = [ { from = 1714; to = 1764; } ]; allowedUDPPortRanges = [ { from = 1714; to = 1764; } ];
allowedTCPPortRanges = [ { from = 1714; to = 1764; } ]; allowedTCPPortRanges = [ { from = 1714; to = 1764; } ];
}; };
desktop.wms = [ "none+i3" "i3" ];
}; };
config.system.copySysConf = { config.system.copySysConf = {

View file

@ -46,6 +46,7 @@ with lib;
services = [ services = [
"docker" "docker"
"desktop" "desktop"
"desktop::i3"
"udev" "udev"
"fprintd" "fprintd"
]; ];
@ -57,7 +58,6 @@ with lib;
allowedUDPPortRanges = [ ]; allowedUDPPortRanges = [ ];
allowedTCPPortRanges = [ ]; allowedTCPPortRanges = [ ];
}; };
desktop.wms = [ "none+i3" "i3" ];
}; };
config.system.copySysConf = { config.system.copySysConf = {

View file

@ -114,13 +114,6 @@ in {
Domain - Service mappings for nginx vHost config. Domain - Service mappings for nginx vHost config.
''; '';
}; };
desktop.wms = mkOption {
type = types.listOf types.str;
default = [];
description = ''
The list of wms to be enabled.
'';
};
}; };
imports = [ imports = [
(mkAliasOptionModule [ "machine" "firewall" ] [ "networking" "firewall" ]) (mkAliasOptionModule [ "machine" "firewall" ] [ "networking" "firewall" ])

View file

@ -1,47 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, fn, pkgs, ... }:
with lib; with lib;
let let
cfg = config.machine; cfg = config.machine;
ifelse = a: b: c: if a then b else c; desktopFiles = fn.lst { p = (toString ./desktop); b = true; };
in mkIf (elem "desktop" cfg.services) { in {
programs.sway = mkIf (elem "sway" cfg.desktop.wms) # (import ./desktop/sway.nix { inherit pkgs; }); imports = desktopFiles;
{ } // mkIf (elem "desktop" cfg.services) {
enable = true;
extraPackages = with pkgs; [
file i3status dmenu
qt5.qtwayland
grim slurp
swaylock
swayidle
light
mako
wl-clipboard
wf-recorder
];
extraSessionCommands = ''
export GDK_BACKEND=wayland
export CLUTTER_BACKEND=wayland
export SDL_VIDEODRIVER=wayland
# needs qt5.qtwayland in systemPackages
export QT_QPA_PLATFORM=wayland-egl
export QT_WAYLAND_FORCE_DPI=physical
export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
# Fix for some Java AWT applications (e.g. Android Studio),
# use this if they aren't displayed properly:
export _JAVA_AWT_WM_NONREPARENTING=1
'';
};
services.gvfs.enable = true; services.gvfs.enable = true;
services.xserver = { services.xserver = {
enable = !(elem "sway" cfg.desktop.wms);
layout = "de"; layout = "de";
displayManager.defaultSession = ifelse (cfg.desktop.wms != []) (elemAt cfg.desktop.wms 0) null;
windowManager = mkIf (cfg.desktop.wms != []) {
i3 = mkIf (elem "i3" cfg.desktop.wms) (import ./desktop/i3.nix { inherit pkgs; });
};
libinput = { libinput = {
enable = true; enable = true;
touchpad = { touchpad = {
@ -56,5 +25,4 @@ in mkIf (elem "desktop" cfg.services) {
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness" ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chgrp video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chmod 664 /sys/class/backlight/%k/brightness" ACTION=="add", SUBSYSTEM=="backlight", RUN+="${pkgs.coreutils}/bin/chmod 664 /sys/class/backlight/%k/brightness"
''; '';
machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [ py3status pytz tzlocal ];
} }

View file

@ -1,17 +1,21 @@
{ pkgs }: { config, lib, pkgs, ... }:
#with lib; with lib;
#mkIf (elem "i3" cfg.xserver.wms) { mkIf (elem "desktop::i3" config.machine.services) {
# i3 = services.xserver = {
{ enable = true;
enable = true; windowManager.i3 = {
configFile = (import ../../config/etc/i3/config.nix { inherit pkgs; }); enable = true;
extraPackages = with pkgs; [ configFile = (import ../../config/etc/i3/config.nix { inherit pkgs; });
dmenu extraPackages = with pkgs; [
file dmenu
i3lock file
i3status i3lock
xdg-user-dirs i3status
]; xdg-user-dirs
];
};
};
machine.pkgsets.python3.pkgs = with pkgs.python310Packages; [ py3status pytz tzlocal ];
} }

View file

@ -1,6 +1,9 @@
{ pkgs }: { config, lib, pkgs, ... }:
{ with lib;
mkIf (elem "desktop::sway" config.machine.services) {
programs.sway = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
xwayland xwayland
@ -26,4 +29,5 @@
# use this if they aren't displayed properly: # use this if they aren't displayed properly:
export _JAVA_AWT_WM_NONREPARENTING=1 export _JAVA_AWT_WM_NONREPARENTING=1
''; '';
} };
}