Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 asciidoctor, 3 fetchgit, 4 git, 5 installShellFiles, 6 jq, 7 lib, 8 makeWrapper, 9 man-db, 10 nixos, 11 nixosTests, 12 openssh, 13 radicle-node, 14 runCommand, 15 rustPlatform, 16 stdenv, 17 testers, 18 xdg-utils, 19}: 20rustPlatform.buildRustPackage rec { 21 pname = "radicle-node"; 22 version = "1.2.1"; 23 env.RADICLE_VERSION = version; 24 25 src = fetchgit { 26 url = "https://seed.radicle.xyz/z3gqcJUoA1n9HaHKufZs5FCSGazv5.git"; 27 rev = "refs/namespaces/z6MkireRatUThvd3qzfKht1S44wpm4FEWSSa4PRMTSQZ3voM/refs/tags/v${version}"; 28 hash = "sha256-pqYV3n/aKNbEDEp8v4oQUMMlsSiJZq/nh5gFP4KpZbM="; 29 leaveDotGit = true; 30 postFetch = '' 31 git -C $out rev-parse HEAD > $out/.git_head 32 git -C $out log -1 --pretty=%ct HEAD > $out/.git_time 33 rm -rf $out/.git 34 ''; 35 }; 36 37 cargoHash = "sha256-T457lXW0M2eO9R+8XyobUFVj4NOiXVSvtDztp1i0PS4="; 38 39 nativeBuildInputs = [ 40 asciidoctor 41 installShellFiles 42 makeWrapper 43 ]; 44 nativeCheckInputs = [ git ]; 45 46 preBuild = '' 47 export GIT_HEAD=$(<$src/.git_head) 48 export SOURCE_DATE_EPOCH=$(<$src/.git_time) 49 ''; 50 51 # tests regularly time out on aarch64 52 doCheck = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86; 53 54 preCheck = '' 55 export PATH=$PATH:$PWD/target/${stdenv.hostPlatform.rust.rustcTargetSpec}/release 56 # Tests want to open many files. 57 ulimit -n 4096 58 ''; 59 checkFlags = [ 60 "--skip=service::message::tests::test_node_announcement_validate" 61 "--skip=tests::test_announcement_relay" 62 "--skip=tests::commands::rad_remote" 63 # https://radicle.zulipchat.com/#narrow/stream/369277-heartwood/topic/Flaky.20tests/near/438352360 64 "--skip=tests::e2e::test_connection_crossing" 65 # https://radicle.zulipchat.com/#narrow/stream/369277-heartwood/topic/Clone.20Partial.20Fail.20Flake 66 "--skip=rad_clone_partial_fail" 67 ]; 68 69 postInstall = '' 70 for page in $(find -name '*.adoc'); do 71 asciidoctor -d manpage -b manpage $page 72 installManPage ''${page::-5} 73 done 74 ''; 75 76 postFixup = '' 77 for program in $out/bin/* ; 78 do 79 wrapProgram "$program" \ 80 --prefix PATH : "${ 81 lib.makeBinPath [ 82 git 83 man-db 84 openssh 85 xdg-utils 86 ] 87 }" 88 done 89 ''; 90 91 passthru.tests = 92 let 93 package = radicle-node; 94 in 95 { 96 version = testers.testVersion { inherit package; }; 97 basic = 98 runCommand "${package.name}-basic-test" 99 { 100 nativeBuildInputs = [ 101 jq 102 openssh 103 radicle-node 104 ]; 105 } 106 '' 107 set -e 108 export RAD_HOME="$PWD/.radicle" 109 mkdir -p "$RAD_HOME/keys" 110 ssh-keygen -t ed25519 -N "" -f "$RAD_HOME/keys/radicle" > /dev/null 111 jq -n '.node.alias |= "nix"' > "$RAD_HOME/config.json" 112 113 rad config > /dev/null 114 rad debug | jq -e ' 115 (.sshVersion | contains("${openssh.version}")) 116 and 117 (.gitVersion | contains("${git.version}")) 118 ' 119 120 touch $out 121 ''; 122 nixos-build = lib.recurseIntoAttrs { 123 checkConfig-success = 124 (nixos { 125 services.radicle.settings = { 126 node.alias = "foo"; 127 }; 128 }).config.services.radicle.configFile; 129 checkConfig-failure = 130 testers.testBuildFailure 131 (nixos { 132 services.radicle.settings = { 133 node.alias = null; 134 }; 135 }).config.services.radicle.configFile; 136 }; 137 nixos-run = nixosTests.radicle; 138 }; 139 140 meta = { 141 description = "Radicle node and CLI for decentralized code collaboration"; 142 longDescription = '' 143 Radicle is an open source, peer-to-peer code collaboration stack built on Git. 144 Unlike centralized code hosting platforms, there is no single entity controlling the network. 145 Repositories are replicated across peers in a decentralized manner, and users are in full control of their data and workflow. 146 ''; 147 homepage = "https://radicle.xyz"; 148 license = with lib.licenses; [ 149 asl20 150 mit 151 ]; 152 platforms = lib.platforms.unix; 153 maintainers = with lib.maintainers; [ 154 amesgen 155 lorenzleutgeb 156 ]; 157 mainProgram = "rad"; 158 }; 159}