at 23.11-beta 50 lines 1.5 kB view raw
1#!/usr/bin/env nix-shell 2#! nix-shell -i bash -p nix curl jq nix-update 3 4# check if composer2nix is installed 5if ! command -v composer2nix &> /dev/null; then 6 echo "Please install composer2nix (https://github.com/svanderburg/composer2nix) to run this script." 7 exit 1 8fi 9 10CURRENT_VERSION=$(nix eval -f ../../../.. --raw bookstack.version) 11TARGET_VERSION_REMOTE=$(curl https://api.github.com/repos/bookstackapp/bookstack/releases/latest | jq -r ".tag_name") 12TARGET_VERSION=${TARGET_VERSION_REMOTE:1} 13BOOKSTACK=https://github.com/bookstackapp/bookstack/raw/$TARGET_VERSION_REMOTE 14SHA256=$(nix-prefetch-url --unpack "https://github.com/bookstackapp/bookstack/archive/v$TARGET_VERSION/bookstack.tar.gz") 15 16if [[ "$CURRENT_VERSION" == "$TARGET_VERSION" ]]; then 17 echo "bookstack is up-to-date: ${CURRENT_VERSION}" 18 exit 0 19fi 20 21curl -LO "$BOOKSTACK/composer.json" 22curl -LO "$BOOKSTACK/composer.lock" 23 24composer2nix --name "bookstack" \ 25 --composition=composition.nix \ 26 --no-dev 27rm composer.json composer.lock 28 29# change version number 30sed -e "s/version =.*;/version = \"$TARGET_VERSION\";/g" \ 31 -e "s/sha256 =.*;/sha256 = \"$SHA256\";/g" \ 32 -i ./default.nix 33 34# fix composer-env.nix 35sed -e "s/stdenv\.lib/lib/g" \ 36 -e '3s/stdenv, writeTextFile/stdenv, lib, writeTextFile/' \ 37 -i ./composer-env.nix 38 39# fix composition.nix 40sed -e '7s/stdenv writeTextFile/stdenv lib writeTextFile/' \ 41 -i composition.nix 42 43# fix missing newline 44echo "" >> composition.nix 45echo "" >> php-packages.nix 46 47cd ../../../.. 48nix-build -A bookstack 49 50exit $?