My current workflow consist of building my remote server on a local nixos server and deploying it with:
nix copy --to ssh://root@somehost $(readlink result)
I’m now trying to auto-deploy everytime new code is pushed to a github repo.
I’ve set up a systemd service on the local server which triggers a bash script everytime a webhook request is received. The script stops on the nix-copy
command with this error:
error: executing 'nix-store --serve --write' on 'root@somehost': No such file or directory
error: cannot connect to 'root@somehost'
My guess is that it fails because of missing ssh credentials. When running the script manually it uses the private key from the ssh-agent, which I guess the systemd service is not able to use.
Is what I’m doing possible or are there any better alternatives?