diff --git a/pkgs/tools/networking/zerotierone/default.nix b/pkgs/tools/networking/zerotierone/default.nix index 3062befe2d3b..5a9239e2737c 100644 --- a/pkgs/tools/networking/zerotierone/default.nix +++ b/pkgs/tools/networking/zerotierone/default.nix @@ -1,15 +1,37 @@ -{ lib, stdenv, buildPackages, fetchFromGitHub, openssl, lzo, zlib, iproute2, ronn }: +{ lib +, stdenv +, rustPlatform +, fetchFromGitHub +, fetchurl -stdenv.mkDerivation rec { +, buildPackages +, iproute2 +, lzo +, openssl +, pkg-config +, ronn +, zlib +}: + +let pname = "zerotierone"; - version = "1.8.4"; + version = "1.8.9"; src = fetchFromGitHub { owner = "zerotier"; repo = "ZeroTierOne"; rev = version; - sha256 = "sha256-aM0FkcrSd5dEJVdJryIGuyWNFwvKH0SBfOuy4dIMK4A="; + sha256 = "sha256-N1VqzjaFJRJiSG4qHqRy4Fs8TlkUqyDoq0/3JQdGwfA="; }; +in stdenv.mkDerivation { + inherit pname version src; + + cargoDeps = rustPlatform.fetchCargoTarball { + src = "${src}/zeroidc"; + name = "${pname}-${version}"; + sha256 = "sha256-PDsJtz279P2IpgiL0T92IbcANeGSUnGKhEH1dj9VtbM="; + }; + postPatch = "cp ${src}/zeroidc/Cargo.lock Cargo.lock"; preConfigure = '' patchShebangs ./doc/build.sh @@ -20,9 +42,19 @@ stdenv.mkDerivation rec { --replace 'armv5' 'armv6' ''; - - nativeBuildInputs = [ ronn ]; - buildInputs = [ openssl lzo zlib iproute2 ]; + nativeBuildInputs = [ + pkg-config + ronn + rustPlatform.cargoSetupHook + rustPlatform.rust.cargo + rustPlatform.rust.rustc + ]; + buildInputs = [ + iproute2 + lzo + openssl + zlib + ]; enableParallelBuilding = true; @@ -30,18 +62,20 @@ stdenv.mkDerivation rec { doCheck = stdenv.hostPlatform == stdenv.buildPlatform; checkPhase = '' + runHook preCheck ./zerotier-selftest + runHook postCheck ''; - installPhase = '' - install -Dt "$out/bin/" zerotier-one - ln -s $out/bin/zerotier-one $out/bin/zerotier-idtool - ln -s $out/bin/zerotier-one $out/bin/zerotier-cli + installFlags = [ "DESTDIR=$$out/upstream" ]; - mkdir -p $man/share/man/man8 - for cmd in zerotier-one.8 zerotier-cli.1 zerotier-idtool.1; do - cat doc/$cmd | gzip -9n > $man/share/man/man8/$cmd.gz - done + postInstall = '' + mv $out/upstream/usr/sbin $out/bin + + mkdir -p $man/share + mv $out/upstream/usr/share/man $man/share/man + + rm -rf $out/upstream ''; outputs = [ "out" "man" ];