miru: added passthru.updateScript
This commit is contained in:
parent
8660d7b646
commit
bea3a3f50c
@ -7,9 +7,15 @@
|
||||
pname,
|
||||
version,
|
||||
meta,
|
||||
passthru,
|
||||
}:
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
inherit pname version meta;
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
meta
|
||||
passthru
|
||||
;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/ThaUnknown/miru/releases/download/v${version}/mac-Miru-${version}-mac.zip";
|
||||
|
@ -5,15 +5,21 @@
|
||||
pname,
|
||||
version,
|
||||
meta,
|
||||
passthru,
|
||||
}:
|
||||
|
||||
appimageTools.wrapType2 rec {
|
||||
inherit pname version meta;
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
meta
|
||||
passthru
|
||||
;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://github.com/ThaUnknown/miru/releases/download/v${version}/linux-Miru-${version}.AppImage";
|
||||
name = "${pname}-${version}.AppImage";
|
||||
sha256 = "sha256-wnqCKnZKt0Fj8TasdRVzI558W7aIB5FLkcDEiZfz3ZQ=";
|
||||
hash = "sha256-wnqCKnZKt0Fj8TasdRVzI558W7aIB5FLkcDEiZfz3ZQ=";
|
||||
};
|
||||
|
||||
extraInstallCommands =
|
||||
|
@ -32,8 +32,25 @@ let
|
||||
instead of flat out closing MPV.
|
||||
'';
|
||||
};
|
||||
passthru = {
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
in
|
||||
if stdenv.isDarwin then
|
||||
callPackage ./darwin.nix { inherit pname version meta; }
|
||||
callPackage ./darwin.nix {
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
meta
|
||||
passthru
|
||||
;
|
||||
}
|
||||
else
|
||||
callPackage ./linux.nix { inherit pname version meta; }
|
||||
callPackage ./linux.nix {
|
||||
inherit
|
||||
pname
|
||||
version
|
||||
meta
|
||||
passthru
|
||||
;
|
||||
}
|
||||
|
52
pkgs/by-name/mi/miru/update.sh
Executable file
52
pkgs/by-name/mi/miru/update.sh
Executable file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl jq gnused
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(dirname "$(readlink -f "$0")")"
|
||||
if [[ ! "$(basename $ROOT)" == "miru" || ! -f "$ROOT/package.nix" ]]; then
|
||||
echo "error: Not in the miru folder" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PACKAGE_NIX="$ROOT/package.nix"
|
||||
LINUX_NIX="$ROOT/linux.nix"
|
||||
DARWIN_NIX="$ROOT/darwin.nix"
|
||||
|
||||
MIRU_LATEST_VER="$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} "https://api.github.com/repos/ThaUnknown/miru/releases/latest" | jq -r .tag_name | sed 's/^v//')"
|
||||
MIRU_CURRENT_VER="$(grep -oP 'version = "\K[^"]+' "$PACKAGE_NIX")"
|
||||
|
||||
if [[ "$MIRU_LATEST_VER" == "null" ]]; then
|
||||
echo "error: could not fetch miru latest version from GitHub API" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$MIRU_LATEST_VER" == "$MIRU_CURRENT_VER" ]]; then
|
||||
echo "miru is up-to-date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
get_hash() {
|
||||
# $1: URL
|
||||
nix-hash --to-sri --type sha256 "$(nix-prefetch-url --type sha256 "$1")"
|
||||
}
|
||||
|
||||
replace_hash_in_file() {
|
||||
# $1: file
|
||||
# $2: new hash
|
||||
sed -i "s#hash = \".*\"#hash = \"$2\"#g" "$1"
|
||||
}
|
||||
|
||||
replace_version_in_file() {
|
||||
# $1: file
|
||||
# $2: new version
|
||||
sed -i "s#version = \".*\";#version = \"$2\";#g" "$1"
|
||||
}
|
||||
|
||||
MIRU_LINUX_HASH="$(get_hash "https://github.com/ThaUnknown/miru/releases/download/v${MIRU_LATEST_VER}/linux-Miru-${MIRU_LATEST_VER}.AppImage")"
|
||||
MIRU_DARWIN_HASH="$(get_hash "https://github.com/ThaUnknown/miru/releases/download/v${MIRU_LATEST_VER}/mac-Miru-${MIRU_LATEST_VER}-mac.zip")"
|
||||
|
||||
replace_hash_in_file "$LINUX_NIX" "$MIRU_LINUX_HASH"
|
||||
replace_hash_in_file "$DARWIN_NIX" "$MIRU_DARWIN_HASH"
|
||||
|
||||
replace_version_in_file "$PACKAGE_NIX" "$MIRU_LATEST_VER"
|
Loading…
Reference in New Issue
Block a user