refactor: users/services: have `waitExists` support waiting on multiple paths
This commit is contained in:
parent
f65d3d04dc
commit
2e58353b0e
|
@ -42,10 +42,10 @@ in
|
|||
mkdir -p $PIPEWIRE_RUNTIME_DIR
|
||||
exec pipewire
|
||||
'';
|
||||
readiness.waitCommand = pkgs.writeShellScript "pipewire-wait-started" ''
|
||||
test -e "$PIPEWIRE_RUNTIME_DIR/pipewire-0" && \
|
||||
test -e "$PIPEWIRE_RUNTIME_DIR/pipewire-0-manager"
|
||||
'';
|
||||
readiness.waitExists = [
|
||||
"$PIPEWIRE_RUNTIME_DIR/pipewire-0"
|
||||
"$PIPEWIRE_RUNTIME_DIR/pipewire-0-manager"
|
||||
];
|
||||
cleanupCommand = ''rm -f "$PIPEWIRE_RUNTIME_DIR/{pipewire-0,pipewire-0.lock,pipewire-0-manager,pipewire-0-manager.lock}"'';
|
||||
};
|
||||
services.pipewire-pulse = {
|
||||
|
@ -53,10 +53,10 @@ in
|
|||
depends = [ "pipewire" ];
|
||||
partOf = [ "sound" ];
|
||||
command = "pipewire-pulse";
|
||||
readiness.waitCommand = pkgs.writeShellScript "pipewire-pulse-wait-started" ''
|
||||
test -e "$XDG_RUNTIME_DIR/pulse/native" && \
|
||||
test -e "$XDG_RUNTIME_DIR/pulse/pid"
|
||||
'';
|
||||
readiness.waitExists = [
|
||||
"$XDG_RUNTIME_DIR/pulse/native"
|
||||
"$XDG_RUNTIME_DIR/pulse/pid"
|
||||
];
|
||||
cleanupCommand = ''rm -f "$XDG_RUNTIME_DIR/pulse/{native,pid}"'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -230,10 +230,7 @@ in
|
|||
mkdir -p /tmp/.X11-unix # for Xwayland
|
||||
exec sway
|
||||
'';
|
||||
# readiness.waitExists = "$SWAYSOCK";
|
||||
readiness.waitCommand = pkgs.writeShellScript "sway-readycheck" ''
|
||||
test -e "$SWAYSOCK" && test -e "$WAYLAND_DISPLAY"
|
||||
'';
|
||||
readiness.waitExists = [ "$SWAYSOCK" "$WAYLAND_DISPLAY" ];
|
||||
};
|
||||
# link the graphical-session into the default target, so sway gets auto-started
|
||||
services.graphical-session.partOf = [ "default" ];
|
||||
|
|
|
@ -67,8 +67,8 @@ let
|
|||
'';
|
||||
};
|
||||
readiness.waitExists = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
type = types.coercedTo types.str toList (types.listOf types.str);
|
||||
default = [];
|
||||
description = ''
|
||||
path to a directory or file whose existence signals the service's readiness.
|
||||
this is expanded as a shell expression, and may contain variables like `$HOME`, etc.
|
||||
|
@ -80,8 +80,9 @@ let
|
|||
(lib.mkIf (config.readiness.waitDbus != null)
|
||||
''${pkgs.systemdMinimal}/bin/busctl --user status "${config.readiness.waitDbus}" > /dev/null''
|
||||
)
|
||||
(lib.mkIf (config.readiness.waitExists != null)
|
||||
''test -e "${config.readiness.waitExists}"''
|
||||
(lib.mkIf (config.readiness.waitExists != [])
|
||||
# e.g.: test -e /foo -a -e /bar
|
||||
("test -e " + (lib.concatStringsSep " -a -e " config.readiness.waitExists))
|
||||
)
|
||||
];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue