diff options
author | Malte Voos <git@mal.tc> | 2025-02-19 21:16:51 +0100 |
---|---|---|
committer | Malte Voos <git@mal.tc> | 2025-02-19 21:16:51 +0100 |
commit | 0b2391075932d3b78a4e700cd464f068874b6127 (patch) | |
tree | 9f1770c2ce739473af400f4229aa68675a7236d3 | |
parent | e1bbd03df6324936fb63e676f562e47e51b0a837 (diff) | |
download | reMder-0b2391075932d3b78a4e700cd464f068874b6127.tar.gz reMder-0b2391075932d3b78a4e700cd464f068874b6127.zip |
update to firmware version v3.14.1.9
-rw-r--r-- | client.nix | 56 | ||||
-rw-r--r-- | flake.nix | 52 | ||||
-rw-r--r-- | server.nix | 155 |
3 files changed, 143 insertions, 120 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" + ''; } diff --git a/flake.nix b/flake.nix index ef3a18c..889e68e 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,31 @@ { - inputs = { - nixpkgs.url = "github:malte-v/nixpkgs/raspi3"; - flake-utils.url = "github:numtide/flake-utils"; - }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = import nixpkgs { inherit system; }; + outputs = + { self }: + { + overlays.default = + final: prev: + let + sshPassword = "1234"; + sshPort = 43922; + httpPort = 43980; - sshPassword = "1234"; - sshPort = 43922; - httpPort = 43980; + server = final.callPackage ./server.nix { + inherit sshPassword sshPort httpPort; + }; + client = final.callPackage ./client.nix { + inherit sshPassword sshPort httpPort; + }; - server = pkgs.callPackage ./server.nix { - inherit sshPassword sshPort httpPort; + reMder = final.symlinkJoin { + name = "reMder"; + paths = [ + client + server + ]; + }; + in + { + inherit reMder; }; - client = pkgs.callPackage ./client.nix { - inherit sshPassword sshPort httpPort; - }; - - reMder = pkgs.symlinkJoin { - name = "reMder"; - paths = [ client server ]; - }; - in { - packages = { inherit reMder; }; - - defaultPackage = reMder; - }); + }; } diff --git a/server.nix b/server.nix index b0d4e61..b301821 100644 --- a/server.nix +++ b/server.nix @@ -1,5 +1,16 @@ -{ fetchurl, writeText, libguestfs-with-appliance, pkgsCross, qemu -, runCommand, cpio, writeShellApplication, sshPassword, sshPort, httpPort }: +{ + fetchurl, + writeText, + libguestfs-with-appliance, + pkgsCross, + qemu, + runCommand, + cpio, + writeShellApplication, + sshPassword, + sshPort, + httpPort, +}: let updateName = "remarkable-production-memfault-image-3.14.1.9-rm2-public"; @@ -27,6 +38,14 @@ let ATTR{type}=="1", KERNEL=="eth*", NAME="usb0" ''; + usbNetworkConfig = writeText "10-usb.network" '' + [Match] + Name=usb* + + [Network] + DHCP=yes + ''; + xochitlService = writeText "xochitl.service" '' [Unit] Description=reMarkable main application @@ -53,75 +72,71 @@ let rootfsImage = runCommand "rm-rootfs.ext4" { nativeBuildInputs = [ cpio ]; } '' cpio -i --file ${updateArchive} - gzip -dc ${updateName}.ext4.gz > $out + gzip -dc ${updateName}.ext4.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 <<EOF - run - - # not the original partition table of the RM2 - part-init /dev/sda gpt - part-add /dev/sda p 2048 2099199 - part-add /dev/sda p 2099200 10487807 - part-add /dev/sda p 10487808 12584959 - part-add /dev/sda p 12584960 16775167 - - mkfs vfat /dev/sda1 - upload ${rootfsImage} /dev/sda2 - resize2fs /dev/sda2 - mkfs ext4 /dev/sda4 - - mount /dev/sda2 / - - copy-in ${kernel}/lib/modules /lib - - download /etc/fstab fstab - ! sed -i 's#mmcblk2#vda#' fstab - upload fstab /etc/fstab - - upload ${ifnameUdevRule} /etc/udev/rules.d/70-persistent-net.rules - - # download /lib/systemd/system/dhcpcd.service dhcpcd.service - # ! sed -i 's/wlan/usb/' dhcpcd.service - # upload dhcpcd.service /lib/systemd/system/dhcpcd.service TODO - - upload ${xochitlService} /lib/systemd/system/xochitl.service - - # delete stuff which hinders boot - # rm /lib/systemd/system/rm-sync.service - rm /lib/systemd/system/xochitl.service.d/xochitl-service-override.conf - # rm /lib/systemd/system/wpa_supplicant.service - # rm /lib/systemd/system/dropbear-wlan.socket - # rm /lib/systemd/system/keystore.service - # rm /lib/systemd/system/swapcryptor.service - # rm /lib/systemd/system/homecryptor.service - # rm /lib/systemd/system/growpart-home.service - # rm /lib/systemd/system/memfault-attributes.service - # rm /lib/systemd/system/swupdate.service - # rm /lib/systemd/system/swupdate.socket - # rm /lib/systemd/system/usb-ether-once.service - # rm /lib/systemd/system/marker-manager.service - # rm /lib/systemd/system/rm-sanity.timer - - upload ${fakefbdev}/lib/libfakefbdev.so /usr/lib/libfakefbdev.so - chmod 0755 /usr/lib/libfakefbdev.so - - mount /dev/sda4 /home - cp-a /etc/skel /home/root - - mkdir-p /home/root/.local/share/remarkable/xochitl - mkdir-p /home/root/.config/remarkable - upload ${xochitlConfig} /home/root/.config/remarkable/xochitl.conf - - EOF - ''; + diskImage = + runCommand "rm-disk.qcow2" + { + nativeBuildInputs = [ + qemu + libguestfs-with-appliance + ]; + } + '' + qemu-img create -f qcow2 $out 8G + + guestfish --rw --blocksize=512 --add $out <<EOF + run + + # not the original partition table of the RM2 + part-init /dev/sda gpt + part-add /dev/sda p 2048 2099199 + part-add /dev/sda p 2099200 10487807 + part-add /dev/sda p 10487808 12584959 + part-add /dev/sda p 12584960 16775167 + + mkfs vfat /dev/sda1 + upload ${rootfsImage} /dev/sda2 + resize2fs /dev/sda2 + mkfs ext4 /dev/sda4 + + mount /dev/sda2 / + + copy-in ${kernel}/lib/modules /lib + + download /etc/fstab fstab + ! sed -i 's/mmcblk2p/vda/' fstab + upload fstab /etc/fstab + + upload ${ifnameUdevRule} /etc/udev/rules.d/70-persistent-net.rules + upload ${usbNetworkConfig} /etc/systemd/network/10-usb.network + + upload ${xochitlService} /lib/systemd/system/xochitl.service + + # delete any systemd units that hinder or delay startup + rm /lib/systemd/system/kdump.service + rm /lib/systemd/system/wacom_flash.service + rm /lib/systemd/system/memfaultd.service + rm /lib/systemd/system/swupdate.service + rm /lib/systemd/system/swupdate.socket + rm /etc/systemd/system/multi-user.target.wants/busybox-ifplugd@usb1.service + + upload ${fakefbdev}/lib/libfakefbdev.so /usr/lib/libfakefbdev.so + chmod 0755 /usr/lib/libfakefbdev.so + + mount /dev/sda4 /home + cp-a /etc/skel /home/root + + mkdir-p /home/root/.local/share/remarkable/xochitl + mkdir-p /home/root/.config/remarkable + upload ${xochitlConfig} /home/root/.config/remarkable/xochitl.conf + + EOF + ''; -in writeShellApplication { +in +writeShellApplication { name = "reMder-server"; runtimeInputs = [ qemu ]; @@ -135,9 +150,7 @@ in writeShellApplication { -kernel ${kernel}/zImage \ -drive if=none,file=./reMder.qcow2,format=qcow2,id=hd \ -device virtio-blk-device,drive=hd \ - -netdev user,hostfwd=tcp::${toString sshPort}-:22,hostfwd=tcp::${ - toString httpPort - }-:80,id=net \ + -netdev user,hostfwd=tcp::${toString sshPort}-:22,hostfwd=tcp::${toString httpPort}-:80,id=net \ -device virtio-net-device,netdev=net,mac=${usbMacAddr} \ -append "console=ttyAMA0 rootfstype=ext4 root=/dev/vda2 rw rootwait init=/sbin/init" \ -serial mon:stdio \ |