From 2e2aed71002ade3bc5291faea27470cbb43be204 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 8 Apr 2022 18:44:02 +0200 Subject: [PATCH] wiki-js: add update script --- pkgs/servers/web-apps/wiki-js/default.nix | 5 ++++- pkgs/servers/web-apps/wiki-js/update.sh | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 pkgs/servers/web-apps/wiki-js/update.sh diff --git a/pkgs/servers/web-apps/wiki-js/default.nix b/pkgs/servers/web-apps/wiki-js/default.nix index f4e7775c400f..0d70a6b0f73c 100644 --- a/pkgs/servers/web-apps/wiki-js/default.nix +++ b/pkgs/servers/web-apps/wiki-js/default.nix @@ -21,7 +21,10 @@ stdenv.mkDerivation rec { runHook postInstall ''; - passthru.tests = { inherit (nixosTests) wiki-js; }; + passthru = { + tests = { inherit (nixosTests) wiki-js; }; + updateScript = ./update.sh; + }; meta = with lib; { homepage = "https://js.wiki/"; diff --git a/pkgs/servers/web-apps/wiki-js/update.sh b/pkgs/servers/web-apps/wiki-js/update.sh new file mode 100755 index 000000000000..63015800e691 --- /dev/null +++ b/pkgs/servers/web-apps/wiki-js/update.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl common-updater-scripts + +oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion wiki-js" | tr -d '"')" +latestTag="$(git ls-remote --tags --sort="v:refname" https://github.com/Requarks/wiki.git | tail -1 | awk '{ print $2 }' | sed -E "s,^refs/tags/v(.*)$,\1,")" + +targetVersion="${1:-$latestTag}" +if [ ! "${oldVersion}" = "${targetVersion}" ]; then + update-source-version wiki-js "${targetVersion}" + nix-build -A wiki-js +else + echo "wiki-js is already up-to-date" +fi