summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorYegor Timoshenko <yegortimoshenko@riseup.net>2018-05-22 04:17:09 +0300
committerYegor Timoshenko <yegortimoshenko@riseup.net>2018-05-22 04:24:34 +0300
commite9e044abbb96012a0d4761272132f3d20ceb5577 (patch)
treea8ed30a829d520c17da3ace19f7de112ecde83bc /pkgs/tools
parented8267495423052600abc1bb4865be7fc9921f48 (diff)
downloadnixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar.gz
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar.bz2
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar.lz
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar.xz
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.tar.zst
nixlib-e9e044abbb96012a0d4761272132f3d20ceb5577.zip
wireguard-tools: clean up, wrap w/ wireguard-go on Darwin
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/networking/wireguard-tools/default.nix40
1 files changed, 19 insertions, 21 deletions
diff --git a/pkgs/tools/networking/wireguard-tools/default.nix b/pkgs/tools/networking/wireguard-tools/default.nix
index 8ebe18906f64..c43e7548364e 100644
--- a/pkgs/tools/networking/wireguard-tools/default.nix
+++ b/pkgs/tools/networking/wireguard-tools/default.nix
@@ -1,46 +1,44 @@
-{ stdenv, lib, fetchzip, libmnl, useSystemd ? stdenv.isLinux }:
+{ stdenv, fetchzip, libmnl ? null, makeWrapper ? null, wireguard-go ? null }:
 
-let
-  inherit (lib) optional optionalString;
-in
+with stdenv.lib;
 
 stdenv.mkDerivation rec {
   name = "wireguard-tools-${version}";
   version = "0.0.20180519";
 
   src = fetchzip {
-    url    = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${version}.tar.xz";
+    url = "https://git.zx2c4.com/WireGuard/snapshot/WireGuard-${version}.tar.xz";
     sha256 = "0pd04ia0wcm0f6di4gx5kflccc5j35d72j38l8jqpj8vinl6l070";
   };
 
-  preConfigure = "cd src";
+  sourceRoot = "source/src/tools";
 
-  buildInputs = optional stdenv.isLinux libmnl;
-
-  enableParallelBuilding = true;
+  nativeBuildInputs = [ (optional stdenv.isDarwin makeWrapper) ];
+  buildInputs = [ (optional stdenv.isLinux libmnl) ];
 
   makeFlags = [
-    "WITH_BASHCOMPLETION=yes"
-    "WITH_WGQUICK=yes"
-    "WITH_SYSTEMDUNITS=${if useSystemd then "yes" else "no"}"
     "DESTDIR=$(out)"
     "PREFIX=/"
-    "-C" "tools"
+    "WITH_BASHCOMPLETION=yes"
+    "WITH_SYSTEMDUNITS=yes"
+    "WITH_WGQUICK=yes"
   ];
 
-  buildPhase = "make tools";
-
-  postInstall = optionalString useSystemd ''
+  postFixup = ''
     substituteInPlace $out/lib/systemd/system/wg-quick@.service \
       --replace /usr/bin $out/bin
+  '' + optionalString stdenv.isDarwin ''
+    for f in $out/bin/*; do
+      wrapProgram $f --prefix PATH : ${wireguard-go}/bin
+    done
   '';
 
   meta = with stdenv.lib; {
-    homepage     = https://www.wireguard.com/;
+    description = "Tools for the WireGuard secure network tunnel";
     downloadPage = https://git.zx2c4.com/WireGuard/refs/;
-    description  = "Tools for the WireGuard secure network tunnel";
-    maintainers  = with maintainers; [ ericsagnes mic92 zx2c4 ];
-    license      = licenses.gpl2;
-    platforms    = platforms.unix;
+    homepage = https://www.wireguard.com/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ ericsagnes mic92 zx2c4 ];
+    platforms = platforms.unix;
   };
 }