aboutsummaryrefslogtreecommitdiff
path: root/client.nix
diff options
context:
space:
mode:
Diffstat (limited to 'client.nix')
-rw-r--r--client.nix56
1 files changed, 33 insertions, 23 deletions
diff --git a/client.nix b/client.nix
index 67c083c..ad58693 100644
--- a/client.nix
+++ b/client.nix
@@ -1,33 +1,43 @@
-{ writeShellApplication, curl, openssh, sshpass, rsync, sshPassword, sshPort
-, httpPort }:
+{
+ writeShellApplication,
+ curl,
+ openssh,
+ sshpass,
+ rsync,
+ sshPassword,
+ sshPort,
+ httpPort,
+}:
writeShellApplication {
name = "reMder-client";
- runtimeInputs = [ curl openssh sshpass rsync ];
+ 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"
+ 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")"
+ in_basename="$(basename "$in")"
- ${ssh} ${guest} rm -rf ${documentDir}
- ${ssh} ${guest} mkdir ${documentDir}
+ ${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 '\;')"
+ 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"
- '';
+ curl -f -o "$out" "http://127.0.0.1:${toString httpPort}/download/$doc_id/placeholder"
+ '';
}