From d2f6648bce6393eec0a8226e0083c66e712f9446 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 21 Mar 2024 15:05:23 +0000 Subject: [PATCH] users/services: refactor: replace ExecStart/ExecStopPost with command/cleanupCommand note that this completely breaks the systemd backend (though easily fixable if wanted) --- hosts/common/programs/abaddon.nix | 2 +- hosts/common/programs/bonsai.nix | 4 +- hosts/common/programs/calls.nix | 2 +- hosts/common/programs/conky/default.nix | 5 ++- hosts/common/programs/dconf.nix | 3 +- hosts/common/programs/dino.nix | 2 +- hosts/common/programs/dissent.nix | 3 +- hosts/common/programs/fcitx5.nix | 2 +- hosts/common/programs/feedbackd.nix | 2 +- hosts/common/programs/fractal.nix | 2 +- hosts/common/programs/geary.nix | 3 +- .../common/programs/gnome-keyring/default.nix | 4 +- hosts/common/programs/mako.nix | 3 +- hosts/common/programs/ntfy-sh.nix | 2 +- hosts/common/programs/pipewire.nix | 42 +++++++------------ hosts/common/programs/playerctl.nix | 4 +- hosts/common/programs/signal-desktop.nix | 2 +- .../programs/sway-autoscaler/default.nix | 2 +- hosts/common/programs/sway/default.nix | 2 +- hosts/common/programs/swayidle.nix | 2 +- .../swaynotificationcenter/default.nix | 2 +- hosts/common/programs/sysvol.nix | 2 +- hosts/common/programs/waybar/default.nix | 2 +- hosts/common/programs/wireplumber.nix | 2 +- hosts/common/programs/wvkbd.nix | 2 +- .../programs/xdg-desktop-portal-gtk.nix | 6 +-- .../programs/xdg-desktop-portal-wlr.nix | 6 +-- hosts/common/programs/xdg-desktop-portal.nix | 40 ++++++++---------- modules/users/default.nix | 25 ++++++++--- modules/users/s6-rc.nix | 12 +++--- 30 files changed, 90 insertions(+), 102 deletions(-) diff --git a/hosts/common/programs/abaddon.nix b/hosts/common/programs/abaddon.nix index d367f4cda..143a7d5a1 100644 --- a/hosts/common/programs/abaddon.nix +++ b/hosts/common/programs/abaddon.nix @@ -88,7 +88,7 @@ in services.abaddon = { description = "unofficial Discord chat client"; wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; - serviceConfig.ExecStart = "abaddon"; + command = "abaddon"; }; }; } diff --git a/hosts/common/programs/bonsai.nix b/hosts/common/programs/bonsai.nix index a2e97ff1d..5e0324ece 100644 --- a/hosts/common/programs/bonsai.nix +++ b/hosts/common/programs/bonsai.nix @@ -121,8 +121,8 @@ in after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "bonsaid -t ${cfg.config.configFile}"; - serviceConfig.ExecStopPost = "rm -f $XDG_RUNTIME_DIR/bonsai"; + command = "bonsaid -t ${cfg.config.configFile}"; + cleanupCommand = "rm -f $XDG_RUNTIME_DIR/bonsai"; }; }; } diff --git a/hosts/common/programs/calls.nix b/hosts/common/programs/calls.nix index a8c47e38a..6a19cdd00 100644 --- a/hosts/common/programs/calls.nix +++ b/hosts/common/programs/calls.nix @@ -46,7 +46,7 @@ in description = "gnome-calls daemon to monitor incoming SIP calls"; wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; # add --verbose for more debugging - serviceConfig.ExecStart = "env G_MESSAGES_DEBUG=all gnome-calls --daemon"; + command = "env G_MESSAGES_DEBUG=all gnome-calls --daemon"; }; }; programs.calls = lib.mkIf cfg.enabled { diff --git a/hosts/common/programs/conky/default.nix b/hosts/common/programs/conky/default.nix index 516cf195e..54ae35668 100644 --- a/hosts/common/programs/conky/default.nix +++ b/hosts/common/programs/conky/default.nix @@ -1,4 +1,4 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: { sane.programs.conky = { # TODO: non-sandboxed `conky` still ships via `sxmo-utils`, but unused @@ -14,6 +14,7 @@ fs.".config/conky/conky.conf".symlink.target = let + # TODO: make this just another `suggestedPrograms`! battery_estimate = pkgs.static-nix-shell.mkBash { pname = "battery_estimate"; srcRoot = ./.; @@ -30,7 +31,7 @@ # partOf = [ "graphical-session.target" ]; # propagate stop/restart signal from graphical-session to this unit wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "${config.sane.programs.conky.package}/bin/conky"; + command = "conky"; }; }; } diff --git a/hosts/common/programs/dconf.nix b/hosts/common/programs/dconf.nix index 0b1515c0c..9fd870a10 100644 --- a/hosts/common/programs/dconf.nix +++ b/hosts/common/programs/dconf.nix @@ -36,8 +36,7 @@ in description = "dconf configuration database/server"; after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - - serviceConfig.ExecStart = "${lib.getLib cfg.package}/libexec/dconf-service"; + command = "${lib.getLib cfg.package}/libexec/dconf-service"; }; # supposedly necessary for packages which haven't been wrapped (i.e. wrapGtkApp?), diff --git a/hosts/common/programs/dino.nix b/hosts/common/programs/dino.nix index a3e14ac1b..25f9cdfe6 100644 --- a/hosts/common/programs/dino.nix +++ b/hosts/common/programs/dino.nix @@ -80,7 +80,7 @@ in # # note that debug logging during calls produces so much journal spam that it pegs the CPU and causes dropped audio # env G_MESSAGES_DEBUG = "all"; - serviceConfig.ExecStart = "env PULSE_LATENCY_MSEC=20 dino"; + command = "env PULSE_LATENCY_MSEC=20 dino"; }; }; } diff --git a/hosts/common/programs/dissent.nix b/hosts/common/programs/dissent.nix index c335fd39a..72a38c7f0 100644 --- a/hosts/common/programs/dissent.nix +++ b/hosts/common/programs/dissent.nix @@ -59,8 +59,7 @@ in description = "dissent Discord client"; after = [ "graphical-session.target" ]; wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; - - serviceConfig.ExecStart = "dissent"; + command = "dissent"; }; }; } diff --git a/hosts/common/programs/fcitx5.nix b/hosts/common/programs/fcitx5.nix index 63f0d27db..2878c72c0 100644 --- a/hosts/common/programs/fcitx5.nix +++ b/hosts/common/programs/fcitx5.nix @@ -100,7 +100,7 @@ after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "fcitx5"; + command = "fcitx5"; }; env.XMODIFIERS = "@im=fcitx"; diff --git a/hosts/common/programs/feedbackd.nix b/hosts/common/programs/feedbackd.nix index 285c24af2..b3ec820b1 100644 --- a/hosts/common/programs/feedbackd.nix +++ b/hosts/common/programs/feedbackd.nix @@ -97,7 +97,7 @@ in services.feedbackd = { description = "feedbackd audio/vibration/led controller"; wantedBy = [ "default.target" ]; #< should technically be `sound.target`, but that doesn't seem to get auto-started? - serviceConfig.ExecStart = lib.concatStringsSep " " ([ + command = lib.concatStringsSep " " ([ "env" "G_MESSAGES_DEBUG=all" ] ++ lib.optionals cfg.config.proxied [ diff --git a/hosts/common/programs/fractal.nix b/hosts/common/programs/fractal.nix index f697347e1..250c915c8 100644 --- a/hosts/common/programs/fractal.nix +++ b/hosts/common/programs/fractal.nix @@ -73,7 +73,7 @@ in wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; # env "G_MESSAGES_DEBUG=all" - serviceConfig.ExecStart = "fractal"; + command = "fractal"; }; }; } diff --git a/hosts/common/programs/geary.nix b/hosts/common/programs/geary.nix index d97e02610..09f2bf9ca 100644 --- a/hosts/common/programs/geary.nix +++ b/hosts/common/programs/geary.nix @@ -90,8 +90,7 @@ in after = [ "graphical-session.target" ]; # partOf = [ "graphical-session.target" ]; wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; - - serviceConfig.ExecStart = "geary"; + command = "geary"; }; }; diff --git a/hosts/common/programs/gnome-keyring/default.nix b/hosts/common/programs/gnome-keyring/default.nix index 0edca989b..ca135e28a 100644 --- a/hosts/common/programs/gnome-keyring/default.nix +++ b/hosts/common/programs/gnome-keyring/default.nix @@ -50,9 +50,9 @@ description = "gnome-keyring-daemon: secret provider"; after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = let + command = let gkr-start = pkgs.writeShellScriptBin "gnome-keyring-daemon-start" '' - mkdir -m 0700 -p %t/keyring + mkdir -m 0700 -p $XDG_RUNTIME_DIR/keyring exec gnome-keyring-daemon --start --foreground --components=secrets ''; in "${gkr-start}/bin/gnome-keyring-daemon-start"; diff --git a/hosts/common/programs/mako.nix b/hosts/common/programs/mako.nix index 37605b843..ac954d887 100644 --- a/hosts/common/programs/mako.nix +++ b/hosts/common/programs/mako.nix @@ -54,8 +54,7 @@ services.mako = { description = "mako desktop notification daemon"; wantedBy = [ "graphical-session.target" ]; - - serviceConfig.ExecStart = "${config.sane.programs.mako.package}/bin/mako"; + command = "${config.sane.programs.mako.package}/bin/mako"; }; }; } diff --git a/hosts/common/programs/ntfy-sh.nix b/hosts/common/programs/ntfy-sh.nix index 8d0eacb2a..d2bdd2831 100644 --- a/hosts/common/programs/ntfy-sh.nix +++ b/hosts/common/programs/ntfy-sh.nix @@ -28,7 +28,7 @@ in services.ntfy-sub = { description = "listen for push-notifications"; wantedBy = lib.mkIf cfg.config.autostart [ "default.target" ]; - serviceConfig.ExecStart = let + command = let sub = pkgs.writeShellScriptBin "ntfy-sub" '' topic=$(cat ~/.config/ntfy-sh/topic) exec ntfy sub "https://ntfy.uninsane.org:2587/$topic" diff --git a/hosts/common/programs/pipewire.nix b/hosts/common/programs/pipewire.nix index a44929480..4e9c3cf3f 100644 --- a/hosts/common/programs/pipewire.nix +++ b/hosts/common/programs/pipewire.nix @@ -32,39 +32,25 @@ in description = "pipewire: multimedia service"; after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig = { - # env PIPEWIRE_LOG_SYSTEMD=false" - # env PIPEWIRE_DEBUG"*:3,mod.raop*:5,pw.rtsp-client*:5" - ExecStart = "pipewire"; - ExecStartPost = pkgs.writeShellScript "pipewire-wait-started" '' - waitFor() { - while [ ! -e "$1" ]; do - sleep 1 - done - } - waitFor "$XDG_RUNTIME_DIR/pipewire-0" - waitFor "$XDG_RUNTIME_DIR/pipewire-0-manager" - ''; - ExecStopPost = ''rm -f "$XDG_RUNTIME_DIR/{pipewire-0,pipewire-0.lock,pipewire-0-manager,pipewire-0-manager.lock}"''; - }; + # env PIPEWIRE_LOG_SYSTEMD=false" + # env PIPEWIRE_DEBUG"*:3,mod.raop*:5,pw.rtsp-client*:5" + command = "pipewire"; + pollReadyCommand = pkgs.writeShellScript "pipewire-wait-started" '' + [ -e "$XDG_RUNTIME_DIR/pipewire-0" ] && \ + [ -e "$XDG_RUNTIME_DIR/pipewire-0-manager" ] + ''; + cleanupCommand = ''rm -f "$XDG_RUNTIME_DIR/{pipewire-0,pipewire-0.lock,pipewire-0-manager,pipewire-0-manager.lock}"''; }; services.pipewire-pulse = { description = "pipewire-pulse: Pipewire compatibility layer for PulseAudio clients"; after = [ "pipewire.service" ]; wantedBy = [ "pipewire.service" ]; - serviceConfig = { - ExecStart = "pipewire-pulse"; - ExecStartPost = pkgs.writeShellScript "pipewire-pulse-wait-started" '' - waitFor() { - while [ ! -e "$1" ]; do - sleep 1 - done - } - waitFor "$XDG_RUNTIME_DIR/pulse/native" - waitFor "$XDG_RUNTIME_DIR/pulse/pid" - ''; - ExecStopPost = ''rm -f "$XDG_RUNTIME_DIR/pulse/{native,pid}"''; - }; + command = "pipewire-pulse"; + pollReadyCommand = pkgs.writeShellScript "pipewire-pulse-wait-started" '' + [ -e "$XDG_RUNTIME_DIR/pulse/native" ] && \ + [ -e "$XDG_RUNTIME_DIR/pulse/pid" ] + ''; + cleanupCommand = ''rm -f "$XDG_RUNTIME_DIR/pulse/{native,pid}"''; }; }; diff --git a/hosts/common/programs/playerctl.nix b/hosts/common/programs/playerctl.nix index a59c2c69c..45321d7c8 100644 --- a/hosts/common/programs/playerctl.nix +++ b/hosts/common/programs/playerctl.nix @@ -1,4 +1,4 @@ -{ config, ... }: +{ ... }: { sane.programs.playerctl = { sandbox.method = "bwrap"; @@ -9,7 +9,7 @@ description = "playerctl daemon to keep track of which MPRIS players were recently active"; documentation = [ "https://github.com/altdesktop/playerctl/issues/161" ]; wantedBy = [ "default.target" ]; #< TODO: maybe better to zero `wantedBy` here and have the specific consumers (e.g. swaync) explicitly depend on this. - serviceConfig.ExecStart = "${config.sane.programs.playerctl.package}/bin/playerctld"; + command = "playerctld"; # serviceConfig.BusName = "org.mpris.MediaPlayer2.Player"; }; }; diff --git a/hosts/common/programs/signal-desktop.nix b/hosts/common/programs/signal-desktop.nix index 1897f1221..4c9aa0794 100644 --- a/hosts/common/programs/signal-desktop.nix +++ b/hosts/common/programs/signal-desktop.nix @@ -51,7 +51,7 @@ in wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; # for some reason the --ozone-platform-hint=auto flag fails when signal-desktop is launched from a service - serviceConfig.ExecStart = "env NIXOS_OZONE_WL=1 signal-desktop"; + command = "env NIXOS_OZONE_WL=1 signal-desktop"; }; }; } diff --git a/hosts/common/programs/sway-autoscaler/default.nix b/hosts/common/programs/sway-autoscaler/default.nix index 30105af33..c811aa65d 100644 --- a/hosts/common/programs/sway-autoscaler/default.nix +++ b/hosts/common/programs/sway-autoscaler/default.nix @@ -32,7 +32,7 @@ in services.sway-autoscaler = { description = "adjust global desktop scale to match the activate application"; wantedBy = lib.mkIf cfg.config.autostart [ "graphical-session.target" ]; - serviceConfig.ExecStart = lib.escapeShellArgs [ + command = lib.escapeShellArgs [ "env" "SWAY_DEFAULT_SCALE=${builtins.toString cfg.config.defaultScale}" "sway-autoscaler" diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index ae1373b59..e2dfb4325 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -254,7 +254,7 @@ in services.sway = { description = "sway: tiling wayland desktop environment"; wantedBy = [ "default.target" ]; - serviceConfig.ExecStart = "sway"; + command = "sway"; }; }; diff --git a/hosts/common/programs/swayidle.nix b/hosts/common/programs/swayidle.nix index 5a1b04ce3..2aa183d2c 100644 --- a/hosts/common/programs/swayidle.nix +++ b/hosts/common/programs/swayidle.nix @@ -57,7 +57,7 @@ in after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = lib.escapeShellArgs ( + command = lib.escapeShellArgs ( [ "swayidle" "-w" diff --git a/hosts/common/programs/swaynotificationcenter/default.nix b/hosts/common/programs/swaynotificationcenter/default.nix index 9c97f17c2..6546d67a5 100644 --- a/hosts/common/programs/swaynotificationcenter/default.nix +++ b/hosts/common/programs/swaynotificationcenter/default.nix @@ -478,7 +478,7 @@ in # partOf = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "env G_MESSAGES_DEBUG=all swaync"; + command = "env G_MESSAGES_DEBUG=all swaync"; # serviceConfig.BusName = "org.freedesktop.Notifications"; }; }; diff --git a/hosts/common/programs/sysvol.nix b/hosts/common/programs/sysvol.nix index fd61a4247..5d05fc57a 100644 --- a/hosts/common/programs/sysvol.nix +++ b/hosts/common/programs/sysvol.nix @@ -63,7 +63,7 @@ # -{H,W} N to set the height/width of the notifier, in px. # -i N to set the size of the volume icon # -P to hide percentage text - serviceConfig.ExecStart = "sysvol -p 0 -t 1 -m 22 -H 39 -W 256 -i 32 -P"; + command = "sysvol -p 0 -t 1 -m 22 -H 39 -W 256 -i 32 -P"; }; }; } diff --git a/hosts/common/programs/waybar/default.nix b/hosts/common/programs/waybar/default.nix index e4491691e..425fb50e2 100644 --- a/hosts/common/programs/waybar/default.nix +++ b/hosts/common/programs/waybar/default.nix @@ -120,7 +120,7 @@ in wantedBy = [ "graphical-session.target" ]; # env G_MESSAGES_DEBUG=all - serviceConfig.ExecStart = "waybar"; + command = "waybar"; }; }; } diff --git a/hosts/common/programs/wireplumber.nix b/hosts/common/programs/wireplumber.nix index f44a2c352..b01519252 100644 --- a/hosts/common/programs/wireplumber.nix +++ b/hosts/common/programs/wireplumber.nix @@ -34,7 +34,7 @@ after = [ "pipewire.service" ]; bindsTo = [ "pipewire.service" ]; wantedBy = [ "pipewire.service" ]; - serviceConfig.ExecStart = "wireplumber"; + command = "wireplumber"; }; }; } diff --git a/hosts/common/programs/wvkbd.nix b/hosts/common/programs/wvkbd.nix index 2131c1e1a..53888aefd 100644 --- a/hosts/common/programs/wvkbd.nix +++ b/hosts/common/programs/wvkbd.nix @@ -17,7 +17,7 @@ description = "wvkbd: wayland virtual keyboard"; after = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = lib.escapeShellArgs [ + command = lib.escapeShellArgs [ "env" # --hidden: send SIGUSR2 to unhide # wvkbd layers: diff --git a/hosts/common/programs/xdg-desktop-portal-gtk.nix b/hosts/common/programs/xdg-desktop-portal-gtk.nix index 2556ec907..b3ae65334 100644 --- a/hosts/common/programs/xdg-desktop-portal-gtk.nix +++ b/hosts/common/programs/xdg-desktop-portal-gtk.nix @@ -45,10 +45,8 @@ in before = [ "xdg-desktop-portal.service" ]; wantedBy = [ "xdg-desktop-portal.service" ]; - serviceConfig = { - ExecStart = "${cfg.package}/libexec/xdg-desktop-portal-gtk"; - BusName = "org.freedesktop.impl.portal.desktop.gtk"; - }; + command = "${cfg.package}/libexec/xdg-desktop-portal-gtk"; + serviceConfig.BusName = "org.freedesktop.impl.portal.desktop.gtk"; }; }; } diff --git a/hosts/common/programs/xdg-desktop-portal-wlr.nix b/hosts/common/programs/xdg-desktop-portal-wlr.nix index b20fbe6a0..6158a12a9 100644 --- a/hosts/common/programs/xdg-desktop-portal-wlr.nix +++ b/hosts/common/programs/xdg-desktop-portal-wlr.nix @@ -30,10 +30,8 @@ in before = [ "xdg-desktop-portal.service" ]; wantedBy = [ "xdg-desktop-portal.service" ]; - serviceConfig = { - ExecStart = "${cfg.package}/libexec/xdg-desktop-portal-wlr"; - BusName = "org.freedesktop.impl.portal.desktop.wlr"; - }; + command = "${cfg.package}/libexec/xdg-desktop-portal-wlr"; + serviceConfig.BusName = "org.freedesktop.impl.portal.desktop.wlr"; }; }; } diff --git a/hosts/common/programs/xdg-desktop-portal.nix b/hosts/common/programs/xdg-desktop-portal.nix index d1799f016..c650857e6 100644 --- a/hosts/common/programs/xdg-desktop-portal.nix +++ b/hosts/common/programs/xdg-desktop-portal.nix @@ -58,20 +58,18 @@ in # partOf = [ "graphical-session.target" ]; wantedBy = [ "graphical-session.target" ]; - serviceConfig = { - # tracking issue for having xdg-desktop-portal locate portals via more standard directories, obviating this var: - # - - # i can actually almost omit it today; problem is that if you don't set it it'll look for `sway-portals.conf` in ~/.config/xdg-desktop-portal - # but then will check its *own* output dir for {gtk,wlr}.portal. - # arguable if that's a packaging bug, or limitation... - ExecStart = lib.concatStringsSep " " [ - "env" - "XDG_DESKTOP_PORTAL_DIR=$HOME/.config/xdg-desktop-portal" - # "G_MESSAGES_DEBUG=all" #< also applies to all apps launched by the portal - "${cfg.package}/libexec/xdg-desktop-portal" - ]; - BusName = "org.freedesktop.portal.Desktop"; - }; + # tracking issue for having xdg-desktop-portal locate portals via more standard directories, obviating this var: + # - + # i can actually almost omit it today; problem is that if you don't set it it'll look for `sway-portals.conf` in ~/.config/xdg-desktop-portal + # but then will check its *own* output dir for {gtk,wlr}.portal. + # arguable if that's a packaging bug, or limitation... + command = lib.concatStringsSep " " [ + "env" + "XDG_DESKTOP_PORTAL_DIR=$HOME/.config/xdg-desktop-portal" + # "G_MESSAGES_DEBUG=all" #< also applies to all apps launched by the portal + "${cfg.package}/libexec/xdg-desktop-portal" + ]; + serviceConfig.BusName = "org.freedesktop.portal.Desktop"; }; services.xdg-permission-store = { @@ -82,14 +80,12 @@ in before = [ "xdg-desktop-portal.service" ]; wantedBy = [ "xdg-desktop-portal.service" ]; - serviceConfig = { - ExecStart = lib.concatStringsSep " " [ - "env" - "XDG_DESKTOP_PORTAL_DIR=$HOME/.config/xdg-desktop-portal" - "${cfg.package}/libexec/xdg-permission-store" - ]; - BusName = "org.freedesktop.impl.portal.PermissionStore"; - }; + command = lib.concatStringsSep " " [ + "env" + "XDG_DESKTOP_PORTAL_DIR=$HOME/.config/xdg-desktop-portal" + "${cfg.package}/libexec/xdg-permission-store" + ]; + serviceConfig.BusName = "org.freedesktop.impl.portal.PermissionStore"; }; # also available: ${cfg.package}/libexec/xdg-document-portal # - diff --git a/modules/users/default.nix b/modules/users/default.nix index 8eb33c6f2..95498cf37 100644 --- a/modules/users/default.nix +++ b/modules/users/default.nix @@ -38,17 +38,30 @@ let default = []; }; - serviceConfig.ExecStart = mkOption { + command = mkOption { type = types.nullOr (types.coercedTo types.package toString types.str); default = null; + description = '' + long-running command which represents this service. + when the command returns, the service is considered "failed", and restarted unless explicitly `down`d. + ''; }; - serviceConfig.ExecStartPost = mkOption { - type = types.nullOr (types.coercedTo types.package toString types.str); - default = null; - }; - serviceConfig.ExecStopPost = mkOption { + cleanupCommand = mkOption { type = types.nullOr types.str; default = null; + description = '' + command which is run after the service has exited. + restart of the service (if applicable) is blocked on this command. + ''; + }; + pollReadyCommand = mkOption { + type = types.nullOr (types.coercedTo types.package toString types.str); + default = null; + description = '' + path to executable which exits zero only when the service is ready. + this may be invoked repeatedly (with delay), + though it's not an error for it to block either (it may, though, be killed and restarted if it blocks too long) + ''; }; serviceConfig.BusName = mkOption { type = types.nullOr types.str; diff --git a/modules/users/s6-rc.nix b/modules/users/s6-rc.nix index 4d1042409..1aa8a582a 100644 --- a/modules/users/s6-rc.nix +++ b/modules/users/s6-rc.nix @@ -153,8 +153,8 @@ let s6SvcsFromConfigServices = services: lib.mapAttrsToList (name: service: { inherit name; - run = service.serviceConfig.ExecStart; - finish = service.serviceConfig.ExecStopPost; + run = service.command; + finish = service.cleanupCommand; depends = service.wants ++ builtins.attrNames ( lib.filterAttrs (_: cfg: lib.elem name cfg.wantedBy || lib.elem "${name}.service" cfg.wantedBy) services ); @@ -167,14 +167,14 @@ let # map them onto s6 "bundles". their contents are determined via reverse dependency mapping (`wantedBy` of every other service). implicitServices = { "default.target" = { - serviceConfig.ExecStart = null; - serviceConfig.ExecStopPost = null; + command = null; + cleanupCommand = null; wants = []; wantedBy = []; }; "graphical-session.target" = { - serviceConfig.ExecStart = null; - serviceConfig.ExecStopPost = null; + command = null; + cleanupCommand = null; wants = []; wantedBy = []; };