From 6eaea5ca33cfaeea7a7fc9434e082ce1a9e0c6c5 Mon Sep 17 00:00:00 2001 From: Malte Voos Date: Wed, 3 Apr 2024 18:12:50 +0200 Subject: init --- flake.nix | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..09774ee --- /dev/null +++ b/flake.nix @@ -0,0 +1,163 @@ +{ + 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 + ''; + + 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" + ''; + + 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 <