2021-09-18 10:52:07 +00:00
|
|
|
{ pname
|
|
|
|
, version
|
|
|
|
, homepage
|
|
|
|
, lib
|
2022-04-27 09:35:20 +00:00
|
|
|
, gitUpdater
|
2021-09-18 10:52:07 +00:00
|
|
|
, writers
|
|
|
|
, jq
|
|
|
|
, yarn
|
|
|
|
, yarn2nix
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-04-27 09:35:20 +00:00
|
|
|
updater = gitUpdater {
|
2021-09-18 10:52:07 +00:00
|
|
|
inherit pname version;
|
|
|
|
attrPath = lib.toLower pname;
|
|
|
|
|
|
|
|
# exclude prerelease versions
|
2022-04-27 09:35:20 +00:00
|
|
|
ignoredVersions = "-";
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
2022-10-06 18:32:54 +00:00
|
|
|
updateScript = builtins.elemAt updater.command 0;
|
|
|
|
updateArgs = map (lib.escapeShellArg) (builtins.tail updater.command);
|
2021-09-18 10:52:07 +00:00
|
|
|
in writers.writeBash "update-mirakurun" ''
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
WORKDIR="$(mktemp -d)"
|
|
|
|
cleanup() {
|
|
|
|
rm -rf "$WORKDIR"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
# bump the version
|
|
|
|
${updateScript} ${lib.concatStringsSep " " updateArgs}
|
|
|
|
|
|
|
|
# Get the path to the latest source. Note that we can't just pass the value
|
|
|
|
# of mirakurun.src directly because it'd be evaluated before we can run
|
|
|
|
# updateScript.
|
|
|
|
SRC="$(nix-build "${toString ../../../..}" --no-out-link -A mirakurun.src)"
|
|
|
|
if [[ "${version}" == "$(${jq}/bin/jq -r .version "$SRC/package.json")" ]]; then
|
|
|
|
echo "[INFO] Already using the latest version of ${pname}" >&2
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd "$WORKDIR"
|
|
|
|
|
|
|
|
cp "$SRC/package.json" package.json
|
|
|
|
"${yarn}/bin/yarn" install --ignore-scripts
|
|
|
|
|
|
|
|
"${yarn2nix}/bin/yarn2nix" > "${toString ./.}/yarn.nix"
|
|
|
|
cp yarn.lock "${toString ./.}/yarn.lock"
|
|
|
|
cp package.json "${toString ./.}/package.json"
|
|
|
|
''
|