Files
spotdl-auto/devenv.nix

39 lines
1.2 KiB
Nix

{ pkgs, lib, config, inputs, ... }: {
env.GREET = "SpotDL devenv";
packages = [pkgs.spotdl pkgs.python313Packages.spotipy pkgs.python313Packages.flask pkgs.openssl pkgs.ngrok ];
scripts.hello.exec = ''echo hello from $GREET ! '';
scripts.craftcerts.exec = ''
mkdir -p ssl # Use -p to avoid error if the directory exists
cd ssl
if [ ! -f ./openssl.cnf ]; then
echo "Creating certificates..."
openssl req -x509 -newkey rsa:2048 -keyout server.key -out server.cert -days 365 -nodes -config ../openssl.cnf > /dev/null 2>/dev/null
exit 1
fi
'';
scripts.download.exec = ''
ngrok http 8888 > /dev/null &
python ./geturl.py > geturl_logfile
url=$(cat -p geturl_logfile) # Capture the output of geturl.py
echo "STATEMENT AFTER GETURL"
while true; do
if [ $? -eq 0 ]; then
echo "SPOTDL ATTEMPT:"
spotdl "$url"
break
fi
echo "Error downloading, retrying..."
sleep 2
done
'';
enterShell = ''
hello
craftcerts
download
'';
}