woodpecker-plugin-nix-attic/entrypoint.nix
Gabor Pihaj 4ad3c86c7a
fix: create the runner script outside of the workspace (#9)
Reviewed-on: https://git.vdx.hu/voidcontext/woodpecker-plugin-nix-attic/pulls/9
Co-authored-by: Gabor Pihaj <gabor.pihaj@gmail.com>
Co-committed-by: Gabor Pihaj <gabor.pihaj@gmail.com>
2023-09-30 18:15:22 +00:00

35 lines
792 B
Nix

{pkgs, ...}:
pkgs.writeShellApplication {
name = "woodpecker-nix-attic-entrypoint";
text = ''
cat << EOF >> /etc/nix/nix.conf
experimental-features = nix-command flakes
trusted-substituters = $PLUGIN_BINARY_CACHE
extra-trusted-public-keys = $PLUGIN_BINARY_CACHE_PUBLIC_KEY
extra-substituters = $PLUGIN_BINARY_CACHE
netrc-file = /tmp/netrc
EOF
if [[ $PLUGIN_BINARY_CACHE =~ ^https?:\/\/([^\/]+) ]]; then
machine=''${BASH_REMATCH[1]}
cat << EOF >> /tmp/netrc
machine $machine
password $PLUGIN_BINARY_CACHE_TOKEN
EOF
fi
SCRIPT_DIR=$(mktemp -d)
cat << EOF > "$SCRIPT_DIR"/run.sh
#!/usr/bin/env bash
export PATH=/bin:$PATH
set -x -e -o pipefail
$PLUGIN_SCRIPT
EOF
sh "$SCRIPT_DIR"/run.sh
'';
}