clan-homepage/flake-parts/deploy.nix

36 lines
712 B
Nix
Raw Normal View History

2023-07-17 21:21:54 +00:00
{
perSystem = {
lib,
pkgs,
self',
...
}: let
2024-04-16 12:51:38 +00:00
deployScript = pkgs.writeShellScript "deploy.sh" ''
2023-07-17 21:21:54 +00:00
export PATH="${lib.makeBinPath [
pkgs.coreutils
2023-07-17 21:21:54 +00:00
pkgs.openssh
pkgs.rsync
]}"
2023-07-17 21:33:16 +00:00
if [ -n "$SSH_HOMEPAGE_KEY" ]; then
echo "$SSH_HOMEPAGE_KEY" > ./ssh_key
chmod 600 ./ssh_key
sshExtraArgs="-i ./ssh_key"
2023-07-17 21:33:16 +00:00
else
sshExtraArgs=
fi
rsync \
-e "ssh -o StrictHostKeyChecking=no $sshExtraArgs" \
-a ${self'.packages.default}/ \
2024-04-12 14:25:05 +00:00
www@clan.lol:/var/www/clan.lol
2023-07-19 18:37:32 +00:00
if [ -e ./ssh_key ]; then
rm ./ssh_key
fi
2023-07-17 21:21:54 +00:00
'';
in {
apps.deploy.program = "${deployScript}";
};
}