summary refs log tree commit diff
path: root/pkgs/servers/web-apps/bookstack/update.sh
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/servers/web-apps/bookstack/update.sh
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/servers/web-apps/bookstack/update.sh')
-rwxr-xr-xpkgs/servers/web-apps/bookstack/update.sh50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkgs/servers/web-apps/bookstack/update.sh b/pkgs/servers/web-apps/bookstack/update.sh
new file mode 100755
index 00000000000..f61a5110590
--- /dev/null
+++ b/pkgs/servers/web-apps/bookstack/update.sh
@@ -0,0 +1,50 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash -p nix curl jq nix-update
+
+# check if composer2nix is installed
+if ! command -v composer2nix &> /dev/null; then
+  echo "Please install composer2nix (https://github.com/svanderburg/composer2nix) to run this script."
+  exit 1
+fi
+
+CURRENT_VERSION=$(nix eval --raw '(with import ../../../.. {}; bookstack.version)')
+TARGET_VERSION_REMOTE=$(curl https://api.github.com/repos/bookstackapp/bookstack/releases/latest | jq -r ".tag_name")
+TARGET_VERSION=${TARGET_VERSION_REMOTE:1}
+BOOKSTACK=https://github.com/bookstackapp/bookstack/raw/$TARGET_VERSION_REMOTE
+SHA256=$(nix-prefetch-url --unpack "https://github.com/bookstackapp/bookstack/archive/v$TARGET_VERSION/bookstack.tar.gz")
+
+if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then
+  echo "bookstack is up-to-date: ${CURRENT_VERSION}"
+  exit 0
+fi
+
+curl -LO "$BOOKSTACK/composer.json"
+curl -LO "$BOOKSTACK/composer.lock"
+
+composer2nix --name "bookstack" \
+  --composition=composition.nix \
+  --no-dev
+rm composer.json composer.lock
+
+# change version number
+sed -e "s/version =.*;/version = \"$TARGET_VERSION\";/g" \
+    -e "s/sha256 =.*;/sha256 = \"$SHA256\";/g" \
+    -i ./default.nix
+
+# fix composer-env.nix
+sed -e "s/stdenv\.lib/lib/g" \
+    -e '3s/stdenv, writeTextFile/stdenv, lib, writeTextFile/' \
+    -i ./composer-env.nix
+
+# fix composition.nix
+sed -e '7s/stdenv writeTextFile/stdenv lib writeTextFile/' \
+    -i composition.nix
+
+# fix missing newline
+echo "" >> composition.nix
+echo "" >> php-packages.nix
+
+cd ../../../..
+nix-build -A bookstack
+
+exit $?