From 3e0f7c24b962f332be771d3229dfb500f17cc91a Mon Sep 17 00:00:00 2001 From: stuebinm Date: Mon, 6 Jan 2025 02:49:16 +0100 Subject: git annex testremote in a nixos vm test i tried adding a 'loopback' mode to the specialremote itself, but that turned out to be too error-prone to really work, so for now running tests requires an sshd. --- default.nix | 8 ++++++++ test.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 default.nix create mode 100644 test.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..a150f68 --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +{ rustPlatform }: + +rustPlatform.buildRustPackage rec { + name = "git-annex-remote-remarkable2"; + RUSTC_BOOTSTRAP = 1; + src = ./.; + cargoLock.lockFile = ./Cargo.lock; +} diff --git a/test.nix b/test.nix new file mode 100644 index 0000000..b708c5e --- /dev/null +++ b/test.nix @@ -0,0 +1,53 @@ +{ nixpkgs ? import {} }: + +let inherit (import nixpkgs) + snakeOilPrivateKey snakeOilPublicKey snakeOilEd25519PrivateKey snakeOilEd25519PublicKey; +in + +nixpkgs.nixosTest { + name = "git-annex-specialremote-ramarkable2"; + + nodes.annex = { + + services.openssh = { + enable = true; + settings.PermitEmptyPasswords = true; + settings.PermitRootLogin = "yes"; + }; + + environment.systemPackages = with nixpkgs; [ + openssh + (callPackage ./default.nix {}) + gitFull + git-annex + ]; + + users.users.root = { + openssh.authorizedKeys.keys = [ snakeOilEd25519PublicKey ]; + }; + + }; + + testScript = '' + machine.start() + + machine.wait_for_open_port(22) + + machine.succeed("mkdir -p /root/.ssh") + machine.succeed("echo ${snakeOilEd25519PublicKey} > /root/.ssh/id_ed25519.pub") + machine.succeed("echo StrictHostKeyChecking no > /root/.ssh/config") + machine.succeed("cp ${snakeOilEd25519PrivateKey} /root/.ssh/id_ed25519") + machine.succeed("chmod 600 /root/.ssh/id_ed25519") + + machine.succeed("ssh localhost echo meow") + + machine.succeed("mkdir -p /root/.local/share/remarkable/xochitl") + + machine.succeed("mkdir -p repo && cd repo") + machine.succeed("git init") + machine.succeed("git annex init") + machine.succeed("git annex initremote localhost type=external externaltype=remarkable2 ssh_destination=localhost encryption=none exporttree=yes") + + machine.succeed("git annex testremote -d --fast localhost") + ''; +} -- cgit v1.2.3