about summary refs log tree commit diff
path: root/pkgs/by-name/ra
diff options
context:
space:
mode:
authorLorenz Leutgeb <lorenz@leutgeb.xyz>2024-05-22 19:01:07 +0200
committerLorenz Leutgeb <lorenz@leutgeb.xyz>2024-06-04 21:58:35 +0200
commit3a4a5cbaf3edbcb7467739be12e5f33bfcad8b0e (patch)
tree040db9cabb0be6b03a4b6dade6fc9fe8eb8d8abd /pkgs/by-name/ra
parent0e6040b0fa719f5e062bf4119aff3553f4d9a972 (diff)
radicle-node: Wrappers and a better package test
Diffstat (limited to 'pkgs/by-name/ra')
-rw-r--r--pkgs/by-name/ra/radicle-node/package.nix53
1 files changed, 46 insertions, 7 deletions
diff --git a/pkgs/by-name/ra/radicle-node/package.nix b/pkgs/by-name/ra/radicle-node/package.nix
index 8044e41d8e443..3d93f596c2e18 100644
--- a/pkgs/by-name/ra/radicle-node/package.nix
+++ b/pkgs/by-name/ra/radicle-node/package.nix
@@ -1,13 +1,19 @@
-{ lib
-, stdenv
+{ asciidoctor
+, darwin
 , fetchgit
-, asciidoctor
 , git
 , installShellFiles
+, jq
+, lib
+, makeWrapper
+, man-db
+, openssh
+, radicle-node
+, runCommand
 , rustPlatform
+, stdenv
 , testers
-, radicle-node
-, darwin
+, xdg-utils
 }: rustPlatform.buildRustPackage rec {
   pname = "radicle-node";
   version = "1.0.0-rc.9";
@@ -20,7 +26,7 @@
   };
   cargoHash = "sha256-UM9eDWyeewWPq3+z0JWqdAsCxx6EqytuYMwLXDHOC64=";
 
-  nativeBuildInputs = [ asciidoctor installShellFiles ];
+  nativeBuildInputs = [ asciidoctor installShellFiles makeWrapper ];
   nativeCheckInputs = [ git ];
   buildInputs = lib.optionals stdenv.buildPlatform.isDarwin [
     darwin.apple_sdk.frameworks.Security
@@ -45,7 +51,40 @@
     done
   '';
 
-  passthru.tests.version = testers.testVersion { package = radicle-node; };
+  postFixup = ''
+    for program in $out/bin/* ;
+    do
+      wrapProgram "$program" \
+        --prefix PATH : "${lib.makeBinPath [ git man-db openssh xdg-utils ]}"
+    done
+  '';
+
+  passthru.tests =
+    let
+      package = radicle-node;
+    in
+    {
+      version = testers.testVersion { inherit package; };
+      basic = runCommand "${package.name}-basic-test"
+        {
+          nativeBuildInputs = [ jq openssh radicle-node ];
+        } ''
+        set -e
+        export RAD_HOME="$PWD/.radicle"
+        mkdir -p "$RAD_HOME/keys"
+        ssh-keygen -t ed25519 -N "" -f "$RAD_HOME/keys/radicle" > /dev/null
+        jq -n '.node.alias |= "nix"' > "$RAD_HOME/config.json"
+
+        rad config > /dev/null
+        rad debug | jq -e '
+            (.sshVersion | contains("${openssh.version}"))
+          and
+            (.gitVersion | contains("${git.version}"))
+        '
+
+        touch $out
+      '';
+    };
 
   meta = {
     description = "Radicle node and CLI for decentralized code collaboration";