diff options
Diffstat (limited to 'client.nix')
-rw-r--r-- | client.nix | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/client.nix b/client.nix new file mode 100644 index 0000000..67c083c --- /dev/null +++ b/client.nix @@ -0,0 +1,33 @@ +{ writeShellApplication, curl, openssh, sshpass, rsync, sshPassword, sshPort +, httpPort }: + +writeShellApplication { + name = "reMder-client"; + + runtimeInputs = [ curl openssh sshpass rsync ]; + + text = let + ssh = + "sshpass -p ${sshPassword} ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${ + toString sshPort + }"; + guest = "root@127.0.0.1"; + documentDir = "/home/root/.local/share/remarkable/xochitl"; + in '' + in="$1" + out="$2" + + in_basename="$(basename "$in")" + + ${ssh} ${guest} rm -rf ${documentDir} + ${ssh} ${guest} mkdir ${documentDir} + + rsync --rsh="${ssh}" "$in" ${guest}:${documentDir} + ${ssh} ${guest} "unzip '${documentDir}/$in_basename' -d ${documentDir}" + doc_id="$(${ssh} ${guest} find ${documentDir} -name '\*.metadata' -exec basename {} .metadata '\;')" + + curl -f -o "$out" "http://127.0.0.1:${ + toString httpPort + }/download/$doc_id/placeholder" + ''; +} |