summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstuebinm2025-01-06 02:49:16 +0100
committerstuebinm2025-01-06 02:52:17 +0100
commit3e0f7c24b962f332be771d3229dfb500f17cc91a (patch)
treeca238ec93fe5a84986a97701f43795394c7acfeb
parentc363db95be7e2520e5c69c49733544fe98dff838 (diff)
git annex testremote in a nixos vm testHEADmain
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.
-rw-r--r--default.nix8
-rw-r--r--test.nix53
2 files changed, 61 insertions, 0 deletions
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 <nixpkgs> {} }:
+
+let inherit (import <nixpkgs/nixos/tests/ssh-keys.nix> 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")
+ '';
+}