-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcnls-update.sh
More file actions
executable file
·44 lines (31 loc) · 1.21 KB
/
cnls-update.sh
File metadata and controls
executable file
·44 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch python3
VERSION=$(nix eval --raw --expr 'import ./cnls-version.nix' --impure)
echo "Got version: $VERSION"
NAME="cpp-notebook-language-server-$VERSION"
NEW_HASHES=$(
for system in aarch64-linux x86_64-linux x86_64-darwin aarch64-darwin; do
URL="https://github.com/codedownio/cpp-notebook-language-server/releases/download/v${VERSION}/cpp-notebook-language-server-${VERSION}-${system}.tar.gz"
HASH=$(nix-prefetch fetchzip --name "$NAME" --no-stripRoot --url "$URL" 2>/dev/null)
echo >&2 "$URL -> $HASH"
echo " \"$system\" = fetchzip {"
echo " name = \"$NAME\";"
echo " stripRoot = false;"
echo " url = \"$URL\";"
echo " hash = \"$HASH\";"
echo " };"
done
)
py_script=$(cat <<END
from operator import indexOf
import sys
input = sys.stdin.read()
with open("./cnls.nix", 'r') as f:
lines = f.readlines()
start_index = indexOf(map(lambda x: "HASHES_START" in x, lines), True)
end_index = indexOf(map(lambda x: "HASHES_END" in x, lines), True)
with open("./cnls.nix", 'w') as f:
f.write("".join(lines[0:(start_index+1)]) + input + "".join(lines[end_index:]))
END
)
echo "$NEW_HASHES" | python -c "$py_script"