{
# Snowfall Lib provides a customized `lib` instance with access to your flake's library
# as well as the libraries available from your flake's inputs.
lib,
# You also have access to your flake's inputs.
inputs,

# All other arguments come from NixPkgs. You can use `pkgs` to pull packages or helpers
# programmatically or you may add the named attributes as arguments here.
pkgs, stdenv, ... }:

pkgs.writeShellApplication {
  name = "deploy-to-pianopi";

  runtimeInputs = with pkgs; [ rsync ];

  text = ''
    set -e
    set -x

    nix build .#packages.aarch64-linux.default --print-out-paths
    # copy dependencies etc
    nix copy --to ssh://julian@pianopi.local .#packages.aarch64-linux.default

    # This should be expanded on the client side
    # shellcheck disable=SC2029
    # ssh julian@pianopi.local ln -sf "$DERIVATION_PATH"/bin/\* /home/julian/.local/bin
    # ssh julian@pianopi.local nix profile install "$DERIVATION_PATH"

    rsync -ac result/bin/ julian@pianopi.local:/home/julian/.local/bin
  '';
}