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 --- server.nix | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 server.nix (limited to 'server.nix') diff --git a/server.nix b/server.nix new file mode 100644 index 0000000..31462cd --- /dev/null +++ b/server.nix @@ -0,0 +1,132 @@ +{ fetchurl, writeText, libguestfs-with-appliance, pkgsCross, qemu, runCommand +, writeShellApplication, sshPassword, sshPort, httpPort }: +let + updateName = "remarkable-ct-prototype-image-3.16.1.0-ferrari-public"; + + updateArchive = fetchurl { + url = + # TODO: this is not an official source. might be worth authenticating the updates + "https://storage.googleapis.com/remarkable-versions/${updateName}.swu"; + hash = ""; + }; + + xochitlConfig = writeText "xochitl.conf" '' + [General] + DeveloperPassword=${sshPassword} + wifion=false + WebInterfaceEnabled=true + IdleSuspendDelay=0 + SuspendPowerOffDelay=0 + ''; + + usbMacAddr = "52:54:00:12:34:56"; + + ifnameUdevRule = writeText "70-persistent-net.rules" '' + SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", \ + ATTR{address}=="${usbMacAddr}", \ + ATTR{type}=="1", KERNEL=="eth*", NAME="usb0" + ''; + + xochitlService = 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 # TODO uncomment? + + [Install] + WantedBy=multi-user.target + ''; + + fakefbdev = pkgsCross.remarkable2.gcc11Stdenv.mkDerivation { + name = "fakefbdev"; + src = ./fakefbdev; + + installFlags = [ "DESTDIR=${placeholder "out"}" ]; + }; + + rootfsImage = runCommand "rm-rootfs.ext4" '' + cpio -i --file ${updateArchive} + gzip -dc ${updateName}.ext4.verity.gz > $out + ''; + + diskImage = runCommand "rm-disk.qcow2" { + nativeBuildInputs = [ qemu libguestfs-with-appliance ]; + } '' + qemu-img create -f qcow2 $out 8G + + guestfish --rw --blocksize=512 --add $out <