users/services: implement dbus readiness checks for s6-rc
This commit is contained in:
parent
fff9d69e3e
commit
e6c00e6215
|
@ -34,7 +34,7 @@ in
|
|||
# env PIPEWIRE_LOG_SYSTEMD=false"
|
||||
# env PIPEWIRE_DEBUG"*:3,mod.raop*:5,pw.rtsp-client*:5"
|
||||
command = "pipewire";
|
||||
pollReadyCommand = pkgs.writeShellScript "pipewire-wait-started" ''
|
||||
readiness.waitCommand = pkgs.writeShellScript "pipewire-wait-started" ''
|
||||
[ -e "$XDG_RUNTIME_DIR/pipewire-0" ] && \
|
||||
[ -e "$XDG_RUNTIME_DIR/pipewire-0-manager" ]
|
||||
'';
|
||||
|
@ -45,7 +45,7 @@ in
|
|||
depends = [ "pipewire" ];
|
||||
partOf = [ "sound" ];
|
||||
command = "pipewire-pulse";
|
||||
pollReadyCommand = pkgs.writeShellScript "pipewire-pulse-wait-started" ''
|
||||
readiness.waitCommand = pkgs.writeShellScript "pipewire-pulse-wait-started" ''
|
||||
[ -e "$XDG_RUNTIME_DIR/pulse/native" ] && \
|
||||
[ -e "$XDG_RUNTIME_DIR/pulse/pid" ]
|
||||
'';
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
documentation = [ "https://github.com/altdesktop/playerctl/issues/161" ];
|
||||
partOf = [ "default" ]; #< TODO: maybe better to zero `wantedBy` here and have the specific consumers (e.g. swaync) explicitly depend on this.
|
||||
command = "playerctld";
|
||||
# serviceConfig.BusName = "org.mpris.MediaPlayer2.Player";
|
||||
# readiness.waitDbus = "org.mpris.MediaPlayer2.Player"; #< doesn't work... did the endpoint change?
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -475,7 +475,7 @@ in
|
|||
partOf = [ "graphical-session" ];
|
||||
|
||||
command = "env G_MESSAGES_DEBUG=all swaync";
|
||||
# serviceConfig.BusName = "org.freedesktop.Notifications";
|
||||
readiness.waitDbus = "org.freedesktop.Notifications";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ in
|
|||
dependencyOf = [ "xdg-desktop-portal" ];
|
||||
|
||||
command = "${cfg.package}/libexec/xdg-desktop-portal-gtk";
|
||||
serviceConfig.BusName = "org.freedesktop.impl.portal.desktop.gtk";
|
||||
readiness.waitDbus = "org.freedesktop.impl.portal.desktop.gtk";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ in
|
|||
dependencyOf = [ "xdg-desktop-portal" ];
|
||||
|
||||
command = "${cfg.package}/libexec/xdg-desktop-portal-wlr";
|
||||
serviceConfig.BusName = "org.freedesktop.impl.portal.desktop.wlr";
|
||||
readiness.waitDbus = "org.freedesktop.impl.portal.desktop.wlr";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ in
|
|||
# "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";
|
||||
readiness.waitDbus = "org.freedesktop.portal.Desktop";
|
||||
};
|
||||
|
||||
services.xdg-permission-store = {
|
||||
|
@ -82,7 +82,7 @@ in
|
|||
"XDG_DESKTOP_PORTAL_DIR=$HOME/.config/xdg-desktop-portal"
|
||||
"${cfg.package}/libexec/xdg-permission-store"
|
||||
];
|
||||
serviceConfig.BusName = "org.freedesktop.impl.portal.PermissionStore";
|
||||
readiness.waitDbus = "org.freedesktop.impl.portal.PermissionStore";
|
||||
};
|
||||
# also available: ${cfg.package}/libexec/xdg-document-portal
|
||||
# - <https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Documents.html>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{ config, lib, options, sane-lib, ... }:
|
||||
{ config, lib, options, pkgs, sane-lib, ... }:
|
||||
|
||||
let
|
||||
sane-user-cfg = config.sane.user;
|
||||
cfg = config.sane.users;
|
||||
path-lib = sane-lib.path;
|
||||
serviceType = with lib; types.submodule {
|
||||
serviceType = with lib; types.submodule ({ config, ... }: {
|
||||
options = {
|
||||
description = mkOption {
|
||||
type = types.str;
|
||||
|
@ -49,25 +49,31 @@ let
|
|||
restart of the service (if applicable) is blocked on this command.
|
||||
'';
|
||||
};
|
||||
pollReadyCommand = mkOption {
|
||||
readiness.waitCommand = 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.
|
||||
command or 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 {
|
||||
readiness.waitDbus = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
name of the dbus name this service is expected to register.
|
||||
only once the name is registered will the service be considered "active".
|
||||
only once the name is registered will the service be considered "ready".
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
config = {
|
||||
readiness.waitCommand = lib.mkIf
|
||||
(config.readiness.waitDbus != null)
|
||||
''${pkgs.systemdMinimal}/bin/busctl --user status "${config.readiness.waitDbus}" > /dev/null''
|
||||
;
|
||||
};
|
||||
});
|
||||
userOptions = {
|
||||
options = with lib; {
|
||||
fs = mkOption {
|
||||
|
|
|
@ -156,7 +156,7 @@ let
|
|||
s6SvcsFromConfigServices = services: lib.mapAttrsToList
|
||||
(name: service: {
|
||||
inherit name;
|
||||
check = service.pollReadyCommand;
|
||||
check = service.readiness.waitCommand;
|
||||
contents = builtins.attrNames (
|
||||
lib.filterAttrs (_: cfg: lib.elem name cfg.partOf) services
|
||||
);
|
||||
|
@ -180,7 +180,7 @@ let
|
|||
depends = [];
|
||||
dependencyOf = [];
|
||||
partOf = [];
|
||||
pollReadyCommand = null;
|
||||
readiness.waitCommand = null;
|
||||
};
|
||||
"graphical-session" = {
|
||||
command = null;
|
||||
|
@ -189,7 +189,7 @@ let
|
|||
depends = [];
|
||||
dependencyOf = [];
|
||||
partOf = [];
|
||||
pollReadyCommand = null;
|
||||
readiness.waitCommand = null;
|
||||
};
|
||||
"sound" = {
|
||||
command = null;
|
||||
|
@ -198,7 +198,7 @@ let
|
|||
depends = [];
|
||||
dependencyOf = [];
|
||||
partOf = [ "default" ];
|
||||
pollReadyCommand = null;
|
||||
readiness.waitCommand = null;
|
||||
};
|
||||
};
|
||||
in
|
||||
|
|
Loading…
Reference in New Issue