From 806dc1ed43be0e638fc1d60881afdae812d0e4e6 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Thu, 19 Dec 2024 21:57:44 +0100 Subject: switch to rmpp image --- README.md | 2 +- client.nix | 33 ++++++++++ flake.lock | 17 ------ flake.nix | 204 ++++++++----------------------------------------------------- server.nix | 132 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 191 insertions(+), 197 deletions(-) create mode 100644 client.nix create mode 100644 server.nix diff --git a/README.md b/README.md index 44e6605..45b3933 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ interface's PDF rendering functionality to render your documents. As a result, it should be able to render any reMarkable document, in particular those created on newer firmware versions. -Currently, reMder uses firmware version v3.10.2.2063. +Currently, reMder uses firmware version v3.11.2.5. ## Building 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" + ''; +} diff --git a/flake.lock b/flake.lock index 814cffa..e1d7304 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "ddvk-stuff": { - "flake": false, - "locked": { - "lastModified": 1607373149, - "narHash": "sha256-CrP+/BP821xXz4avuGac1+qbNGhWBi1aUkTbpYxB17c=", - "owner": "ddvk", - "repo": "stuff", - "rev": "69158ac525b97294e1dc0e929bc19e50834741d9", - "type": "github" - }, - "original": { - "owner": "ddvk", - "repo": "stuff", - "type": "github" - } - }, "flake-utils": { "inputs": { "systems": "systems" @@ -52,7 +36,6 @@ }, "root": { "inputs": { - "ddvk-stuff": "ddvk-stuff", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 0f2ca48..97a3723 100644 --- a/flake.nix +++ b/flake.nix @@ -2,184 +2,30 @@ inputs = { nixpkgs.url = "github:malte-v/nixpkgs/libguestfs-appliance-fix"; flake-utils.url = "github:numtide/flake-utils"; - ddvk-stuff = { - url = "github:ddvk/stuff"; - flake = false; - }; }; - outputs = { self, nixpkgs, flake-utils, ddvk-stuff }: flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; - - updateArchive = pkgs.fetchurl { - url = "https://updates-download.cloud.remarkable.engineering/build/reMarkable%20Device/reMarkable2/3.10.2.2063/3.10.2.2063_reMarkable2-zKnOgdh8c5.signed"; - hash = "sha256-2w2hE4EG1i8B5TORn+n0gAIHNhsey/NHMsv+cCApHVQ="; - }; - - sshPassword = "1234"; - sshPort = 43922; - httpPort = 43980; - - xochitlConfig = pkgs.writeText "xochitl.conf" '' - [General] - DeveloperPassword=${sshPassword} - wifion=false - WebInterfaceEnabled=true - IdleSuspendDelay=0 - SuspendPowerOffDelay=0 - ''; - - usbMacAddr = "52:54:00:12:34:56"; - - ifnameUdevRule = pkgs.writeText "70-persistent-net.rules" '' - SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \ - ATTR{address}=="${usbMacAddr}", \ - ATTR{type}=="1", KERNEL=="eth*", NAME="usb0" - ''; - - xochitlService = pkgs.writeText "xochitl.service" '' - [Unit] - Description=reMarkable main application - After=home.mount network.target - - [Service] - ExecStart=/usr/bin/xochitl --system - Restart=always - # required to make xochitl run - Environment=LD_PRELOAD=/usr/lib/libfakefbdev.so - - [Install] - WantedBy=multi-user.target - ''; - - fakefbdev = pkgs.pkgsCross.remarkable2.gcc11Stdenv.mkDerivation { - name = "fakefbdev"; - src = ./fakefbdev; - - installFlags = [ "DESTDIR=${placeholder "out"}" ]; - }; - - rootfs = pkgs.runCommand "rm-rootfs.qcow2" - { - nativeBuildInputs = with pkgs; [ - (python3.withPackages (pypkgs: [ pypkgs.protobuf ])) - qemu - libguestfs-with-appliance - ]; - } '' - python3 ${ddvk-stuff}/extractor/extractor.py ${updateArchive} rootfs.ext4 - - qemu-img create -f qcow2 $out 8G - - guestfish --rw --blocksize=512 --add $out < $out + ''; + + diskImage = runCommand "rm-disk.qcow2" { + nativeBuildInputs = [ qemu libguestfs-with-appliance ]; + } '' + qemu-img create -f qcow2 $out 8G + + guestfish --rw --blocksize=512 --add $out <