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."
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}"
21 curl
-LO "$BOOKSTACK/composer.json"
22 curl
-LO "$BOOKSTACK/composer.lock"
24 composer2nix
--name "bookstack" \
25 --composition=composition.nix \
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" \
34 # fix composer-env.nix
35 sed -e "s/stdenv\.lib/lib/g" \
36 -e '3s/stdenv, writeTextFile/stdenv, lib, writeTextFile/' \
40 sed -e '7s/stdenv writeTextFile/stdenv lib writeTextFile/' \
44 echo "" >> composition.nix
45 echo "" >> php-packages.nix
48 nix-build
-A bookstack