Better graphical start

This commit is contained in:
2026-09-11 14:28:11 +02:00
parent b7cfc63310
commit 07b7e2bb05
13 changed files with 152 additions and 99 deletions
+1
View File
@@ -1,4 +1,5 @@
{ lib, config, pkgs, ... }: {
imports = [ ./network-watchdog.nix ];
#environment.sessionVariables.SOPS_AGE_KEY_FILE = keyFilePath;
systemd.user.startServices = lib.mkIf pkgs.stdenv.isLinux "sd-switch";
+52
View File
@@ -0,0 +1,52 @@
{ lib, config, pkgs, ... }:
let
cfg = config.services.network-watchdog;
watchdog = "${pkgs.custom.network-watchdog}/bin/network-watchdog";
units = map (name: "${name}.service") cfg.units;
in {
# User services that only make sense while online: GUI clients that hold a
# socket to a server (jellyfin-mpv-shim, nextcloud-client). Their upstream
# units have no network ordering (network-online.target is a system target,
# out of reach for user units), so they happily start while offline —
# silently dead — and nothing notices a connection dropped by a network
# blip. Gate each start on the network being up, restart on failure, and let
# a watchdog catch the "up but not connected" state that systemd can't see.
# See pkgs.custom.network-watchdog.
options.services.network-watchdog.units = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "jellyfin-mpv-shim" ];
description = "User services (no .service suffix) to gate on the network and keep connected.";
};
config = lib.mkIf (cfg.units != [ ]) {
systemd.user.services = lib.genAttrs cfg.units (name: {
Service = {
ExecStartPre = "${watchdog} wait-online ${name}.service";
TimeoutStartSec = "infinity"; # stay in start-pre until the network is back
Restart = lib.mkDefault "on-failure";
RestartSec = lib.mkDefault 5;
};
}) // {
network-watchdog = {
Unit = {
Description = "Restart network services that are up but not connected";
After = units;
};
Service = {
Type = "oneshot";
ExecStart = "${watchdog} check ${lib.concatStringsSep " " units}";
};
};
};
systemd.user.timers.network-watchdog = {
Unit.Description = "Periodic health check for network services";
Timer = {
OnActiveSec = "60s";
OnUnitActiveSec = "60s";
};
Install.WantedBy = [ "timers.target" ];
};
};
}
+1 -32
View File
@@ -1,7 +1,6 @@
{ lib, config, pkgs, ... }:
let
configuredMpv = config.programs.mpv.finalPackage;
shimWatchdog = pkgs.custom.jellyfin-mpv-shim-watchdog;
in{
config = lib.mkIf (config.syscfg.make.gui) {
@@ -83,36 +82,6 @@ in{
programs.yt-dlp.enable = true;
# The upstream jellyfin-mpv-shim service has no Restart and no network
# ordering: it happily starts while offline (silently dead) and never
# recovers a connection dropped by a network blip. Gate its start on the
# network being up, and let a watchdog notice the "up but not connected"
# state that systemd can't see. See pkgs.custom.jellyfin-mpv-shim-watchdog.
systemd.user.services.jellyfin-mpv-shim.Service = {
ExecStartPre = "${shimWatchdog}/bin/jellyfin-mpv-shim-watchdog wait-online";
TimeoutStartSec = "infinity"; # stay in start-pre until the network is back
Restart = "on-failure";
RestartSec = 5;
};
systemd.user.services.jellyfin-mpv-shim-watchdog = {
Unit = {
Description = "Restart jellyfin-mpv-shim when it is up but not connected";
After = [ "jellyfin-mpv-shim.service" ];
};
Service = {
Type = "oneshot";
ExecStart = "${shimWatchdog}/bin/jellyfin-mpv-shim-watchdog check";
};
};
systemd.user.timers.jellyfin-mpv-shim-watchdog = {
Unit.Description = "Periodic health check for jellyfin-mpv-shim";
Timer = {
OnActiveSec = "60s";
OnUnitActiveSec = "60s";
};
Install.WantedBy = [ "timers.target" ];
};
services.network-watchdog.units = [ "jellyfin-mpv-shim" ];
};
}
@@ -1,6 +1,8 @@
{ lib, config, ... }: {
config = lib.mkIf (config.syscfg.make.gui) {
services.easyeffects.enable = true;
xdg.configFile."pipewire/pipewire-pulse.conf.d/desktop.conf".text = ''
context.modules = [
{ name = libpipewire-module-loopback
+19 -1
View File
@@ -1,7 +1,25 @@
{ lib, config, pkgs, ... }: {
config = lib.mkIf (config.syscfg.make.gui) {
services.nextcloud-client.enable = true;
services.nextcloud-client = {
enable = true;
startInBackground = true;
};
services.network-watchdog.units = [ "nextcloud-client" ];
systemd.user.services.keepassxc = lib.mkIf (config.usercfg.wm != "X11") {
Unit = {
Description = "KeePassXC";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${pkgs.keepassxc}/bin/keepassxc";
Restart = "on-failure";
RestartSec = 5;
};
Install.WantedBy = [ "graphical-session.target" ];
};
home.packages = with pkgs; [
thunar
@@ -20,6 +20,8 @@ let
in {
config = lib.mkIf (config.usercfg.wm == "Wayland") {
systemd.user.services.kanshi.Unit.After = lib.mkForce [ config.services.kanshi.systemdTarget "awww.service" ];
services.kanshi = {
enable = true;
systemdTarget = "graphical-session.target";
+2 -10
View File
@@ -24,23 +24,15 @@
startupScript = pkgs.writeShellScriptBin "hyprland-start" ''
# The eww bar is not started here: eww.service opens it with the
# graphical session and kanshi places it per profile (see apps/eww).
${pkgs.awww}/bin/awww-daemon &
${pkgs.awww}/bin/awww restore &
sleep 2
keepassxc &
firefox &
easyeffects --gapplication-service &
sleep 2
nextcloud &
# telegram-desktop &
# discord &
'';
in {
config = lib.mkIf (config.usercfg.wm == "Wayland") {
services.awww.enable = true;
wayland.windowManager.hyprland = {
enable = true;
xwayland.enable = true;
-2
View File
@@ -108,7 +108,6 @@
bspc desktop -f 0
telegram-desktop &
nextcloud &
#flameshot &
sleep 2
@@ -117,7 +116,6 @@
ibus-daemon -drx
easyeffects --gapplication-service &
bspc desktop -f 0
'';