clan-homepage/flake-parts/deploy.nix
2024-04-16 14:51:38 +02:00

36 lines
712 B
Nix

{
perSystem = {
lib,
pkgs,
self',
...
}: let
deployScript = pkgs.writeShellScript "deploy.sh" ''
export PATH="${lib.makeBinPath [
pkgs.coreutils
pkgs.openssh
pkgs.rsync
]}"
if [ -n "$SSH_HOMEPAGE_KEY" ]; then
echo "$SSH_HOMEPAGE_KEY" > ./ssh_key
chmod 600 ./ssh_key
sshExtraArgs="-i ./ssh_key"
else
sshExtraArgs=
fi
rsync \
-e "ssh -o StrictHostKeyChecking=no $sshExtraArgs" \
-a ${self'.packages.default}/ \
www@clan.lol:/var/www/clan.lol
if [ -e ./ssh_key ]; then
rm ./ssh_key
fi
'';
in {
apps.deploy.program = "${deployScript}";
};
}