Merge pull request #7215 from cwoac/btsync2

Add support for btsync 2.x branch
This commit is contained in:
Arseniy Seroka 2015-04-06 18:50:05 +03:00
commit e52e160190
5 changed files with 70 additions and 4 deletions

View file

@ -54,6 +54,7 @@
copumpkin = "Dan Peebles <pumpkingod@gmail.com>";
coroa = "Jonas Hörsch <jonas@chaoflow.net>";
cstrahan = "Charles Strahan <charles.c.strahan@gmail.com>";
cwoac = "Oliver Matthews <oliver@codersoffortune.net>";
DamienCassou = "Damien Cassou <damien.cassou@gmail.com>";
davidrusu = "David Rusu <davidrusu.me@gmail.com>";
dbohdan = "Danyil Bohdan <danyil.bohdan@gmail.com>";

View file

@ -4,6 +4,9 @@ with lib;
let
cfg = config.services.btsync;
bittorrentSync = cfg.package;
listenAddr = cfg.httpListenAddr + ":" + (toString cfg.httpListenPort);
boolStr = x: if x then "true" else "false";
@ -57,7 +60,7 @@ let
''
{
"device_name": "${cfg.deviceName}",
"storage_path": "/var/lib/btsync/",
"storage_path": "${cfg.storagePath}",
"listening_port": ${toString cfg.listeningPort},
"use_gui": false,
@ -195,6 +198,24 @@ in
'';
};
package = mkOption {
type = types.package;
default = pkgs.bittorrentSync14;
example = literalExample "pkgs.bittorrentSync20";
description = ''
Branch of bittorrent sync to use.
'';
};
storagePath = mkOption {
type = types.path;
default = "/var/lib/btsync";
example = "/var/lib/btsync";
description = ''
Where to store the bittorrent sync files.
'';
};
apiKey = mkOption {
type = types.str;
default = "";
@ -258,7 +279,7 @@ in
users.extraUsers.btsync = {
description = "Bittorrent Sync Service user";
home = "/var/lib/btsync";
home = cfg.storagePath;
createHome = true;
uid = config.ids.uids.btsync;
group = "btsync";
@ -292,6 +313,6 @@ in
};
};
environment.systemPackages = [ pkgs.bittorrentSync ];
environment.systemPackages = [ cfg.package ];
};
}

View file

@ -0,0 +1,42 @@
{ stdenv, fetchurl, patchelf }:
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 "cbce76f73f47c23d9073644504fa454976629450d008354bd8faef1bddf368fd"
else if stdenv.system == "i686-linux" then "d3e8583c8a54cbeb34ea3621daf0498316a959d944b30f24aa4e518a851ecdeb"
else throw "Bittorrent Sync for: ${stdenv.system} not supported!";
libPath = stdenv.lib.makeLibraryPath [ stdenv.cc.libc ];
in
stdenv.mkDerivation rec {
name = "btsync-${version}";
version = "2.0.93";
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 cwoac ];
};
}

View file

@ -11767,7 +11767,9 @@ let
sxiv = callPackage ../applications/graphics/sxiv { };
bittorrentSync = callPackage ../applications/networking/bittorrentsync { };
bittorrentSync = bittorrentSync14;
bittorrentSync14 = callPackage ../applications/networking/bittorrentsync/1.4.x.nix { };
bittorrentSync20 = callPackage ../applications/networking/bittorrentsync/2.0.x.nix { };
copy-com = callPackage ../applications/networking/copy-com { };