summary refs log tree commit diff
path: root/pkgs/applications/networking
diff options
context:
space:
mode:
authorJoachim Fasting <joachifm@fastmail.fm>2016-05-06 00:55:32 +0200
committerJoachim Fasting <joachifm@fastmail.fm>2016-05-06 01:03:04 +0200
commitaa478b5021ea0bb7b708861637c3ddf7a0f3b850 (patch)
tree39a3415f0944591716e841697bfd7155b87f60e2 /pkgs/applications/networking
parente4bd66c8f0b7e64a23db9ef04fc7059701eab599 (diff)
downloadnixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar.gz
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar.bz2
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar.lz
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar.xz
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.tar.zst
nixpkgs-aa478b5021ea0bb7b708861637c3ddf7a0f3b850.zip
bittorrentSync: factor out common parts
Diffstat (limited to 'pkgs/applications/networking')
-rw-r--r--pkgs/applications/networking/bittorrentsync/1.4.x.nix45
-rw-r--r--pkgs/applications/networking/bittorrentsync/2.0.x.nix44
-rw-r--r--pkgs/applications/networking/bittorrentsync/generic.nix40
3 files changed, 52 insertions, 77 deletions
diff --git a/pkgs/applications/networking/bittorrentsync/1.4.x.nix b/pkgs/applications/networking/bittorrentsync/1.4.x.nix
index 6c72937d6b7..9d57cdaaf20 100644
--- a/pkgs/applications/networking/bittorrentsync/1.4.x.nix
+++ b/pkgs/applications/networking/bittorrentsync/1.4.x.nix
@@ -1,42 +1,9 @@
-{ stdenv, fetchurl, patchelf }:
+{ stdenv, fetchurl, ... } @ args:
 
-let
-  arch = if stdenv.system == "x86_64-linux" then "x64"
-    else if stdenv.system == "i686-linux" then "i386"
-    else throw "Bittorrent Sync for: ${stdenv.system} not supported!";
-
-  sha256 = if stdenv.system == "x86_64-linux" then "0bw3ds3ndcnkry5mpv645z2bfi5z387bh0f7b35blxq1yv93r83f"
-    else if stdenv.system == "i686-linux"     then "1qwaj7l7nsd4afx7ksb4b1c22mki9qa40803v9x1a8bhbdfhkczk"
-    else throw "Bittorrent Sync for: ${stdenv.system} not supported!";
-
-  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
-in
-stdenv.mkDerivation rec {
-  name = "btsync-${version}";
+import ./generic.nix (args // {
   version = "1.4.111";
-
-  src  = fetchurl {
-    url  = "http://syncapp.bittorrent.com/${version}/btsync_${arch}-${version}.tar.gz";
-    inherit sha256;
-  };
-
-  dontStrip   = true; # Don't strip, otherwise patching the rpaths breaks
-  sourceRoot  = ".";
-  buildInputs = [ patchelf ];
-
-  installPhase = ''
-    mkdir -p "$out/bin/"
-    cp -r "btsync" "$out/bin/"
-
-    patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --set-rpath ${libPath} "$out/bin/btsync"
-  '';
-
-  meta = {
-    description = "Automatically sync files via secure, distributed technology";
-    homepage    = "http://www.bittorrent.com/sync";
-    license     = stdenv.lib.licenses.unfreeRedistributable;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ iElectric thoughtpolice ];
+  sha256s = {
+    "x86_64-linux" = "0bw3ds3ndcnkry5mpv645z2bfi5z387bh0f7b35blxq1yv93r83f";
+    "i686-linux"   = "1qwaj7l7nsd4afx7ksb4b1c22mki9qa40803v9x1a8bhbdfhkczk";
   };
-}
+})
diff --git a/pkgs/applications/networking/bittorrentsync/2.0.x.nix b/pkgs/applications/networking/bittorrentsync/2.0.x.nix
index c99b2570cf6..f8ba6a5c5f6 100644
--- a/pkgs/applications/networking/bittorrentsync/2.0.x.nix
+++ b/pkgs/applications/networking/bittorrentsync/2.0.x.nix
@@ -1,41 +1,9 @@
-{ stdenv, fetchurl }:
+{ stdenv, fetchurl, ... } @ args:
 
-let
-  arch = if stdenv.system == "x86_64-linux" then "x64"
-    else if stdenv.system == "i686-linux" then "i386"
-    else throw "Bittorrent Sync for: ${stdenv.system} not supported!";
-
-  sha256 = if stdenv.system == "x86_64-linux" then "1hnw6bv60xrnc733gm1ilywc0y93k2g6bmwgnww9qk7ivbvi6pd1"
-    else if stdenv.system == "i686-linux" then     "0hj8nbq6mava15m1hxaqq371fqk0whdx5iqsbnppyci0jjnr4qv1"
-    else throw "Bittorrent Sync for: ${stdenv.system} not supported!";
-
-  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
-in
-stdenv.mkDerivation rec {
-  name = "btsync-${version}";
+import ./generic.nix (args // {
   version = "2.3.7";
-
-  src  = fetchurl {
-    url  = "https://download-cdn.getsync.com/${version}/linux-${arch}/BitTorrent-Sync_${arch}.tar.gz";
-    inherit sha256;
-  };
-
-  dontStrip   = true; # Don't strip, otherwise patching the rpaths breaks
-  sourceRoot  = ".";
-
-  installPhase = ''
-    mkdir -p "$out/bin/"
-    cp -r "btsync" "$out/bin/"
-
-    patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
-      --set-rpath ${libPath} "$out/bin/btsync"
-  '';
-
-  meta = {
-    description = "Automatically sync files via secure, distributed technology";
-    homepage    = https://www.getsync.com/;
-    license     = stdenv.lib.licenses.unfreeRedistributable;
-    platforms   = stdenv.lib.platforms.linux;
-    maintainers = with stdenv.lib.maintainers; [ iElectric thoughtpolice cwoac ];
+  sha256s = {
+    "x86_64-linux" = "1hnw6bv60xrnc733gm1ilywc0y93k2g6bmwgnww9qk7ivbvi6pd1";
+    "i686-linux"   = "0hj8nbq6mava15m1hxaqq371fqk0whdx5iqsbnppyci0jjnr4qv1";
   };
-}
+})
diff --git a/pkgs/applications/networking/bittorrentsync/generic.nix b/pkgs/applications/networking/bittorrentsync/generic.nix
new file mode 100644
index 00000000000..6d8735609ea
--- /dev/null
+++ b/pkgs/applications/networking/bittorrentsync/generic.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, version, sha256s, ... } @ args:
+
+let
+  arch = {
+    "x86_64-linux" = "x64";
+    "i686-linux" = "i386";
+  }.${stdenv.system};
+  libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
+in
+
+stdenv.mkDerivation rec {
+  name = "btsync-${version}";
+  inherit version;
+
+  src = fetchurl {
+    # annoyingly, downloads for 1.4 and 2.3 do not follow the same URL layout; this is
+    # a simple work-around, in place of overriding the url in the caller.
+    urls = [
+      "https://download-cdn.getsync.com/${version}/linux-${arch}/BitTorrent-Sync_${arch}.tar.gz"
+      "http://syncapp.bittorrent.com/${version}/btsync_${arch}-${version}.tar.gz"
+    ];
+    sha256 = sha256s.${stdenv.system};
+  };
+
+  dontStrip = true; # Don't strip, otherwise patching the rpaths breaks
+  sourceRoot = ".";
+
+  installPhase = ''
+    install -D btsync "$out/bin/btsync"
+    patchelf --interpreter "$(< $NIX_CC/nix-support/dynamic-linker)" --set-rpath ${libPath} "$out/bin/btsync"
+  '';
+
+  meta = {
+    description = "Automatically sync files via secure, distributed technology";
+    homepage    = https://www.getsync.com/;
+    license     = stdenv.lib.licenses.unfreeRedistributable;
+    platforms   = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ iElectric thoughtpolice cwoac ];
+  };
+}