mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-25 04:20:22 +00:00
da49352d4e
As discussed in <https://github.com/nix-community/home-manager/issues/5069>. 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.
42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
die() {
|
|
printf '%s\n' "$1" >&2
|
|
exit "${2-1}"
|
|
}
|
|
|
|
DESTDIR="${DESTDIR:-}"
|
|
PREFIX="${PREFIX:-"$DESTDIR/usr/local"}"
|
|
RELEASES_URL="https://github.com/soywod/himalaya/releases"
|
|
|
|
system=$(uname -s | tr [:upper:] [:lower:])
|
|
case $system in
|
|
msys*|mingw*|cygwin*|win*) system=windows; binary=himalaya.exe;;
|
|
linux|freebsd) system=linux; binary=himalaya;;
|
|
darwin) system=macos; binary=himalaya;;
|
|
*) die "Unsupported system: $system" ;;
|
|
esac
|
|
|
|
tmpdir=$(mktemp -d) || die "Failed to create tmpdir"
|
|
trap "rm -rf $tmpdir" EXIT
|
|
|
|
echo "Downloading latest $system release…"
|
|
curl -sLo "$tmpdir/himalaya.tar.gz" \
|
|
"$RELEASES_URL/latest/download/himalaya-$system.tar.gz"
|
|
|
|
echo "Installing binary…"
|
|
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
|