From da49352d4eec86aeb2010b7c3b911b198cfdfc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Thu, 7 Mar 2024 18:41:56 +0100 Subject: [PATCH] add himalaya-watch@.service As discussed in . I set `ExecStart=%install_dir%/himalaya` so when packaging himalaya people nee to explicitly set the path to himalaya (i.e. `sed 's:%install_dir%:/usr/bin:' assets/himalaya-watch@.service`). This is done automatically in `install.sh` if `$PREFIX` is `/usr`, Otherwise the packager should handle it themselves For `nix` it would be (`sed 's:%install_dir%:$out/bin:' assets/himalaya-watch@.service`). I don't know where it should be placed (probably `$out/share/systemd/user` as nix will add that to `$XDG_DATA_DIRS` which is searched by `systemctl --user`. I swear I checked the address like 4 times before sending the email, I have no idea how I managed to mess it up T-T. I was wondering why the formatting was so messed up in sr.ht. --- assets/himalaya-watch@.service | 13 +++++++++++++ install.sh | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 assets/himalaya-watch@.service diff --git a/assets/himalaya-watch@.service b/assets/himalaya-watch@.service new file mode 100644 index 0000000..dd7e88e --- /dev/null +++ b/assets/himalaya-watch@.service @@ -0,0 +1,13 @@ +[Unit] +Description=Email client Himalaya CLI envelopes watcher service +After=network.target + +[Service] +Type=exec +ExecStart=%install_dir%/himalaya envelopes watch --account %i +ExecSearchPath=/bin +Restart=always +RestartSec=10 + +[Install] +WantedBy=default.target diff --git a/install.sh b/install.sh index d6e72e5..57a4240 100644 --- a/install.sh +++ b/install.sh @@ -32,4 +32,11 @@ tar -xzf "$tmpdir/himalaya.tar.gz" -C "$tmpdir" mkdir -p "$PREFIX/bin" cp -f -- "$tmpdir/$binary" "$PREFIX/bin/$binary" +# See User Unit Search Path in `man systemd.unit(5)` +if [ "$system" = "linux" ] && [ "$PREFIX" = "/usr" ]; then + mkdir -p "$PREFIX/lib/systemd/user" + sed "s:%install_dir%:$PREFIX/bin:" "$tmpdir/assets/himalaya-watch@.service" \ + > "$PREFIX/lib/systemd/user/himalaya-watch@.service" +fi + die "$("$PREFIX/bin/$binary" --version) installed!" 0