From bd13ef5944a01f02006bcd4caafaaeba6a52d323 Mon Sep 17 00:00:00 2001
From: Charles Duffy <charles@dyfis.net>
Date: Sat, 22 Sep 2018 18:22:07 -0500
Subject: [PATCH] Introduce desync, an alternate implementation of casync
 (#47195)

desync isn't as feature-rich as casync, but has a focus on production usability
and implementation quality which may make it a more appropriate tool.
---
 maintainers/maintainer-list.nix               |   5 +
 .../networking/sync/desync/default.nix        |  27 ++++
 .../networking/sync/desync/deps.nix           | 129 ++++++++++++++++++
 pkgs/top-level/all-packages.nix               |   2 +
 4 files changed, 163 insertions(+)
 create mode 100644 pkgs/applications/networking/sync/desync/default.nix
 create mode 100644 pkgs/applications/networking/sync/desync/deps.nix

diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix
index 216d6dac74e..c3b32789382 100644
--- a/maintainers/maintainer-list.nix
+++ b/maintainers/maintainer-list.nix
@@ -678,6 +678,11 @@
     github = "Chaddai";
     name = "Chaddaï Fouché";
   };
+  chaduffy = {
+    email = "charles@dyfis.net";
+    github = "charles-dyfis-net";
+    name = "Charles Duffy";
+  };
   changlinli = {
     email = "mail@changlinli.com";
     github = "changlinli";
diff --git a/pkgs/applications/networking/sync/desync/default.nix b/pkgs/applications/networking/sync/desync/default.nix
new file mode 100644
index 00000000000..e8cca04203b
--- /dev/null
+++ b/pkgs/applications/networking/sync/desync/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, buildGoPackage, fetchFromGitHub }:
+
+buildGoPackage rec {
+  name = "desync-${version}";
+  version = "0.3.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/folbricht/desync";
+
+  src = fetchFromGitHub {
+    inherit rev;
+    owner = "folbricht";
+    repo = "desync";
+    sha256 = "1h2i6ai7q1mg2ysd3cnas96rb8g0bpp1v3hh7ip9nrfxhlplyyda";
+  };
+
+  goDeps = ./deps.nix;
+
+  meta = with stdenv.lib; {
+    description = "Content-addressed binary distribution system";
+    longDescription = "An alternate implementation of the casync protocol and storage mechanism with a focus on production-readiness";
+    homepage = https://github.com/folbricht/desync;
+    license = licenses.bsd3;
+    platforms = platforms.unix; # windows temporarily broken in 0.3.0 release
+    maintainers = [ maintainers.chaduffy ];
+  };
+}
diff --git a/pkgs/applications/networking/sync/desync/deps.nix b/pkgs/applications/networking/sync/desync/deps.nix
new file mode 100644
index 00000000000..2342fb76f0c
--- /dev/null
+++ b/pkgs/applications/networking/sync/desync/deps.nix
@@ -0,0 +1,129 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/datadog/zstd";
+    fetch = {
+      type = "git";
+      url = "https://github.com/datadog/zstd";
+      rev = "940731c8fc259059120b0e617a69d54dcd7c3eee";
+      sha256 = "04nmljnk54xm2k4ydhdiidazk3765jk8h4hvcsymkrsggrfyrjfx";
+    };
+  }
+  {
+    goPackagePath = "github.com/dchest/siphash";
+    fetch = {
+      type = "git";
+      url = "https://github.com/dchest/siphash";
+      rev = "34f201214d993633bb24f418ba11736ab8b55aa7";
+      sha256 = "08s076y7vmjqnq7jz0762hkm896r6r31v8b31a3gy0n8rfa01k8k";
+    };
+  }
+  {
+    goPackagePath = "github.com/folbricht/tempfile";
+    fetch = {
+      type = "git";
+      url = "https://github.com/folbricht/tempfile";
+      rev = "ee190cb5934293f187a9d43ee34de7d5cf9ceb83";
+      sha256 = "0vz08qvbniqxc24vhmcbq5ncnz97ncp4jbxgcf0hziazxfp114z3";
+    };
+  }
+  {
+    goPackagePath = "github.com/go-ini/ini";
+    fetch = {
+      type = "git";
+      url = "https://github.com/go-ini/ini";
+      rev = "fa25069db393aecc09b71267d0489b357781c860";
+      sha256 = "0fs1c48hni5gc1fyz65d138jpmqm1sqpb7vw5vhx0j6lmj1nf45z";
+    };
+  }
+  {
+    goPackagePath = "github.com/hanwen/go-fuse";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hanwen/go-fuse";
+      rev = "1d35017e97018335f348413b3aeed67468d80f7b";
+      sha256 = "11rggvkd6lc5lcpsfvc9iip4z9cingzpkpshaskv2cirbxdynyi8";
+    };
+  }
+  {
+    goPackagePath = "github.com/kr/fs";
+    fetch = {
+      type = "git";
+      url = "https://github.com/kr/fs";
+      rev = "1455def202f6e05b95cc7bfc7e8ae67ae5141eba";
+      sha256 = "11zg176x9hr9q7fsk95r6q0wf214gg4czy02slax4x56n79g6a7q";
+    };
+  }
+  {
+    goPackagePath = "github.com/minio/minio-go";
+    fetch = {
+      type = "git";
+      url = "https://github.com/minio/minio-go";
+      rev = "f01ef22c977052d716c74724874f932a16f047bb";
+      sha256 = "0pn1likcwnzb2j4hi4r1ib3xlp31h2vgwyc7xnm1iv7f8l4gk2hc";
+    };
+  }
+  {
+    goPackagePath = "github.com/mitchellh/go-homedir";
+    fetch = {
+      type = "git";
+      url = "https://github.com/mitchellh/go-homedir";
+      rev = "ae18d6b8b3205b561c79e8e5f69bff09736185f4";
+      sha256 = "0f0z0aa4wivk4z1y503dmnw0k0g0g403dly8i4q263gfshs82sbq";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/errors";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/errors";
+      rev = "c059e472caf75dbe73903f6521a20abac245b17f";
+      sha256 = "07xg8ym776j2w0k8445ii82lx8yz358cp1z96r739y13i1anqdzi";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/sftp";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/sftp";
+      rev = "08de04f133f27844173471167014e1a753655ac8";
+      sha256 = "090q4xmjbllwl3rpj1hzp0iw3qw1yvp6r3kf5cgw44ai57z96271";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "0e37d006457bf46f9e6692014ba72ef82c33022c";
+      sha256 = "1fj8rvrhgv5j8pmckzphvm3sqkzhcqp3idkxvgv13qrjdfycsa5r";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/net";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/net";
+      rev = "2f5d2388922f370f4355f327fcf4cfe9f5583908";
+      sha256 = "03s92ygxfrd2c1m4697sd6iksgbar6c007w1yf3h6wmd79vr5dxs";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "d47a0f3392421c5624713c9a19fe781f651f8a50";
+      sha256 = "01dqcv7vnynwhlmb28fn50svjb9kfj04nk7frvf7mh4jd3qnrsnv";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/text";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/text";
+      rev = "905a57155faa8230500121607930ebb9dd8e139c";
+      sha256 = "1qlvvb44j9ss3mkb5035i20xsd6sm0n05sqpqbi8gjw64g086zcb";
+    };
+  }
+]
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index fd91049b52f..6478ccb7741 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -1184,6 +1184,8 @@ with pkgs;
 
   deja-dup = callPackage ../applications/backup/deja-dup { };
 
+  desync = callPackage ../applications/networking/sync/desync { };
+
   devmem2 = callPackage ../os-specific/linux/devmem2 { };
 
   dbus-broker = callPackage ../os-specific/linux/dbus-broker { };