3
0
Fork 0
forked from mirrors/nixpkgs

syncthing: new package and nixos module

This commit is contained in:
Matej Cotman 2014-04-03 18:54:10 +02:00 committed by Domen Kožar
parent 8b5c617237
commit 7df1ce5088
4 changed files with 127 additions and 0 deletions

View file

@ -198,6 +198,7 @@
./services/networking/sabnzbd.nix
./services/networking/searx.nix
./services/networking/supybot.nix
./services/networking/syncthing.nix
./services/networking/ssh/lshd.nix
./services/networking/ssh/sshd.nix
./services/networking/tftpd.nix

View file

@ -0,0 +1,73 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
cfg = config.services.syncthing;
in
{
###### interface
options = {
services.syncthing = {
enable = mkOption {
default = false;
description = ''
Whether to enable the Syncthing, self-hosted open-source alternative
to Dropbox and BittorrentSync. Initial interface will be
available on http://127.0.0.1:8080/.
'';
};
user = mkOption {
default = "syncthing";
description = ''
Syncthing will be run under this user (user must exist,
this can be your user name).
'';
};
dataDir = mkOption {
default = "/var/lib/syncthing";
description = ''
Path where the `.syncthing` (settings and keys) and `Sync`
(your synced files) directories will exist. This can be your home
directory.
'';
};
};
};
###### implementation
config = mkIf config.services.syncthing.enable {
systemd.services.syncthing =
{
description = "Syncthing service";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment.STNORESTART = "placeholder"; # do not self-restart
environment.HOME = "${config.services.syncthing.dataDir}";
serviceConfig = {
User = "${config.services.syncthing.user}";
ExecStart = "${pkgs.syncthing}/bin/syncthing -home=${config.services.syncthing.dataDir}/.syncthing";
Restart = "always";
};
};
environment.systemPackages = [ pkgs.syncthing ];
};
}

View file

@ -0,0 +1,51 @@
{ stdenv, fetchurl, fetchgit, go }:
stdenv.mkDerivation rec {
name = "syncthing-${version}";
version = "0.7.1";
src = fetchgit {
url = "git://github.com/calmh/syncthing.git";
rev = "refs/tags/v${version}";
sha256 = "1rja837kimiq15km8cridbm5yxvkm6mkvkwywdi76qf9rm0pcjl1";
};
buildInputs = [ go ];
buildPhase = ''
mkdir -p "./dependencies/src/github.com/calmh/syncthing"
cp -r "./auto" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./buffers" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./cid" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./discover" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./files" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./lamport" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./protocol" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./scanner" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./mc" "./dependencies/src/github.com/calmh/syncthing"
cp -r "./xdr" "./dependencies/src/github.com/calmh/syncthing"
export GOPATH="`pwd`/Godeps/_workspace:`pwd`/dependencies"
go test -cpu=1,2,4 ./...
mkdir ./bin
go build -o ./bin/syncthing -ldflags "-w -X main.Version v${version}" ./cmd/syncthing
go build -o ./bin/stcli -ldflags "-w -X main.Version v${version}" ./cmd/stcli
'';
installPhase = ''
ensureDir $out/bin
cp -r ./bin $out
'';
meta = {
homepage = http://syncthing.net/;
description = "Syncthing replaces Dropbox and BitTorrent Sync with something open, trustworthy and decentralized";
license = with stdenv.lib.licenses; mit;
maintainers = with stdenv.lib.maintainers; [ matejc ];
platforms = with stdenv.lib.platforms; linux;
};
}

View file

@ -9111,6 +9111,8 @@ let
gpgSupport = true;
};
syncthing = callPackage ../applications/networking/syncthing { };
# linux only by now
synergy = callPackage ../applications/misc/synergy { };