2022-01-30 06:41:24 +01:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
|
|
echo "Usage: $0 <language name> [runtime name]"
|
|
|
|
echo
|
|
|
|
echo "language name: The name of the language to add, e.g. javascript"
|
|
|
|
echo "runtime name: The name of the runtime to add, e.g. node"
|
|
|
|
echo " In most cases runtime won't be required, e.g. python3 is both a language and runtime"
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
LANGUAGE=$1
|
|
|
|
RUNTIME=$1
|
|
|
|
NAME=$1
|
|
|
|
|
|
|
|
if [[ $# -eq 2 ]]; then
|
|
|
|
RUNTIME=$2
|
2022-01-31 05:46:48 +01:00
|
|
|
NAME=$RUNTIME-$LANGUAGE
|
2022-01-30 06:41:24 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if grep "./$NAME.nix" default.nix > /dev/null; then
|
|
|
|
echo "ERROR: $NAME already exists"
|
|
|
|
echo "Remove it from default.nix and retry if this is intended"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
sed -i '$d' default.nix
|
|
|
|
echo " \"$NAME\" = import ./$NAME.nix args;" >> default.nix
|
|
|
|
sed -e 's/%LANGUAGE%/'"$LANGUAGE"'/g' \
|
|
|
|
-e 's/%RUNTIME%/'"$RUNTIME"'/g' \
|
2022-01-31 05:18:12 +01:00
|
|
|
-e 's/%NAME%/'"$NAME"'/g' \
|
2022-01-30 06:41:24 +01:00
|
|
|
.scaffold.nix > $NAME.nix
|
|
|
|
echo "}" >> default.nix
|
|
|
|
|
2022-06-05 11:31:49 +02:00
|
|
|
git add $NAME.nix default.nix
|
2022-01-31 05:18:12 +01:00
|
|
|
|
2022-01-30 06:41:24 +01:00
|
|
|
echo "Scaffolded $NAME"
|
|
|
|
echo "Edit $NAME.nix to get started"
|
2022-01-31 05:18:12 +01:00
|
|
|
echo "Once you are done, run ./piston test $NAME to test it"
|
2022-06-05 11:31:49 +02:00
|
|
|
fi
|