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