about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/filesystems
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/tools/filesystems')
-rw-r--r--nixpkgs/pkgs/tools/filesystems/9pfs/default.nix31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/aefs/default.nix20
-rw-r--r--nixpkgs/pkgs/tools/filesystems/afpfs-ng/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/android-file-transfer/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/archivemount/default.nix22
-rw-r--r--nixpkgs/pkgs/tools/filesystems/avfs/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bashmount/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bcache-tools/bcache-udev-modern.patch52
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bcache-tools/default.nix57
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bcache-tools/fix-static.patch22
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bcachefs-tools/default.nix30
-rwxr-xr-xnixpkgs/pkgs/tools/filesystems/bees/bees-service-wrapper223
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bees/default.nix69
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bindfs/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/blobfuse/default.nix23
-rw-r--r--nixpkgs/pkgs/tools/filesystems/bonnie/default.nix18
-rw-r--r--nixpkgs/pkgs/tools/filesystems/boxfs/default.nix60
-rw-r--r--nixpkgs/pkgs/tools/filesystems/boxfs/work-around-API-borkage.patch15
-rw-r--r--nixpkgs/pkgs/tools/filesystems/btrfs-dedupe/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/btrfs-progs/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/filesystems/buttersink/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/0001-Makefile-env-Don-t-force-sbin.patch25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/0001-kv-RocksDBStore-API-break-additional.patch58
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/0002-fix-absolute-include-path.patch19
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/default.nix12
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/fix-pythonpath.patch31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ceph/generic.nix174
-rw-r--r--nixpkgs/pkgs/tools/filesystems/chunkfs/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ciopfs/default.nix22
-rw-r--r--nixpkgs/pkgs/tools/filesystems/convoy/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/cryfs/default.nix79
-rw-r--r--nixpkgs/pkgs/tools/filesystems/cryfs/skip-failing-test-large-malloc.patch34
-rw-r--r--nixpkgs/pkgs/tools/filesystems/cryfs/test-no-network.patch24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/curlftpfs/default.nix21
-rw-r--r--nixpkgs/pkgs/tools/filesystems/darling-dmg/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/filesystems/davfs2/default.nix35
-rw-r--r--nixpkgs/pkgs/tools/filesystems/davfs2/fix-sysconfdir.patch60
-rw-r--r--nixpkgs/pkgs/tools/filesystems/davfs2/isdir.patch30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/dislocker/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/filesystems/disorderfs/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/djmount/default.nix21
-rw-r--r--nixpkgs/pkgs/tools/filesystems/dosfstools/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/duff/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/filesystems/duperemove/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/e2fsprogs/default.nix54
-rw-r--r--nixpkgs/pkgs/tools/filesystems/e2tools/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/encfs/default.nix34
-rw-r--r--nixpkgs/pkgs/tools/filesystems/exfat/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ext4magic/default.nix39
-rw-r--r--nixpkgs/pkgs/tools/filesystems/extundelete/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/filesystems/f2fs-tools/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/f2fs-tools/f2fs-tools-cross-fix.patch27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/f3/default.nix39
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fatresize/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fatresize/fatresize_parted_nix.patch74
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fatsort/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fatsort/fatsort-Makefiles.patch31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/file-rename/default.nix23
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fsfs/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fuse-7z-ng/default.nix41
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fuseiso/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/filesystems/fusesmb/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/filesystems/gcsfuse/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/genext2fs/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/genimage/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/genromfs/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/gitfs/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/filesystems/glusterfs/default.nix195
-rw-r--r--nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch49
-rw-r--r--nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch156
-rw-r--r--nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-use-PATH-instead-of-hardcodes.patch138
-rw-r--r--nixpkgs/pkgs/tools/filesystems/go-mtpfs/default.nix20
-rw-r--r--nixpkgs/pkgs/tools/filesystems/go-mtpfs/deps.nix20
-rw-r--r--nixpkgs/pkgs/tools/filesystems/gocryptfs/default.nix50
-rw-r--r--nixpkgs/pkgs/tools/filesystems/gocryptfs/deps.nix66
-rw-r--r--nixpkgs/pkgs/tools/filesystems/gpart/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/filesystems/grive2/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/hfsprogs/default.nix45
-rw-r--r--nixpkgs/pkgs/tools/filesystems/httpfs/default.nix35
-rw-r--r--nixpkgs/pkgs/tools/filesystems/hubicfuse/default.nix29
-rw-r--r--nixpkgs/pkgs/tools/filesystems/idsk/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ifuse/default.nix31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/irods/common.nix55
-rw-r--r--nixpkgs/pkgs/tools/filesystems/irods/default.nix87
-rw-r--r--nixpkgs/pkgs/tools/filesystems/irods/irods_root_path.patch71
-rw-r--r--nixpkgs/pkgs/tools/filesystems/jfsutils/ar-fix.patch10
-rw-r--r--nixpkgs/pkgs/tools/filesystems/jfsutils/default.nix27
-rw-r--r--nixpkgs/pkgs/tools/filesystems/jfsutils/hardening-format.patch37
-rw-r--r--nixpkgs/pkgs/tools/filesystems/jfsutils/types.patch12
-rw-r--r--nixpkgs/pkgs/tools/filesystems/jmtpfs/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/lizardfs/default.nix70
-rw-r--r--nixpkgs/pkgs/tools/filesystems/lizardfs/remove-download-external.patch25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mergerfs/default.nix35
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mergerfs/tools.nix36
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mhddfs/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mhddfs/fix-format-security-error.patch12
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mkspiffs/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mkspiffs/presets.nix20
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mp3fs/default.nix32
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mp3fs/fix-statfs-operation.patch39
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mtdutils/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mtools/UNUSED-darwin.patch11
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mtools/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/mtpfs/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/filesystems/netatalk/default.nix60
-rw-r--r--nixpkgs/pkgs/tools/filesystems/netatalk/no-suid.patch11
-rw-r--r--nixpkgs/pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patch19
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nilfs-utils/default.nix57
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.nix50
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.patch51
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/cryptsetup.nix29
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/default.nix75
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/dmraid.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/lvm2.nix64
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/multipath-tools.nix36
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/parted.nix50
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyblock.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pykickstart.nix31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyparted.nix42
-rw-r--r--nixpkgs/pkgs/tools/filesystems/nixpart/default.nix21
-rw-r--r--nixpkgs/pkgs/tools/filesystems/ntfs-3g/default.nix56
-rw-r--r--nixpkgs/pkgs/tools/filesystems/rdfind/default.nix21
-rw-r--r--nixpkgs/pkgs/tools/filesystems/reiser4progs/default.nix31
-rw-r--r--nixpkgs/pkgs/tools/filesystems/reiserfsprogs/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/reiserfsprogs/reiserfsprogs-ar-fix.patch10
-rw-r--r--nixpkgs/pkgs/tools/filesystems/relfs/default.nix51
-rw-r--r--nixpkgs/pkgs/tools/filesystems/s3backer/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/s3fs/default.nix30
-rw-r--r--nixpkgs/pkgs/tools/filesystems/securefs/default.nix37
-rw-r--r--nixpkgs/pkgs/tools/filesystems/simg2img/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/smbnetfs/default.nix24
-rw-r--r--nixpkgs/pkgs/tools/filesystems/smbnetfs/default.upstream6
-rw-r--r--nixpkgs/pkgs/tools/filesystems/snapraid/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch90
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch83
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patch220
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/darwin.patch431
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/default.nix48
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfs/squashfs-tools-4.3-4k-align.patch92
-rw-r--r--nixpkgs/pkgs/tools/filesystems/squashfuse/default.nix33
-rw-r--r--nixpkgs/pkgs/tools/filesystems/sshfs-fuse/default.nix49
-rw-r--r--nixpkgs/pkgs/tools/filesystems/svnfs/default.nix28
-rw-r--r--nixpkgs/pkgs/tools/filesystems/tmsu/default.nix61
-rw-r--r--nixpkgs/pkgs/tools/filesystems/u3-tool/default.nix22
-rw-r--r--nixpkgs/pkgs/tools/filesystems/udftools/default.nix41
-rw-r--r--nixpkgs/pkgs/tools/filesystems/unionfs-fuse/default.nix44
-rw-r--r--nixpkgs/pkgs/tools/filesystems/unionfs-fuse/prevent-kill-on-shutdown.patch14
-rw-r--r--nixpkgs/pkgs/tools/filesystems/vmfs-tools/default.nix25
-rw-r--r--nixpkgs/pkgs/tools/filesystems/wdfs/default.nix19
-rw-r--r--nixpkgs/pkgs/tools/filesystems/xfsprogs/default.nix65
-rw-r--r--nixpkgs/pkgs/tools/filesystems/xtreemfs/default.nix70
-rw-r--r--nixpkgs/pkgs/tools/filesystems/yandex-disk/default.nix64
-rw-r--r--nixpkgs/pkgs/tools/filesystems/zerofree/default.nix26
-rw-r--r--nixpkgs/pkgs/tools/filesystems/zfstools/default.nix40
-rw-r--r--nixpkgs/pkgs/tools/filesystems/zkfuse/default.nix22
156 files changed, 6826 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/tools/filesystems/9pfs/default.nix b/nixpkgs/pkgs/tools/filesystems/9pfs/default.nix
new file mode 100644
index 000000000000..2e34c9dd4857
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/9pfs/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "9pfs-20150918";
+
+  src = fetchFromGitHub {
+    owner = "mischief";
+    repo = "9pfs";
+    rev = "7f4ca4cd750d650c1215b92ac3cc2a28041960e4";
+    sha256 = "007s2idsn6bspmfxv1qabj39ggkgvn6gwdbhczwn04lb4c6gh3xc";
+  };
+
+  preConfigure =
+    ''
+      substituteInPlace Makefile --replace '-g bin' ""
+      installFlagsArray+=(BIN=$out/bin MAN=$out/share/man/man1)
+      mkdir -p $out/bin $out/share/man/man1
+    '';
+
+  buildInputs = [ fuse ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = https://github.com/mischief/9pfs;
+    description = "FUSE-based client of the 9P network filesystem protocol";
+    maintainers = [ lib.maintainers.eelco ];
+    platforms = lib.platforms.linux;
+    license = with lib.licenses; [ lpl-102 bsd2 ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/aefs/default.nix b/nixpkgs/pkgs/tools/filesystems/aefs/default.nix
new file mode 100644
index 000000000000..9344ada8f93e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/aefs/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, fetchurl, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "aefs-0.4pre259-8843b7c";
+
+  src = fetchurl {
+    url = "http://tarballs.nixos.org/${name}.tar.bz2";
+    sha256 = "167hp58hmgdavg2mqn5dx1xgq24v08n8d6psf33jhbdabzx6a6zq";
+  };
+
+  buildInputs = [ fuse ];
+
+  meta = with stdenv.lib; {
+    homepage = https://nixos.org/~edolstra/aefs/;
+    description = "A cryptographic filesystem implemented in userspace using FUSE";
+    platforms = platforms.linux;
+    maintainers = [ maintainers.eelco ];
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/afpfs-ng/default.nix b/nixpkgs/pkgs/tools/filesystems/afpfs-ng/default.nix
new file mode 100644
index 000000000000..74ba47ceee1a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/afpfs-ng/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, fuse, readline, libgcrypt, gmp }:
+
+stdenv.mkDerivation rec {
+  name = "afpfs-ng-${version}";
+  version = "0.8.2";
+
+  src = fetchFromGitHub {
+    owner  = "simonvetter";
+    repo   = "afpfs-ng";
+    rev    = "f6e24eb73c9283732c3b5d9cb101a1e2e4fade3e";
+    sha256 = "125jx1rsqkiifcffyjb05b2s36rllckdgjaf1bay15k9gzhwwldz";
+  };
+
+  buildInputs = [ fuse readline libgcrypt gmp ];
+
+  meta = with stdenv.lib; {
+    homepage    = https://github.com/simonvetter/afpfs-ng;
+    description = "A client implementation of the Apple Filing Protocol";
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ rnhmjoj ];
+    platforms   = platforms.linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/android-file-transfer/default.nix b/nixpkgs/pkgs/tools/filesystems/android-file-transfer/default.nix
new file mode 100644
index 000000000000..6441ae5dbd1b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/android-file-transfer/default.nix
@@ -0,0 +1,27 @@
+{ lib, stdenv, fetchFromGitHub, cmake, fuse, readline, pkgconfig, qtbase }:
+
+stdenv.mkDerivation rec {
+  name = "android-file-transfer-${version}";
+  version = "3.7";
+  src = fetchFromGitHub {
+    owner = "whoozle";
+    repo = "android-file-transfer-linux";
+    rev = "v${version}";
+    sha256 = "0a388pqc0azgn0wy85wb1mjk3b5zb6vcr58l4warwfzhca400zn0";
+  };
+  buildInputs = [ cmake fuse readline pkgconfig qtbase ];
+  buildPhase = ''
+    cmake .
+    make
+  '';
+  installPhase = ''
+    make install
+  '';
+  meta = with stdenv.lib; {
+    description = "Reliable MTP client with minimalistic UI";
+    homepage = https://whoozle.github.io/android-file-transfer-linux/;
+    license = licenses.lgpl21;
+    maintainers = [ maintainers.xaverdh ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/archivemount/default.nix b/nixpkgs/pkgs/tools/filesystems/archivemount/default.nix
new file mode 100644
index 000000000000..18bde25267d3
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/archivemount/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, fuse, libarchive }:
+
+let
+  name = "archivemount-0.8.12";
+in
+stdenv.mkDerivation {
+  inherit name;
+
+  src = fetchurl {
+    url = "https://www.cybernoia.de/software/archivemount/${name}.tar.gz";
+    sha256 = "12fb8fcmd1zwvfgzx4pay47md5cr2kgxcgq82cm6skmq75alfzi4";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse libarchive ];
+
+  meta = {
+    description = "Gateway between FUSE and libarchive: allows mounting of cpio, .tar.gz, .tar.bz2 archives";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/avfs/default.nix b/nixpkgs/pkgs/tools/filesystems/avfs/default.nix
new file mode 100644
index 000000000000..5c44ef239630
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/avfs/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, pkgconfig, fuse, xz }:
+
+stdenv.mkDerivation rec {
+  name = "avfs-${version}";
+  version = "1.0.6";
+  src = fetchurl {
+    url = "mirror://sourceforge/avf/${version}/${name}.tar.bz2";
+    sha256 = "1hz39f7p5vw647xqk161v3nh88qnd599av6nfidpmkh1d9vkl6jc";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildInputs = [ fuse xz ];
+
+  configureFlags = [
+    "--enable-library"
+    "--enable-fuse"
+    "--disable-static"
+  ];
+
+  meta = {
+    homepage = http://avf.sourceforge.net/;
+    description = "Virtual filesystem that allows browsing of compressed files";
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/bashmount/default.nix b/nixpkgs/pkgs/tools/filesystems/bashmount/default.nix
new file mode 100644
index 000000000000..cd0f3ea23229
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bashmount/default.nix
@@ -0,0 +1,37 @@
+{stdenv, fetchFromGitHub}:
+
+stdenv.mkDerivation rec {
+  name = "bashmount-${version}";
+  version = "3.2.0";
+
+  src = fetchFromGitHub {
+    owner = "jamielinux";
+    repo = "bashmount";
+    rev = version;
+    sha256 = "0rki4s0jgz6vkywc6hcx9qa551r5bnjs7sw0rdh93k64l32kh644";
+  };
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bashmount $out/bin
+
+    mkdir -p $out/etc
+    cp bashmount.conf $out/etc
+
+    mkdir -p $out/share/man/man1
+    gzip -c -9 bashmount.1 > bashmount.1.gz
+    cp bashmount.1.gz $out/share/man/man1
+
+    mkdir -p $out/share/doc/bashmount
+    cp COPYING $out/share/doc/bashmount
+    cp NEWS    $out/share/doc/bashmount
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/jamielinux/bashmount;
+    description = "A menu-driven bash script for the management of removable media with udisks";
+    maintainers = [ maintainers.koral ];
+    license = licenses.gpl2;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/bcache-tools/bcache-udev-modern.patch b/nixpkgs/pkgs/tools/filesystems/bcache-tools/bcache-udev-modern.patch
new file mode 100644
index 000000000000..c6cf79785b73
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bcache-tools/bcache-udev-modern.patch
@@ -0,0 +1,52 @@
+This patch does two things:
+1) Drops probe-bcache, so now new util-linux detecting functionality is used.
+2) Drops bcache-register, using kmod (built in udev) and moving registering device
+   into rule using 'sh'.
+This reduces things that need to be present in initrd, replacing them with already
+existing functionality and reducing overall initrd size.
+
+diff --git a/69-bcache.rules b/69-bcache.rules
+index 5d28e70..6a52893 100644
+--- a/69-bcache.rules
++++ b/69-bcache.rules
+@@ -10,15 +10,11 @@ KERNEL=="fd*|sr*", GOTO="bcache_end"
+ # It recognised bcache (util-linux 2.24+)
+ ENV{ID_FS_TYPE}=="bcache", GOTO="bcache_backing_found"
+ # It recognised something else; bail
+-ENV{ID_FS_TYPE}=="?*", GOTO="bcache_backing_end"
+-
+-# Backing devices: scan, symlink, register
+-IMPORT{program}="probe-bcache -o udev $tempnode"
+-ENV{ID_FS_TYPE}!="bcache", GOTO="bcache_backing_end"
+-ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
++GOTO="bcache_backing_end"
+ 
+ LABEL="bcache_backing_found"
+-RUN+="bcache-register $tempnode"
++RUN{builtin}+="kmod load bcache"
++RUN+="/bin/sh -c 'echo $tempnode > /sys/fs/bcache/register_quiet'"
+ LABEL="bcache_backing_end"
+ 
+ # Cached devices: symlink
+diff --git a/Makefile b/Makefile
+index 3f8d87b..15638a7 100644
+--- a/Makefile
++++ b/Makefile
+@@ -9,7 +9,7 @@ all: make-bcache probe-bcache bcache-super-show
+ 
+ install: make-bcache probe-bcache bcache-super-show
+ 	$(INSTALL) -m0755 make-bcache bcache-super-show	$(DESTDIR)${PREFIX}/sbin/
+-	$(INSTALL) -m0755 probe-bcache bcache-register		$(DESTDIR)$(UDEVLIBDIR)/
++#	$(INSTALL) -m0755 probe-bcache bcache-register		$(DESTDIR)$(UDEVLIBDIR)/
+ 	$(INSTALL) -m0644 69-bcache.rules	$(DESTDIR)$(UDEVLIBDIR)/rules.d/
+ 	$(INSTALL) -m0644 -- *.8 $(DESTDIR)${PREFIX}/share/man/man8/
+ 	$(INSTALL) -D -m0755 initramfs/hook	$(DESTDIR)/usr/share/initramfs-tools/hooks/bcache
+diff --git a/bcache-register b/bcache-register
+index 9b592bc..75b4faf 100755
+--- a/bcache-register
++++ b/bcache-register
+@@ -1,4 +1,3 @@
+ #!/bin/sh
+-/sbin/modprobe -qba bcache
+ test -f /sys/fs/bcache/register_quiet && echo "$1" > /sys/fs/bcache/register_quiet
+ 
diff --git a/nixpkgs/pkgs/tools/filesystems/bcache-tools/default.nix b/nixpkgs/pkgs/tools/filesystems/bcache-tools/default.nix
new file mode 100644
index 000000000000..efd48fb87fe7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bcache-tools/default.nix
@@ -0,0 +1,57 @@
+{ stdenv, fetchurl, pkgconfig, utillinux, bash }:
+
+stdenv.mkDerivation rec {
+  name = "bcache-tools-${version}";
+  version = "1.0.7";
+
+  src = fetchurl {
+    name = "${name}.tar.gz";
+    url = "https://github.com/g2p/bcache-tools/archive/v${version}.tar.gz";
+    sha256 = "1gbsh2qw0a7kgck6w0apydiy37nnz5xvdgipa0yqrfmghl86vmv4";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ utillinux ];
+
+  # * Remove broken install rules (they ignore $PREFIX) for stuff we don't need
+  #   anyway (it's distro specific stuff).
+  # * Fixup absolute path to modprobe.
+  prePatch = ''
+    sed -e "/INSTALL.*initramfs\/hook/d" \
+        -e "/INSTALL.*initcpio\/install/d" \
+        -e "/INSTALL.*dracut\/module-setup.sh/d" \
+        -i Makefile
+  '';
+
+  patches = [
+    ./bcache-udev-modern.patch
+    ./fix-static.patch
+  ];
+
+  preBuild = ''
+    export makeFlags="$makeFlags PREFIX=\"$out\" UDEVLIBDIR=\"$out/lib/udev/\"";
+    sed -e "s|/bin/sh|${bash}/bin/sh|" -i *.rules
+  '';
+
+  preInstall = ''
+    mkdir -p "$out/sbin" "$out/lib/udev/rules.d" "$out/share/man/man8"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "User-space tools required for bcache (Linux block layer cache)";
+    longDescription = ''
+      Bcache is a Linux kernel block layer cache. It allows one or more fast
+      disk drives such as flash-based solid state drives (SSDs) to act as a
+      cache for one or more slower hard disk drives.
+      
+      This package contains the required user-space tools.
+
+      User documentation is in Documentation/bcache.txt in the Linux kernel
+      tree.
+    '';
+    homepage = https://bcache.evilpiepirate.org/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/bcache-tools/fix-static.patch b/nixpkgs/pkgs/tools/filesystems/bcache-tools/fix-static.patch
new file mode 100644
index 000000000000..e5dd2df5299d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bcache-tools/fix-static.patch
@@ -0,0 +1,22 @@
+diff --git a/bcache.c b/bcache.c
+index 8f37445..79806d8 100644
+--- a/bcache.c
++++ b/bcache.c
+@@ -26,7 +26,7 @@
+  * x^7 + x^4 + x + 1
+ */
+ 
+-static const uint64_t crc_table[256] = {
++const uint64_t crc_table[256] = {
+ 	0x0000000000000000ULL, 0x42F0E1EBA9EA3693ULL, 0x85E1C3D753D46D26ULL,
+ 	0xC711223CFA3E5BB5ULL, 0x493366450E42ECDFULL, 0x0BC387AEA7A8DA4CULL,
+ 	0xCCD2A5925D9681F9ULL, 0x8E224479F47CB76AULL, 0x9266CC8A1C85D9BEULL,
+@@ -115,7 +115,7 @@ static const uint64_t crc_table[256] = {
+ 	0x9AFCE626CE85B507ULL
+ };
+ 
+-inline uint64_t crc64(const void *_data, size_t len)
++uint64_t crc64(const void *_data, size_t len)
+ {
+ 	uint64_t crc = 0xFFFFFFFFFFFFFFFFULL;
+ 	const unsigned char *data = _data;
diff --git a/nixpkgs/pkgs/tools/filesystems/bcachefs-tools/default.nix b/nixpkgs/pkgs/tools/filesystems/bcachefs-tools/default.nix
new file mode 100644
index 000000000000..75737e2da7fc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bcachefs-tools/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchgit, pkgconfig, attr, libuuid, libscrypt, libsodium, keyutils
+, liburcu, zlib, libaio, zstd, lz4 }:
+
+stdenv.mkDerivation rec {
+  name = "bcachefs-tools-unstable-2018-10-12";
+
+  src = fetchgit {
+    url = "https://evilpiepirate.org/git/bcachefs-tools.git";
+    rev = "55fbb25501330038e1714905b9ddeb25d875c11c";
+    sha256 = "0cwzbyf133jc0fkc8nmjcvv3wmglqhyxda1hh10hgxrbq5vm39wx";
+  };
+
+  enableParallelBuilding = true;
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ attr libuuid libscrypt libsodium keyutils liburcu zlib libaio zstd lz4 ];
+  installFlags = [ "PREFIX=$(out)" ];
+  
+  preInstall = ''
+    sed -i \
+      "s,INITRAMFS_DIR=/etc/initramfs-tools,INITRAMFS_DIR=$out/etc/initramfs-tools,g" Makefile
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Tool for managing bcachefs filesystems";
+    homepage = https://bcachefs.org/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ davidak chiiruno ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/bees/bees-service-wrapper b/nixpkgs/pkgs/tools/filesystems/bees/bees-service-wrapper
new file mode 100755
index 000000000000..8ef46afc18f5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bees/bees-service-wrapper
@@ -0,0 +1,223 @@
+#!@bash@/bin/bash
+PATH=@bash@/bin:@coreutils@/bin:@utillinux@/bin:@btrfsProgs@/bin:$PATH
+beesd_bin=@bees@/lib/bees/bees
+# PLEASE KEEP NIX-ISMS ABOVE THIS LINE TO EASE UPSTREAM MERGE
+#!/usr/bin/env bash
+
+shopt -s extglob
+
+# Upstream wrapper requires UUID to be used for configuration.
+
+# However, when declaratively describing a host, we may not know its UUID, and
+# shouldn't need to persist something that will differ between hosts built from
+# the same configuration template.
+
+# Thus, for using bees from NixOS, we have our own wrapper, which supports not
+# just UUID but any specification permitted by findmnt
+
+[[ $bees_debug ]] && { PS4=':${BASH_SOURCE##*/}:$LINENO+'; set -x; }
+
+usage() {
+  cat >&2 <<EOF
+Usage: ${BASH_SOURCE##*/} run|cleanup config-name|fsSpec [idxSizeMB=...] [verbosity=...] [workDir=...] [-- daemon-options...]
+
+  fsSpec should be in a format recognized by findmnt. Alternately,
+  "config-name" may refer to a file that exists in ${bees_config_dir:-/etc/bees}
+  with a .conf extension; if that file does not specify UUID, findmnt will be
+  used in addition.
+
+  Note that while config files may presently use shell arithmetic, use of this
+  functionality is not encouraged going forward: Setting ''idxSizeMB=4096'' is
+  preferred over ''DB_SIZE=$((1024*1024*1024*4))'' or ''DB_SIZE=$(( AL16M * 256 ))'',
+  although both of these are presently supported.
+
+  If fsSpec contains a /, it assumed to be a mount point to be looked up by
+  findmnt, not a config file name.
+
+  daemon-options are passed directly through to the daemon on startup, as
+  documented at https://github.com/Zygo/bees/blob/master/docs/options.md.
+EOF
+  exit 1
+}
+
+die() { echo "$*" >&2; exit 1; }
+
+allConfigNames=( blockdev fsSpec home idxSize idxSizeMB mntDir runDir status verbosity workDir )
+
+# Alternate names for configuration values; "bees_" will always be prepended
+declare -A altConfigNames=(
+  # from original bees wrapper
+  [BEESHOME]=home
+  [BEESSTATUS]=status
+  [MNT_DIR]=mntDir
+  [UUID]=uuid
+  [WORK_DIR]=runDir
+  [DB_SIZE]=idxSize
+)
+
+# legacy bees config files can be arbitrary shell scripts, so we need to actually evaluate them
+sandboxedConfigFileEval() {
+  bash_exe=$(type -P bash) || exit
+  PATH=/var/empty ENV='' BASH_ENV='' AL128K="$((128*1024))" AL16M="$((16*1024*1024))" "$bash_exe" -r ${bees_debug+-x} \
+    -c 'eval "$(</dev/stdin)" >&2; for var; do [[ ${!var} ]] && printf "%q=%s\\0" "$var" "${!var}"; done' \
+    "${!altConfigNames[@]}" "${allConfigNames[@]}" \
+    <"$1"
+}
+
+readConfigFileIfExists() {
+  local line
+  [[ -s $1 ]] || return 1
+  while IFS= read -r -d '' line; do
+    line=${line%%+([[:space:]])"#"*}
+    [[ $line ]] || continue
+    [[ $line = *=* ]] || {
+      printf 'WARNING: Config file line not recognized: %q\n' "$line" >&2
+      continue
+    }
+    set_option "$line"
+  done < <(sandboxedConfigFileEval "$1")
+}
+
+set_option() {
+  local k v
+  k="${1%%=*}" v="${1#*=}"
+  [[ ${altConfigNames[$k]} ]] && k=${altConfigNames[$k]}
+  printf -v "bees_$k" %s "$v"
+}
+
+uuid_re='^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$'
+
+# Shared code for setting configuration used by other operations.
+#
+# Reads from global associative array "opts" containing options passed in as
+# key=value pairs on the command line, looks for config-file overrides, and
+# sets individual global variables.
+_setup() {
+  declare fstype
+  bees_fsSpec=$1; shift
+
+  # Look for file-based configuration, additional to honoring configuration on the command line
+  bees_config_dir="${bees_config_dir:-/etc/bees}"
+  if [[ $bees_fsSpec =~ $uuid_re ]]; then
+    bees_uuid=$bees_fsSpec
+    # If our spec looks like a bare UUID, and no config file exists in the new
+    # format, fall back to legacy config file search mechanism (grep; ewww).
+    if ! readConfigFileIfExists "$bees_config_dir/UUID=$bees_fsSpec.conf"; then
+      # Legacy approach to finding a config file: Grep for a *.conf file
+      # containing the UUID within its text. Permitting spaces around the "="
+      # appears to be a bug, but is retained for compatibility with the
+      # original upstream script.
+      allConfFiles=( "$bees_config_dir"/*.conf )
+      if (( ${#allConfFiles[@]} )); then
+        # in read or readarray with -d '', the NUL terminating the empty string is used as delimiter character.
+        readarray -d '' -t matchingConfFiles < <(grep -E -l -Z "^[^#]*UUID[[:space:]]*=[[:space:]]*" "${allConfFiles[@]}")
+      else
+        matchingConfFiles=( )
+      fi
+      if (( ${#matchingConfFiles[@]} == 1 )); then
+        # Exactly one configuration file exists in our target directory with a reference to the UUID given.
+        bees_config_file=${matchingConfFiles[0]}
+        readConfigFileIfExists "$bees_config_file"
+        echo "NOTE: Please consider renaming $bees_config_file to $bees_config_dir/UUID=$bees_fsSpec" >&2
+        echo "      ...and passing UUID=$bees_fsSpec on startup." >&2
+      elif (( ${#matchingConfFiles[@]} > 1 )); then
+        # The legacy wrapper would silently use the first file and ignore
+        # others, but... no.
+        echo "ERROR: Passed a bare UUID, but multiple configuration files match it:" >&2
+        printf ' - %q\n' "${matchingConfFiles[@]}" >&2
+        die "Unable to continue."
+      fi
+    fi
+  else
+    # For a non-UUID fsSpec that is not a path, look only for a config file
+    # exactly matching its text.
+    #
+    # (Passing a mount point as a fsSpec is only supported with the new
+    # wrapper; all key=value pairs can be passed on the command line in this
+    # mode, so config file support is not needed).
+    [[ $bees_fsSpec = */* ]] || readConfigFileIfExists "$bees_config_dir/$bees_fsSpec.conf"
+  fi
+
+  [[ $bees_uuid ]] || {
+    # if bees_uuid is not in our .conf file, look it up with findmnt
+    read -r bees_uuid fstype < <(findmnt -n -o uuid,fstype "$bees_fsSpec") && [[ $fstype ]] || exit
+    [[ $fstype = btrfs ]] || die "Device type is $fstype, not btrfs"
+  }
+
+  [[ $bees_uuid = */* ]] || readConfigFileIfExists "$bees_config_dir/UUID=$bees_uuid.conf"
+
+  # Honor any values read from config files above; otherwise, set defaults.
+  bees_workDir="${bees_workDir:-.beeshome}"
+  bees_runDir="${bees_runDir:-/run/bees}"
+  bees_mntDir="${bees_mntDir:-$bees_runDir/mnt/$bees_uuid}"
+  bees_home="${bees_home:-$bees_mntDir/$bees_workDir}"
+  bees_status="${bees_status:-${bees_runDir}/$bees_uuid.status}"
+  bees_verbosity="${bees_verbosity:-6}"
+  bees_idxSizeMB="${bees_idxSizeMB:-1024}"
+  bees_idxSize=${bees_idxSize:-"$(( bees_idxSizeMB * 1024 * 1024 ))"}
+  bees_blockdev=${bees_blockdev:-"/dev/disk/by-uuid/$bees_uuid"}
+
+  [[ -b $bees_blockdev ]] || die "Block device $bees_blockdev missing"
+  (( bees_idxSize % (16 * 1024 * 1024) == 0 )) || die "DB size must be divisible by 16MB"
+}
+
+do_run() {
+  local db old_db_size
+
+  _setup "$1"; shift
+  mkdir -p -- "$bees_mntDir" || exit
+
+  # subvol id 5 is reserved for the root subvolume of a btrfs filesystem.
+  mountpoint -q "$bees_mntDir" || mount -osubvolid=5 -- "$bees_blockdev" "$bees_mntDir" || exit
+  if [[ -d $bees_home ]]; then
+    btrfs subvolume show "$bees_home" >/dev/null 2>&1 || die "$bees_home exists but is not a subvolume"
+  else
+    btrfs subvolume create "$bees_home" || exit
+    sync # workaround for Zygo/bees#93
+  fi
+  db=$bees_home/beeshash.dat
+  touch -- "$db"
+
+  old_db_size=$(stat -c %s -- "$db")
+  new_db_size=$bees_idxSize
+
+  if (( old_db_size != new_db_size )); then
+    rm -f -- "$bees_home"/beescrawl."$bees_uuid".dat
+    truncate -s "$new_db_size" -- "$db" || exit
+  fi
+  chmod 700 -- "$bees_home"
+
+  # BEESSTATUS and BEESHOME are the only variables handled by the legacy
+  # wrapper for which getenv() is called in C code.
+  BEESSTATUS=$bees_status BEESHOME=$bees_home exec "${beesd_bin:-/lib/bees/bees}" \
+    --verbose "$bees_verbosity" \
+    "$@" "$bees_mntDir" || exit
+}
+
+do_cleanup() {
+  _setup "$1"; shift
+  mountpoint -q "$bees_mntDir" && umount -l -- "$bees_mntDir" || exit
+}
+
+(( $# >= 2 )) || usage
+declare -f "do_$1" >/dev/null 2>&1 || usage
+mode=$1; shift # must be a do_* function; currently "run" or "cleanup"
+
+declare -a args=( "$1" ); shift  # pass first argument (config-name|fsSpec) through literally
+
+# parse other arguments as key=value pairs, or pass them through literally if they do not match that form.
+# similarly, any option after "--" will be passed through literally.
+while (( $# )); do
+  if [[ $1 = *=* ]]; then
+    set_option "$1"
+  elif [[ $1 = -- ]]; then
+    shift
+    args+=( "$@" )
+    break
+  else
+    args+=( "$1" )
+  fi
+  shift
+done
+
+"do_$mode" "${args[@]}"
diff --git a/nixpkgs/pkgs/tools/filesystems/bees/default.nix b/nixpkgs/pkgs/tools/filesystems/bees/default.nix
new file mode 100644
index 000000000000..c43962cb075d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bees/default.nix
@@ -0,0 +1,69 @@
+{ stdenv, runCommand, makeWrapper, fetchFromGitHub, bash, btrfs-progs, coreutils, pythonPackages, utillinux }:
+
+let
+
+  version = "0.6.1";
+  sha256 = "0h7idclmhyp14mq6786x7f2237vqpn70gyi88ik4g70xl84yfgyh";
+
+  bees = stdenv.mkDerivation rec {
+    name = "bees-${version}";
+    inherit version;
+
+    src = fetchFromGitHub {
+      owner = "Zygo";
+      repo = "bees";
+      rev = "v${version}";
+      inherit sha256;
+    };
+
+    buildInputs = [
+      btrfs-progs               # for btrfs/ioctl.h
+      utillinux                 # for uuid.h
+    ];
+
+    nativeBuildInputs = [
+      pythonPackages.markdown   # documentation build
+    ];
+
+    preBuild = ''
+      git() { if [[ $1 = describe ]]; then echo ${version}; else command git "$@"; fi; }
+      export -f git
+    '';
+
+    postBuild = ''
+      unset -f git
+    '';
+
+    buildFlags = [
+      "ETC_PREFIX=/var/run/bees/configs"
+    ];
+
+    makeFlags = [
+      "SHELL=bash"
+      "PREFIX=$(out)"
+      "ETC_PREFIX=$(out)/etc"
+      "BEES_VERSION=${version}"
+      "SYSTEMD_SYSTEM_UNIT_DIR=$(out)/etc/systemd/system"
+    ];
+
+    meta = with stdenv.lib; {
+      homepage = "https://github.com/Zygo/bees";
+      description = "Block-oriented BTRFS deduplication service";
+      license = licenses.gpl3;
+      platforms = platforms.linux;
+      maintainers = with maintainers; [ chaduffy ];
+      longDescription = "Best-Effort Extent-Same: bees finds not just identical files, but also identical extents within files that differ";
+    };
+  };
+
+in
+
+runCommand "bees-service-${version}" {
+  inherit bash bees coreutils utillinux;
+  btrfsProgs = btrfs-progs; # needs to be a valid shell variable name
+} ''
+  mkdir -p -- "$out/bin"
+  substituteAll ${./bees-service-wrapper} "$out"/bin/bees-service-wrapper
+  chmod +x "$out"/bin/bees-service-wrapper
+  ln -s ${bees}/bin/beesd "$out"/bin/beesd
+''
diff --git a/nixpkgs/pkgs/tools/filesystems/bindfs/default.nix b/nixpkgs/pkgs/tools/filesystems/bindfs/default.nix
new file mode 100644
index 000000000000..a674de9ac49b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bindfs/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, fuse, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  version = "1.13.10";
+  name    = "bindfs-${version}";
+
+  src = fetchurl {
+    url    = "https://bindfs.org/downloads/${name}.tar.gz";
+    sha256 = "14wfp2dcjm0f1pmqqvkf94k7pijbi8ka395cm3hryqpi4k0w3f4j";
+  };
+
+  dontStrip = true;
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse ];
+  postFixup = ''
+    ln -s $out/bin/bindfs $out/bin/mount.fuse.bindfs
+  '';
+
+  meta = {
+    description = "A FUSE filesystem for mounting a directory to another location";
+    homepage    = https://bindfs.org;
+    license     = stdenv.lib.licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ lovek323 ];
+    platforms   = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/blobfuse/default.nix b/nixpkgs/pkgs/tools/filesystems/blobfuse/default.nix
new file mode 100644
index 000000000000..b5694535e946
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/blobfuse/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchFromGitHub, cmake, pkgconfig, curl, gnutls, libgcrypt, libuuid, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "blobfuse-${version}";
+  version = "1.0.2";
+
+  src = fetchFromGitHub {
+    owner  = "Azure";
+    repo   = "azure-storage-fuse";
+    rev    = "v${version}";
+    sha256 = "1qh04z1fsj1l6l12sz9yl2sy9hwlrnzac54hwrr7wvsgv90n9gbp";
+  };
+
+  buildInputs = [ curl gnutls libgcrypt libuuid fuse ];
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  meta = with stdenv.lib; {
+    description = "Mount an Azure Blob storage as filesystem through FUSE";
+    license = licenses.mit;
+    maintainers = with maintainers; [ jbgi ];
+    platforms = platforms.linux;
+  };
+}
\ No newline at end of file
diff --git a/nixpkgs/pkgs/tools/filesystems/bonnie/default.nix b/nixpkgs/pkgs/tools/filesystems/bonnie/default.nix
new file mode 100644
index 000000000000..55edf97d17bc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/bonnie/default.nix
@@ -0,0 +1,18 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "bonnie++-1.97.3";
+  src = fetchurl {
+    url = "https://fossies.org/linux/privat/${name}.tgz";
+    sha256 = "0vkl42rsrsy95fc1ykc6g8rsdbnpxayvdaihnnkly1fww1m3hyz2";
+  };
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = http://www.coker.com.au/bonnie++/;
+    description = "Hard drive and file system benchmark suite";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/boxfs/default.nix b/nixpkgs/pkgs/tools/filesystems/boxfs/default.nix
new file mode 100644
index 000000000000..9c9dbede83f4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/boxfs/default.nix
@@ -0,0 +1,60 @@
+{ stdenv, fetchFromGitHub, curl, fuse, libxml2, pkgconfig }:
+
+let
+  srcs = {
+    boxfs2 = fetchFromGitHub {
+      sha256 = "10af1l3sjnh25shmq5gdnpyqk4vrq7i1zklv4csf1n2nrahln8j8";
+      rev = "d7018b0546d2dae956ae3da3fb95d2f63fa6d3ff";
+      repo = "boxfs2";
+      owner = "drotiro";
+    };
+    libapp = fetchFromGitHub {
+      sha256 = "1p2sbxiranan2n2xsfjkp3c6r2vcs57ds6qvjv4crs1yhxr7cp00";
+      rev = "febebe2bc0fb88d57bdf4eb4a2a54c9eeda3f3d8";
+      repo = "libapp";
+      owner = "drotiro";
+    };
+    libjson = fetchFromGitHub {
+      sha256 = "1vhss3gq44nl61fbnh1l3qzwvz623gwhfgykf1lf1p31rjr7273w";
+      rev = "75a7f50fca2c667bc5f32cdd6dd98f2b673f6657";
+      repo = "libjson";
+      owner = "vincenthz";
+    };
+  };
+in stdenv.mkDerivation rec {
+  name = "boxfs-${version}";
+  version = "2-20150109";
+
+  src = srcs.boxfs2;
+
+  prePatch = with srcs; ''
+    substituteInPlace Makefile --replace "git pull" "true"
+    cp -a --no-preserve=mode ${libapp} libapp
+    cp -a --no-preserve=mode ${libjson} libjson
+  '';
+  patches = [ ./work-around-API-borkage.patch ];
+
+  buildInputs = [ curl fuse libxml2 ];
+  nativeBuildInputs = [ pkgconfig ];
+
+  buildFlags = [ "static" ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    install boxfs boxfs-init $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "FUSE file system for box.com accounts";
+    longDescription = ''
+      Store files on box.com (an account is required). The first time you run
+      boxfs, you will need to complete the authentication (oauth2) process and
+      grant access to your box.com account. Just follow the instructions on
+      the terminal and in your browser. When you've done using your files,
+      unmount the file system with `fusermount -u mountpoint`.
+    '';
+    homepage = https://github.com/drotiro/boxfs2;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/boxfs/work-around-API-borkage.patch b/nixpkgs/pkgs/tools/filesystems/boxfs/work-around-API-borkage.patch
new file mode 100644
index 000000000000..b74e7f324665
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/boxfs/work-around-API-borkage.patch
@@ -0,0 +1,15 @@
+diff --git a/boxapi.c b/boxapi.c
+index 4964273..1a32e0d 100644
+--- a/boxapi.c
++++ b/boxapi.c
+@@ -38,8 +38,8 @@
+ //    AUTH
+ #define API_KEY_VAL "f9ss11y2w0hg5r04jsidxlhk4pil28cf"
+ #define API_SECRET  "r3ZHAIhsOL2FoHjgERI9xf74W5skIM0w"
+-#define API_OAUTH_URL "https://app.box.com/api/oauth2/" //"https://www.box.com/api/oauth2/"
+-#define API_OAUTH_AUTHORIZE API_OAUTH_URL "authorize?response_type=code&client_id=" API_KEY_VAL /*"&redirect_uri=http%3A//localhost"*/
++#define API_OAUTH_URL "https://api.box.com/oauth2/" //"https://www.box.com/api/oauth2/"
++#define API_OAUTH_AUTHORIZE "https://app.box.com/api/oauth2/authorize?response_type=code&client_id=" API_KEY_VAL /*"&redirect_uri=http%3A//localhost"*/
+ #define API_OAUTH_TOKEN     API_OAUTH_URL "token"
+ //    CALLS
+ #define API_ENDPOINT	"https://api.box.com/2.0/"
diff --git a/nixpkgs/pkgs/tools/filesystems/btrfs-dedupe/default.nix b/nixpkgs/pkgs/tools/filesystems/btrfs-dedupe/default.nix
new file mode 100644
index 000000000000..d2a82dc357b5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/btrfs-dedupe/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, rustPlatform, lzo, zlib }:
+
+with rustPlatform;
+
+buildRustPackage rec {
+  name = "btrfs-dedupe-${version}";
+  version = "1.1.0";
+
+
+  src = fetchurl {
+    url = "https://gitlab.wellbehavedsoftware.com/well-behaved-software/btrfs-dedupe/repository/archive.tar.bz2?ref=72c6a301d20f935827b994db210bf0a1e121273a";
+    sha256 = "0qy1g4crhfgs2f5cmrsjv6qscg3r66gb8n6sxhimm9ksivhjyyjp";
+  };
+
+  cargoSha256 = "0dmn9bccicxhqcj9zrsxxp0vb5ma12a1hs9brpc22n4g1qy4yzcn";
+
+  buildInputs = [ lzo zlib ];
+
+  meta = with stdenv.lib; {
+    homepage = https://gitlab.wellbehavedsoftware.com/well-behaved-software/btrfs-dedupe;
+    description = "BTRFS deduplication utility";
+    license = licenses.mit;
+    platforms = [ "x86_64-linux" ];
+    maintainers = with maintainers; [ ikervagyok ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/btrfs-progs/default.nix b/nixpkgs/pkgs/tools/filesystems/btrfs-progs/default.nix
new file mode 100644
index 000000000000..8f3d41e8f4e9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/btrfs-progs/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchurl, fetchpatch, pkgconfig, attr, acl, zlib, libuuid, e2fsprogs, lzo
+, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, libxslt, zstd, python3, python3Packages
+}:
+
+stdenv.mkDerivation rec {
+  name = "btrfs-progs-${version}";
+  version = "4.19.1";
+
+  src = fetchurl {
+    url = "mirror://kernel/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v${version}.tar.xz";
+    sha256 = "1f7gpk9206ph081fr0af8k57i58zjb03xwd8k69177a7rzsjmn04";
+  };
+
+  nativeBuildInputs = [
+    pkgconfig asciidoc xmlto docbook_xml_dtd_45 docbook_xsl libxslt python3 python3Packages.setuptools
+  ];
+
+  buildInputs = [ attr acl zlib libuuid e2fsprogs lzo zstd ];
+
+  # gcc bug with -O1 on ARM with gcc 4.8
+  # This should be fine on all platforms so apply universally
+  postPatch = "sed -i s/-O1/-O2/ configure";
+
+  postInstall = ''
+    install -v -m 444 -D btrfs-completion $out/etc/bash_completion.d/btrfs
+  '';
+
+  configureFlags = stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-backtrace";
+
+  meta = with stdenv.lib; {
+    description = "Utilities for the btrfs filesystem";
+    homepage = https://btrfs.wiki.kernel.org/;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ raskin wkennington ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/buttersink/default.nix b/nixpkgs/pkgs/tools/filesystems/buttersink/default.nix
new file mode 100644
index 000000000000..791d59b7ac27
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/buttersink/default.nix
@@ -0,0 +1,30 @@
+{ lib, python2 }:
+
+python2.pkgs.buildPythonApplication rec {
+  pname = "buttersink";
+  version = "0.6.9";
+
+  src = python2.pkgs.fetchPypi {
+    inherit pname version;
+    sha256 = "a797b6e92ad2acdf41e033c1368ab365aa268f4d8458b396a5770fa6c2bc3f54";
+  };
+
+  propagatedBuildInputs = with python2.pkgs; [ boto crcmod psutil ];
+
+  # No tests implemented
+  doCheck = false;
+
+  meta = with lib; {
+    description = "Synchronise btrfs snapshots";
+    longDescription = ''
+      ButterSink is like rsync, but for btrfs subvolumes instead of files,
+      which makes it much more efficient for things like archiving backup
+      snapshots. It is built on top of btrfs send and receive capabilities.
+      Sources and destinations can be local btrfs file systems, remote btrfs
+      file systems over SSH, or S3 buckets.
+    '';
+    homepage = https://github.com/AmesCornish/buttersink/wiki;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/0001-Makefile-env-Don-t-force-sbin.patch b/nixpkgs/pkgs/tools/filesystems/ceph/0001-Makefile-env-Don-t-force-sbin.patch
new file mode 100644
index 000000000000..cb2de6ad4f5b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/0001-Makefile-env-Don-t-force-sbin.patch
@@ -0,0 +1,25 @@
+From 34c27f66210570adf5aba624d7da3c0382d5493f Mon Sep 17 00:00:00 2001
+From: "William A. Kennington III" <william@wkennington.com>
+Date: Sun, 21 Sep 2014 12:19:30 -0700
+Subject: [PATCH] Makefile-env: Don't force /sbin
+
+---
+ src/Makefile-env.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/Makefile-env.am b/src/Makefile-env.am
+index f2ab655..bf8876e 100644
+--- a/src/Makefile-env.am
++++ b/src/Makefile-env.am
+@@ -27,7 +27,7 @@ bin_DEBUGPROGRAMS =
+ ceph_sbindir = $(sbindir)
+ 
+ # certain things go straight into /sbin, though!
+-su_sbindir = /sbin
++su_sbindir = $(sbindir)
+ 
+ # C/C++ tests to build will be appended to this
+ check_PROGRAMS =
+-- 
+2.1.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/0001-kv-RocksDBStore-API-break-additional.patch b/nixpkgs/pkgs/tools/filesystems/ceph/0001-kv-RocksDBStore-API-break-additional.patch
new file mode 100644
index 000000000000..0b6f1d30a4c9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/0001-kv-RocksDBStore-API-break-additional.patch
@@ -0,0 +1,58 @@
+Seulement dans ceph: ceph.old
+diff -ur ceph.old/src/kv/RocksDBStore.cc ceph/src/kv/RocksDBStore.cc
+--- ceph.old/src/kv/RocksDBStore.cc	1980-01-02 00:00:00.000000000 +0100
++++ ceph/src/kv/RocksDBStore.cc	2018-01-24 14:08:35.017553372 +0100
+@@ -505,7 +505,7 @@
+   // considering performance overhead, default is disabled
+   if (g_conf->rocksdb_perf) {
+     rocksdb::SetPerfLevel(rocksdb::PerfLevel::kEnableTimeExceptForMutex);
+-    rocksdb::perf_context.Reset();
++    rocksdb::get_perf_context()->Reset();
+   }
+ 
+   RocksDBTransactionImpl * _t =
+@@ -532,13 +532,13 @@
+     utime_t write_wal_time;
+     utime_t write_pre_and_post_process_time;
+     write_wal_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_wal_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_wal_time)/1000000000);
+     write_memtable_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_memtable_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_memtable_time)/1000000000);
+     write_delay_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_delay_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_delay_time)/1000000000);
+     write_pre_and_post_process_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_pre_and_post_process_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_pre_and_post_process_time)/1000000000);
+     logger->tinc(l_rocksdb_write_memtable_time, write_memtable_time);
+     logger->tinc(l_rocksdb_write_delay_time, write_delay_time);
+     logger->tinc(l_rocksdb_write_wal_time, write_wal_time);
+@@ -558,7 +558,7 @@
+   // considering performance overhead, default is disabled
+   if (g_conf->rocksdb_perf) {
+     rocksdb::SetPerfLevel(rocksdb::PerfLevel::kEnableTimeExceptForMutex);
+-    rocksdb::perf_context.Reset();
++    rocksdb::get_perf_context()->Reset();
+   }
+ 
+   RocksDBTransactionImpl * _t =
+@@ -586,13 +586,13 @@
+     utime_t write_wal_time;
+     utime_t write_pre_and_post_process_time;
+     write_wal_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_wal_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_wal_time)/1000000000);
+     write_memtable_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_memtable_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_memtable_time)/1000000000);
+     write_delay_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_delay_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_delay_time)/1000000000);
+     write_pre_and_post_process_time.set_from_double(
+-	static_cast<double>(rocksdb::perf_context.write_pre_and_post_process_time)/1000000000);
++	static_cast<double>(rocksdb::get_perf_context()->write_pre_and_post_process_time)/1000000000);
+     logger->tinc(l_rocksdb_write_memtable_time, write_memtable_time);
+     logger->tinc(l_rocksdb_write_delay_time, write_delay_time);
+     logger->tinc(l_rocksdb_write_wal_time, write_wal_time);
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/0002-fix-absolute-include-path.patch b/nixpkgs/pkgs/tools/filesystems/ceph/0002-fix-absolute-include-path.patch
new file mode 100644
index 000000000000..01aa194dddf2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/0002-fix-absolute-include-path.patch
@@ -0,0 +1,19 @@
+diff -ru ceph/src/key_value_store/kv_flat_btree_async.cc ceph-copy/src/key_value_store/kv_flat_btree_async.cc
+--- ceph/src/key_value_store/kv_flat_btree_async.cc	1980-01-02 00:00:00.000000000 +0100
++++ ceph-copy/src/key_value_store/kv_flat_btree_async.cc	2018-02-13 21:49:59.232860487 +0100
+@@ -15,13 +15,13 @@
+ #include "key_value_store/kv_flat_btree_async.h"
+ #include "key_value_store/kvs_arg_types.h"
+ #include "include/rados/librados.hpp"
+-#include "/usr/include/asm-generic/errno.h"
+-#include "/usr/include/asm-generic/errno-base.h"
+ #include "common/ceph_context.h"
+ #include "common/Clock.h"
+ #include "include/types.h"
+ 
+ 
++#include <asm-generic/errno.h>
++#include <asm-generic/errno-base.h>
+ #include <string>
+ #include <iostream>
+ #include <cassert>
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/default.nix b/nixpkgs/pkgs/tools/filesystems/ceph/default.nix
new file mode 100644
index 000000000000..ef3e36ff6275
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/default.nix
@@ -0,0 +1,12 @@
+{ callPackage, fetchgit, fetchpatch, ... } @ args:
+
+callPackage ./generic.nix (args // rec {
+  version = "12.2.7";
+
+  src = fetchgit {
+    url = "https://github.com/ceph/ceph.git";
+    rev = "refs/tags/v${version}";
+    sha256 = "031nfw2g2fdpxxx39g862phgmdx68hj9r54axazandghfhc1bzrl";
+  };
+
+})
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/fix-pythonpath.patch b/nixpkgs/pkgs/tools/filesystems/ceph/fix-pythonpath.patch
new file mode 100644
index 000000000000..7458a46aca15
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/fix-pythonpath.patch
@@ -0,0 +1,31 @@
+diff --git a/src/Makefile-env.am b/src/Makefile-env.am
+index e176596..384e230 100644
+--- a/src/Makefile-env.am
++++ b/src/Makefile-env.am
+@@ -40,7 +40,7 @@ check_SCRIPTS =
+ export VERBOSE = true
+ 
+ # python unit tests need to know where the scripts are located
+-export PYTHONPATH=$(top_srcdir)/src/pybind
++export PYTHONPATH+=:$(top_srcdir)/src/pybind
+ 
+ # when doing a debug build, make sure to make the targets
+ if WITH_DEBUG
+diff --git a/src/ceph-detect-init/Makefile.am b/src/ceph-detect-init/Makefile.am
+index 3e5ad03..66d6683 100644
+--- a/src/ceph-detect-init/Makefile.am
++++ b/src/ceph-detect-init/Makefile.am
+@@ -64,9 +64,10 @@ install-data-local::
+ 	if test "$(DESTDIR)" ; then \
+ 		if lsb_release -si | grep --quiet 'Ubuntu\|Debian\|Devuan' ; then \
+ 			options=--install-layout=deb ; \
+-		else \
+-			options=--prefix=/usr ; \
+ 		fi ; \
+ 		root="--root=$(DESTDIR)" ; \
+ 	fi ; \
+-	python setup.py install $$root $$options
++	if test "$(prefix)"; then \
++		prefix="--prefix=$(prefix)" ; \
++	fi ; \
++	python setup.py install $$prefix $$root $$options
diff --git a/nixpkgs/pkgs/tools/filesystems/ceph/generic.nix b/nixpkgs/pkgs/tools/filesystems/ceph/generic.nix
new file mode 100644
index 000000000000..c4856d925299
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ceph/generic.nix
@@ -0,0 +1,174 @@
+{ stdenv, ensureNewerSourcesHook, cmake, pkgconfig
+, which, git
+, boost, python2Packages
+, libxml2, zlib
+, openldap, lttng-ust
+, babeltrace, gperf
+, cunit, snappy
+, rocksdb, makeWrapper
+
+# Optional Dependencies
+, yasm ? null, fcgi ? null, expat ? null
+, curl ? null, fuse ? null
+, libedit ? null, libatomic_ops ? null, kinetic-cpp-client ? null
+, libs3 ? null
+
+# Mallocs
+, jemalloc ? null, gperftools ? null
+
+# Crypto Dependencies
+, cryptopp ? null
+, nss ? null, nspr ? null
+
+# Linux Only Dependencies
+, linuxHeaders, libuuid, udev, keyutils, libaio ? null, libxfs ? null
+, zfs ? null
+
+# Version specific arguments
+, version, src ? [], buildInputs ? []
+, ...
+}:
+
+# We must have one crypto library
+assert cryptopp != null || (nss != null && nspr != null);
+
+with stdenv;
+with stdenv.lib;
+let
+
+  shouldUsePkg = pkg_: let pkg = (builtins.tryEval pkg_).value;
+    in if lib.any (lib.meta.platformMatch stdenv.hostPlatform) pkg.meta.platforms
+      then pkg else null;
+
+  optYasm = shouldUsePkg yasm;
+  optFcgi = shouldUsePkg fcgi;
+  optExpat = shouldUsePkg expat;
+  optCurl = shouldUsePkg curl;
+  optFuse = shouldUsePkg fuse;
+  optLibedit = shouldUsePkg libedit;
+  optLibatomic_ops = shouldUsePkg libatomic_ops;
+  optKinetic-cpp-client = shouldUsePkg kinetic-cpp-client;
+  optLibs3 = if versionAtLeast version "10.0.0" then null else shouldUsePkg libs3;
+
+  optJemalloc = shouldUsePkg jemalloc;
+  optGperftools = shouldUsePkg gperftools;
+
+  optCryptopp = shouldUsePkg cryptopp;
+  optNss = shouldUsePkg nss;
+  optNspr = shouldUsePkg nspr;
+
+  optLibaio = shouldUsePkg libaio;
+  optLibxfs = shouldUsePkg libxfs;
+  optZfs = shouldUsePkg zfs;
+
+  hasRadosgw = optFcgi != null && optExpat != null && optCurl != null && optLibedit != null;
+
+
+  # TODO: Reenable when kinetic support is fixed
+  #hasKinetic = versionAtLeast version "9.0.0" && optKinetic-cpp-client != null;
+  hasKinetic = false;
+
+  # Malloc implementation (can be jemalloc, tcmalloc or null)
+  malloc = if optJemalloc != null then optJemalloc else optGperftools;
+
+  # We prefer nss over cryptopp
+  cryptoStr = if optNss != null && optNspr != null then "nss" else
+    if optCryptopp != null then "cryptopp" else "none";
+  cryptoLibsMap = {
+    nss = [ optNss optNspr ];
+    cryptopp = [ optCryptopp ];
+    none = [ ];
+  };
+
+  ceph-python-env = python2Packages.python.withPackages (ps: [
+    ps.sphinx
+    ps.flask
+    ps.argparse
+    ps.cython
+    ps.setuptools
+    ps.pip
+    # Libraries needed by the python tools
+    ps.Mako
+    ps.pecan
+    ps.prettytable
+    ps.webob
+    ps.cherrypy
+  ]);
+
+in
+stdenv.mkDerivation {
+  name="ceph-${version}";
+
+  inherit src;
+
+  patches = [
+ #   ./ceph-patch-cmake-path.patch
+    ./0001-kv-RocksDBStore-API-break-additional.patch
+  ] ++ optionals stdenv.isLinux [
+    ./0002-fix-absolute-include-path.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+    pkgconfig which git python2Packages.wrapPython makeWrapper
+    (ensureNewerSourcesHook { year = "1980"; })
+  ];
+
+  buildInputs = buildInputs ++ cryptoLibsMap.${cryptoStr} ++ [
+    boost ceph-python-env libxml2 optYasm optLibatomic_ops optLibs3
+    malloc zlib openldap lttng-ust babeltrace gperf cunit
+    snappy rocksdb
+  ] ++ optionals stdenv.isLinux [
+    linuxHeaders libuuid udev keyutils optLibaio optLibxfs optZfs
+  ] ++ optionals hasRadosgw [
+    optFcgi optExpat optCurl optFuse optLibedit
+  ] ++ optionals hasKinetic [
+    optKinetic-cpp-client
+  ];
+
+
+  preConfigure =''
+    # rip off submodule that interfer with system libs
+	rm -rf src/boost
+	rm -rf src/rocksdb
+
+	# require LD_LIBRARY_PATH for cython to find internal dep
+	export LD_LIBRARY_PATH="$PWD/build/lib:$LD_LIBRARY_PATH"
+
+	# requires setuptools due to embedded in-cmake setup.py usage
+	export PYTHONPATH="${python2Packages.setuptools}/lib/python2.7/site-packages/:$PYTHONPATH"
+  '';
+
+  cmakeFlags = [
+    "-DENABLE_GIT_VERSION=OFF"
+    "-DWITH_SYSTEM_BOOST=ON"
+    "-DWITH_SYSTEM_ROCKSDB=ON"
+    "-DWITH_LEVELDB=OFF"
+
+    # enforce shared lib
+    "-DBUILD_SHARED_LIBS=ON"
+
+    # disable cephfs, cmake build broken for now
+    "-DWITH_CEPHFS=OFF"
+    "-DWITH_LIBCEPHFS=OFF"
+  ];
+
+  postFixup = ''
+    wrapPythonPrograms
+    wrapProgram $out/bin/ceph-mgr --set PYTHONPATH $out/${python2Packages.python.sitePackages}
+  '';
+
+  enableParallelBuilding = true;
+
+  outputs = [ "dev" "lib" "out" "doc" ];
+
+  meta = {
+    homepage = https://ceph.com/;
+    description = "Distributed storage system";
+    license = licenses.lgpl21;
+    maintainers = with maintainers; [ adev ak wkennington ];
+    platforms = platforms.unix;
+  };
+
+  passthru.version = version;
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/chunkfs/default.nix b/nixpkgs/pkgs/tools/filesystems/chunkfs/default.nix
new file mode 100644
index 000000000000..47428e7f52e4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/chunkfs/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, perl, fuse }:
+
+stdenv.mkDerivation rec {
+  version = "0.7";
+  name = "chunkfs-${version}";
+
+  src = fetchurl {
+    url = "https://chunkfs.florz.de/chunkfs_${version}.tar.gz";
+    sha256 = "4c168fc2b265a6ba34afc565707ea738f34375325763c0596f2cfa1c9b8d40f1";
+  };
+
+  buildInputs = [perl fuse];
+
+  makeFlags = [
+    "DESTDIR=$(out)"
+    "PREFIX="
+  ];
+
+  preInstall = ''
+    mkdir -p $out/bin
+    mkdir -p $out/share/man/man1
+  '';
+
+  meta = {
+    description = "FUSE filesystems for viewing chunksync-style directory trees as a block device and vice versa";
+    homepage = http://chunkfs.florz.de/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/ciopfs/default.nix b/nixpkgs/pkgs/tools/filesystems/ciopfs/default.nix
new file mode 100644
index 000000000000..4a8c767e44ac
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ciopfs/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl, pkgconfig, fuse, glib, attr }:
+
+stdenv.mkDerivation rec {
+  name = "ciopfs-0.4";
+
+  src = fetchurl {
+    url = "http://www.brain-dump.org/projects/ciopfs/${name}.tar.gz";
+    sha256 = "0sr9i9b3qfwbfvzvk00yrrg3x2xqk1njadbldkvn7hwwa4z5bm9l";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse glib attr ];
+
+  makeFlags = "DESTDIR=$(out) PREFIX=";
+
+  meta = {
+    homepage = http://www.brain-dump.org/projects/ciopfs/;
+    description = "A case-insensitive filesystem layered on top of any other filesystem";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/convoy/default.nix b/nixpkgs/pkgs/tools/filesystems/convoy/default.nix
new file mode 100644
index 000000000000..8af745ed436e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/convoy/default.nix
@@ -0,0 +1,26 @@
+# This file was generated by go2nix.
+{ stdenv, buildGoPackage, fetchFromGitHub, lvm2 }:
+
+buildGoPackage rec {
+  name = "convoy-${version}";
+  version = "0.5.0";
+
+  goPackagePath = "github.com/rancher/convoy";
+
+  src = fetchFromGitHub {
+    rev = "v${version}";
+    owner = "rancher";
+    repo = "convoy";
+    sha256 = "0ihy0cfq7sa2wml904ajwr165hx2mas3jb1bqk3i0m4fg1lx1xw1";
+  };
+
+  buildInputs = [lvm2];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/rancher/convoy;
+    description = "A Docker volume plugin, managing persistent container volumes.";
+    license = licenses.asl20;
+    maintainers = with maintainers; [ offline ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/cryfs/default.nix b/nixpkgs/pkgs/tools/filesystems/cryfs/default.nix
new file mode 100644
index 000000000000..dfd522f5a094
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/cryfs/default.nix
@@ -0,0 +1,79 @@
+{ stdenv, fetchFromGitHub
+, cmake, pkgconfig, coreutils
+, boost, cryptopp, curl, fuse, openssl, python, spdlog
+}:
+
+stdenv.mkDerivation rec {
+  name = "cryfs-${version}";
+  version = "0.9.9";
+
+  src = fetchFromGitHub {
+    owner  = "cryfs";
+    repo   = "cryfs";
+    rev    = "${version}";
+    sha256 = "07f2k2b595m3vkwwlmlc0m7px0nwrrzrph3z6sss9354m0b0lcri";
+  };
+
+  prePatch = ''
+    patchShebangs src
+
+    substituteInPlace vendor/scrypt/CMakeLists.txt \
+      --replace /usr/bin/ ""
+
+    # scrypt in nixpkgs only produces a binary so we lift the patching from that so allow
+    # building the vendored version. This is very much NOT DRY.
+    # The proper solution is to have scrypt generate a dev output with the required files and just symlink
+    # into vendor/scrypt
+    for f in Makefile.in autocrap/Makefile.am libcperciva/cpusupport/Build/cpusupport.sh ; do
+      substituteInPlace vendor/scrypt/scrypt-*/scrypt/$f --replace "command -p " ""
+    done
+
+    # cryfs is vendoring an old version of spdlog
+    rm -rf vendor/spdlog/spdlog
+    ln -s ${spdlog} vendor/spdlog/spdlog
+  '';
+
+  buildInputs = [ boost cryptopp curl fuse openssl python spdlog ];
+
+  patches = [
+    ./test-no-network.patch  # Disable tests using external networking
+    ./skip-failing-test-large-malloc.patch
+  ];
+
+  # coreutils is needed for the vendored scrypt
+  nativeBuildInputs = [ cmake coreutils pkgconfig ];
+
+  enableParallelBuilding = true;
+
+  cmakeFlags = [
+    "-DCRYFS_UPDATE_CHECKS=OFF"
+    "-DBoost_USE_STATIC_LIBS=OFF" # this option is case sensitive
+    "-DBUILD_TESTING=ON"
+  ];
+
+  doCheck = true;
+
+  # Cryfs tests are broken on darwin
+  checkPhase = stdenv.lib.optionalString (!stdenv.isDarwin) ''
+    # Skip CMakeFiles directory and tests depending on fuse (does not work well with sandboxing)
+    SKIP_IMPURE_TESTS="CMakeFiles|fspp|cryfs-cli"
+
+    for test in `ls -d test/*/ | egrep -v "$SKIP_IMPURE_TESTS"`; do
+      "./$test`basename $test`-test"
+    done
+  '';
+
+  installPhase = ''
+    # Building with BUILD_TESTING=ON is missing the install target
+    mkdir -p $out/bin
+    install -m 755 ./src/cryfs-cli/cryfs $out/bin/cryfs
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Cryptographic filesystem for the cloud";
+    homepage    = https://www.cryfs.org;
+    license     = licenses.lgpl3;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms   = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/cryfs/skip-failing-test-large-malloc.patch b/nixpkgs/pkgs/tools/filesystems/cryfs/skip-failing-test-large-malloc.patch
new file mode 100644
index 000000000000..feb0ed9cfbb9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/cryfs/skip-failing-test-large-malloc.patch
@@ -0,0 +1,34 @@
+From ad3f7e9fa2dececfaab43963887a2f03de52d659 Mon Sep 17 00:00:00 2001
+From: adisbladis <adis@blad.is>
+Date: Thu, 12 Oct 2017 21:45:26 +0800
+Subject: [PATCH] Skip failing test: large malloc
+
+---
+ test/cpp-utils/data/DataTest.cpp | 11 -----------
+ 1 file changed, 11 deletions(-)
+
+diff --git a/test/cpp-utils/data/DataTest.cpp b/test/cpp-utils/data/DataTest.cpp
+index 6f9df070..bd426e62 100644
+--- a/test/cpp-utils/data/DataTest.cpp
++++ b/test/cpp-utils/data/DataTest.cpp
+@@ -191,17 +191,6 @@ TEST_F(DataTest, Inequality_DifferentLastByte) {
+   EXPECT_TRUE(data1 != data2);
+ }
+ 
+-#ifdef __x86_64__
+-TEST_F(DataTest, LargesizeSize) {
+-  //Needs 64bit for representation. This value isn't in the size param list, because the list is also used for read/write checks.
+-  uint64_t size = 4.5L*1024*1024*1024;
+-  Data data(size);
+-  EXPECT_EQ(size, data.size());
+-}
+-#else
+-#warning This is not a 64bit architecture. Large size data tests are disabled.
+-#endif
+-
+ TEST_F(DataTest, LoadingNonexistingFile) {
+   TempFile file(false); // Pass false to constructor, so the tempfile is not created
+   EXPECT_FALSE(Data::LoadFromFile(file.path()));
+-- 
+2.14.2
+
diff --git a/nixpkgs/pkgs/tools/filesystems/cryfs/test-no-network.patch b/nixpkgs/pkgs/tools/filesystems/cryfs/test-no-network.patch
new file mode 100644
index 000000000000..3392d3f855ec
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/cryfs/test-no-network.patch
@@ -0,0 +1,24 @@
+From 8b1808e1278d2cb0dc56a4e98781eceeadfb9718 Mon Sep 17 00:00:00 2001
+From: adisbladis <adis@blad.is>
+Date: Thu, 12 Oct 2017 18:13:28 +0800
+Subject: [PATCH] Disable tests using external networking
+
+---
+ test/cpp-utils/CMakeLists.txt | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/test/cpp-utils/CMakeLists.txt b/test/cpp-utils/CMakeLists.txt
+index 5a2bc9f8..d838edba 100644
+--- a/test/cpp-utils/CMakeLists.txt
++++ b/test/cpp-utils/CMakeLists.txt
+@@ -20,7 +20,6 @@ set(SOURCES
+     tempfile/TempFileIncludeTest.cpp
+     tempfile/TempDirIncludeTest.cpp
+     tempfile/TempDirTest.cpp
+-    network/CurlHttpClientTest.cpp
+     network/FakeHttpClientTest.cpp
+     io/ConsoleIncludeTest.cpp
+     io/ConsoleTest_AskYesNo.cpp
+-- 
+2.14.2
+
diff --git a/nixpkgs/pkgs/tools/filesystems/curlftpfs/default.nix b/nixpkgs/pkgs/tools/filesystems/curlftpfs/default.nix
new file mode 100644
index 000000000000..5636909093e6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/curlftpfs/default.nix
@@ -0,0 +1,21 @@
+{stdenv, fetchurl, fuse, curl, pkgconfig, glib, zlib}:
+
+stdenv.mkDerivation {
+  name = "curlftpfs-0.9.2";
+  src = fetchurl {
+    url = mirror://sourceforge/curlftpfs/curlftpfs-0.9.2.tar.gz;
+    sha256 = "0n397hmv21jsr1j7zx3m21i7ryscdhkdsyqpvvns12q7qwwlgd2f";
+  };
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [fuse curl glib zlib];
+
+  doCheck = false; # fails, doesn't work well too, btw
+
+  meta = with stdenv.lib; {
+    description = "Filesystem for accessing FTP hosts based on FUSE and libcurl";
+    homepage = http://curlftpfs.sourceforge.net;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/darling-dmg/default.nix b/nixpkgs/pkgs/tools/filesystems/darling-dmg/default.nix
new file mode 100644
index 000000000000..e44d0d229052
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/darling-dmg/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, fetchpatch, cmake, fuse, zlib, bzip2, openssl, libxml2, icu } :
+
+stdenv.mkDerivation rec {
+  name = "darling-dmg-${version}";
+  version = "1.0.4";
+
+  src = fetchFromGitHub {
+    owner = "darlinghq";
+    repo = "darling-dmg";
+    rev = "v${version}";
+    sha256 = "0x285p16zfnp0p6injw1frc8krif748sfgxhdd7gb75kz0dfbkrk";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://github.com/darlinghq/darling-dmg/commit/cbb0092264b5c5cf3e92d6c2de23f02d859ebf44.patch";
+    sha256 = "05fhgn5c09f1rva6bvbq16nhlkblrhscbf69k04ajwdh7y98sw39";
+     })
+  ];
+
+  buildInputs = [ cmake fuse openssl zlib bzip2 libxml2 icu ];
+
+  meta = {
+    homepage = http://www.darlinghq.org/;
+    description = "Darling lets you open macOS dmgs on Linux";
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/davfs2/default.nix b/nixpkgs/pkgs/tools/filesystems/davfs2/default.nix
new file mode 100644
index 000000000000..2b6d0f6e669b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/davfs2/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchurl, neon, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "davfs2-1.5.4";
+
+  src = fetchurl {
+    url = "mirror://savannah/davfs2/${name}.tar.gz";
+    sha256 = "1q4ngkzbkq0rfxikvkwg7ccpzi1nkkmlf8bb46326y1aj7qf1i69";
+  };
+
+  buildInputs = [ neon zlib ];
+
+  patches = [ ./isdir.patch ./fix-sysconfdir.patch ];
+
+  configureFlags = [ "--sysconfdir=/etc" ];
+
+  makeFlags = ["sbindir=$(out)/sbin" "ssbindir=$(out)/sbin"];
+
+  meta = {
+    homepage = https://savannah.nongnu.org/projects/davfs2;
+    description = "Mount WebDAV shares like a typical filesystem";
+    license = stdenv.lib.licenses.gpl3Plus;
+
+    longDescription = ''
+      Web Distributed Authoring and Versioning (WebDAV), an extension to
+      the HTTP-protocol, allows authoring of resources on a remote web
+      server. davfs2 provides the ability to access such resources like
+      a typical filesystem, allowing for use by standard applications
+      with no built-in support for WebDAV.
+    '';
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.peti ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/davfs2/fix-sysconfdir.patch b/nixpkgs/pkgs/tools/filesystems/davfs2/fix-sysconfdir.patch
new file mode 100644
index 000000000000..f71248a28f4d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/davfs2/fix-sysconfdir.patch
@@ -0,0 +1,60 @@
+diff -ubr davfs2-1.4.7-orig/etc/Makefile.am davfs2-1.4.7/etc/Makefile.am
+--- davfs2-1.4.7-orig/etc/Makefile.am	2013-02-21 11:45:00.185763558 +0100
++++ davfs2-1.4.7/etc/Makefile.am	2013-02-21 11:53:05.423197775 +0100
+@@ -24,17 +24,17 @@
+ 
+ install-data-local: $(dist_pkgdata_DATA)
+ 	@$(NORMAL_INSTALL)
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)
+-	$(INSTALL_DATA) -b davfs2.conf $(DESTDIR)$(pkgsysconfdir)/davfs2.conf
+-	$(INSTALL_DATA) -b -m 600 secrets $(DESTDIR)$(pkgsysconfdir)/secrets
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)/certs
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)/certs/private
+-	chmod 700 $(DESTDIR)$(pkgsysconfdir)/certs/private
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)
++	$(INSTALL_DATA) -b davfs2.conf $(out)$(pkgsysconfdir)/davfs2.conf
++	$(INSTALL_DATA) -b -m 600 secrets $(out)$(pkgsysconfdir)/secrets
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)/certs
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)/certs/private
++	chmod 700 $(out)$(pkgsysconfdir)/certs/private
+ 
+ uninstall-local:
+ 	@$(NORMAL_UNINSTALL)
+ 	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
+ 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
+-	  echo " rm -f $(DESTDIR)$(pkgsysconfdir)/$$f"; \
+-	  rm -f $(DESTDIR)$(pkgsysconfdir)/$$f; \
++	  echo " rm -f $(out)$(pkgsysconfdir)/$$f"; \
++	  rm -f $(out)$(pkgsysconfdir)/$$f; \
+ 	done
+diff -ubr davfs2-1.4.7-orig/etc/Makefile.in davfs2-1.4.7/etc/Makefile.in
+--- davfs2-1.4.7-orig/etc/Makefile.in	2013-02-21 11:45:00.185763558 +0100
++++ davfs2-1.4.7/etc/Makefile.in	2013-02-21 11:53:27.241207128 +0100
+@@ -408,19 +408,19 @@
+ 
+ install-data-local: $(dist_pkgdata_DATA)
+ 	@$(NORMAL_INSTALL)
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)
+-	$(INSTALL_DATA) -b davfs2.conf $(DESTDIR)$(pkgsysconfdir)/davfs2.conf
+-	$(INSTALL_DATA) -b -m 600 secrets $(DESTDIR)$(pkgsysconfdir)/secrets
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)/certs
+-	$(mkinstalldirs) $(DESTDIR)$(pkgsysconfdir)/certs/private
+-	chmod 700 $(DESTDIR)$(pkgsysconfdir)/certs/private
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)
++	$(INSTALL_DATA) -b davfs2.conf $(out)$(pkgsysconfdir)/davfs2.conf
++	$(INSTALL_DATA) -b -m 600 secrets $(out)$(pkgsysconfdir)/secrets
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)/certs
++	$(mkinstalldirs) $(out)$(pkgsysconfdir)/certs/private
++	chmod 700 $(out)$(pkgsysconfdir)/certs/private
+ 
+ uninstall-local:
+ 	@$(NORMAL_UNINSTALL)
+ 	@list='$(dist_pkgdata_DATA)'; for p in $$list; do \
+ 	  f="`echo $$p | sed -e 's|^.*/||'`"; \
+-	  echo " rm -f $(DESTDIR)$(pkgsysconfdir)/$$f"; \
+-	  rm -f $(DESTDIR)$(pkgsysconfdir)/$$f; \
++	  echo " rm -f $(out)$(pkgsysconfdir)/$$f"; \
++	  rm -f $(out)$(pkgsysconfdir)/$$f; \
+ 	done
+ 
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/nixpkgs/pkgs/tools/filesystems/davfs2/isdir.patch b/nixpkgs/pkgs/tools/filesystems/davfs2/isdir.patch
new file mode 100644
index 000000000000..ae69b4460f5a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/davfs2/isdir.patch
@@ -0,0 +1,30 @@
+diff -ur davfs2-1.4.5-old/src/dav_coda.c davfs2-1.4.5-new/src/dav_coda.c
+--- davfs2-1.4.5-old/src/dav_coda.c	2009-06-04 20:30:32.000000000 +0200
++++ davfs2-1.4.5-new/src/dav_coda.c	2011-02-09 19:51:22.260530572 +0100
+@@ -52,6 +52,10 @@
+ #ifdef HAVE_SYS_TYPES_H
+ #include <sys/types.h>
+ #endif
++#ifdef HAVE_SYS_STAT_H
++#include <sys/stat.h>
++#endif
++
+ 
+ #include "defaults.h"
+ #include "mount_davfs.h"
+diff -ur davfs2-1.4.5-old/src/dav_fuse.c davfs2-1.4.5-new/src/dav_fuse.c
+--- davfs2-1.4.5-old/src/dav_fuse.c	2009-06-30 20:06:44.000000000 +0200
++++ davfs2-1.4.5-new/src/dav_fuse.c	2011-02-09 19:52:23.938220524 +0100
+@@ -41,6 +41,12 @@
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
++#ifdef HAVE_SYS_TYPES_H
++#include <sys/types.h>
++#endif
++#ifdef HAVE_SYS_STAT_H
++#include <sys/stat.h>
++#endif
+ 
+ #include "defaults.h"
+ #include "mount_davfs.h"
diff --git a/nixpkgs/pkgs/tools/filesystems/dislocker/default.nix b/nixpkgs/pkgs/tools/filesystems/dislocker/default.nix
new file mode 100644
index 000000000000..2e4ea88df7f4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/dislocker/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub
+, cmake
+, polarssl , fuse
+}:
+with stdenv.lib;
+let
+  version = "0.7.1";
+in
+stdenv.mkDerivation rec {
+  name = "dislocker-${version}";
+
+  src = fetchFromGitHub {
+    owner = "aorimn";
+    repo = "dislocker";
+    rev = "v${version}";
+    sha256 = "1crh2sg5x1kgqmdrl1nmrqwxjykxa4zwnbggcpdn97mj2gvdw7sb";
+  };
+
+  buildInputs = [ cmake fuse polarssl ];
+
+  meta = {
+    description = "Read BitLocker encrypted partitions in Linux";
+    homepage    = https://github.com/aorimn/dislocker;
+    license     = licenses.gpl2;
+    maintainers = with maintainers; [ elitak ];
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/disorderfs/default.nix b/nixpkgs/pkgs/tools/filesystems/disorderfs/default.nix
new file mode 100644
index 000000000000..07a9015fa28e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/disorderfs/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, pkgconfig, fuse, attr, asciidoc }:
+
+stdenv.mkDerivation rec {
+  name = "disorderfs-${version}";
+  version = "0.5.5";
+
+  src = fetchurl {
+    url = "http://http.debian.net/debian/pool/main/d/disorderfs/disorderfs_${version}.orig.tar.gz";
+    sha256 = "1y1i7k5mx2pxr9bpijnsjyyw8qd7ak1h48gf6a6ca3dhna9ws6i1";
+  };
+
+  nativeBuildInputs = [ pkgconfig asciidoc ];
+
+  buildInputs = [ fuse attr ];
+
+  sourceRoot = ".";
+
+  installFlags = [ "PREFIX=$(out)" ];
+
+  meta = with stdenv.lib; {
+    description = "An overlay FUSE filesystem that introduces non-determinism into filesystem metadata";
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ pSub ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/djmount/default.nix b/nixpkgs/pkgs/tools/filesystems/djmount/default.nix
new file mode 100644
index 000000000000..e8deeaf4b470
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/djmount/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, pkgconfig, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "djmount-${version}";
+  version = "0.71";
+  src = fetchurl {
+    url = "mirror://sourceforge/djmount/${version}/${name}.tar.gz";
+    sha256 = "0kqf0cy3h4cfiy5a2sigmisx0lvvsi1n0fbyb9ll5gacmy1b8nxa";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse];
+
+  meta = {
+    homepage = http://djmount.sourceforge.net/;
+    description = "UPnP AV client, mounts as a Linux filesystem the media content of compatible UPnP AV devices";
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.jagajaga ];
+    license = stdenv.lib.licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/dosfstools/default.nix b/nixpkgs/pkgs/tools/filesystems/dosfstools/default.nix
new file mode 100644
index 000000000000..bc79577ab2b5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/dosfstools/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, libiconv }:
+
+stdenv.mkDerivation rec {
+  name = "dosfstools-${version}";
+  version = "4.1";
+
+  src = fetchFromGitHub {
+    owner = "dosfstools";
+    repo = "dosfstools";
+    rev = "v${version}";
+    sha256 = "1a2zn1655d5f1m6jp9vpn3bp8yfxhcmxx3mx23ai9hmxiydiykr1";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ]
+    ++ stdenv.lib.optional stdenv.isDarwin libiconv;
+
+  configureFlags = [ "--enable-compat-symlinks" ];
+
+  meta = {
+    description = "Utilities for creating and checking FAT and VFAT file systems";
+    repositories.git = git://daniel-baumann.ch/git/software/dosfstools.git;
+    homepage = https://www.daniel-baumann.ch/software/dosfstools/;
+    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
+    license = stdenv.lib.licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/duff/default.nix b/nixpkgs/pkgs/tools/filesystems/duff/default.nix
new file mode 100644
index 000000000000..e1b11a370553
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/duff/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, gettext }:
+
+stdenv.mkDerivation rec {
+  name = "duff-${version}";
+  # The last release (0.5.2) is more than 2 years old and lacks features like -D,
+  # limiting its usefulness. Upstream appears comatose if not dead.
+  version = "2014-07-03";
+
+  src = fetchFromGitHub {
+    sha256 = "1k2dx38pjzc5d624vw1cs5ipj9fprsm5vqv55agksc29m63lswnx";
+    rev = "f26d4837768b062a3f98fa075c791d9c8a0bb75c";
+    repo = "duff";
+    owner = "elmindreda";
+  };
+
+  nativeBuildInputs = [ autoreconfHook gettext ];
+
+  preAutoreconf = ''
+    # gettexttize rightly refuses to run non-interactively:
+    cp ${gettext}/bin/gettextize .
+    substituteInPlace gettextize \
+      --replace "read dummy" "echo '(Automatically acknowledged)' #"
+    ./gettextize
+    sed 's@po/Makefile.in\( .*\)po/Makefile.in@po/Makefile.in \1@' \
+      -i configure.ac
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "Quickly find duplicate files";
+    longDescription = ''
+      Duff is a Unix command-line utility for quickly finding duplicates in
+      a given set of files.
+    '';
+    homepage = http://duff.dreda.org/;
+    license = licenses.zlib;
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/duperemove/default.nix b/nixpkgs/pkgs/tools/filesystems/duperemove/default.nix
new file mode 100644
index 000000000000..208cbb83209c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/duperemove/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchFromGitHub, libgcrypt
+, pkgconfig, glib, linuxHeaders ? stdenv.cc.libc.linuxHeaders, sqlite }:
+
+stdenv.mkDerivation rec {
+  name = "duperemove-${version}";
+  version = "0.11.1";
+
+  src = fetchFromGitHub {
+    owner = "markfasheh";
+    repo = "duperemove";
+    rev = "v${version}";
+    sha256 = "1scz76pvpljvrpfn176125xwaqwyy4pirlm11sc9spb2hyzknw2z";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libgcrypt glib linuxHeaders sqlite ];
+
+  makeFlags = [ "PREFIX=${placeholder "out"}" ];
+
+  meta = with stdenv.lib; {
+    description = "A simple tool for finding duplicated extents and submitting them for deduplication";
+    homepage = https://github.com/markfasheh/duperemove;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ bluescreen303 thoughtpolice ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/e2fsprogs/default.nix b/nixpkgs/pkgs/tools/filesystems/e2fsprogs/default.nix
new file mode 100644
index 000000000000..168bf7d076ce
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/e2fsprogs/default.nix
@@ -0,0 +1,54 @@
+{ stdenv, buildPackages, fetchurl, fetchpatch, pkgconfig, libuuid, gettext, texinfo, perl }:
+
+stdenv.mkDerivation rec {
+  name = "e2fsprogs-1.44.4";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/e2fsprogs/${name}.tar.gz";
+    sha256 = "1cnwfmv9r7s73xhgghqspjq593pc4qghh80wjd0kjdgwy247cw6x";
+  };
+
+  outputs = [ "bin" "dev" "out" "man" "info" ];
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [ pkgconfig texinfo ];
+  buildInputs = [ libuuid gettext ];
+
+  # Only use glibc's __GNUC_PREREQ(X,Y) (checks if compiler is gcc version >= X.Y) when using glibc
+  patches = if stdenv.hostPlatform.libc == "glibc" then null
+    else [
+      (fetchpatch {
+      url = "https://raw.githubusercontent.com/void-linux/void-packages/1f3b51493031cc0309009804475e3db572fc89ad/srcpkgs/e2fsprogs/patches/fix-glibcism.patch";
+      sha256 = "1q7y8nhsfwl9r1q7nhrlikazxxj97p93kgz5wh7723cshlji2vaa";
+      extraPrefix = "";
+      })
+    ];
+
+  configureFlags =
+    if stdenv.isLinux then [
+      "--enable-elf-shlibs" "--enable-symlink-install" "--enable-relative-symlinks"
+      # libuuid, libblkid, uuidd and fsck are in util-linux-ng (the "libuuid" dependency).
+      "--disable-libuuid" "--disable-uuidd" "--disable-libblkid" "--disable-fsck"
+    ] else [
+      "--enable-libuuid --disable-e2initrd-helper"
+    ];
+
+  checkInputs = [ perl ];
+  doCheck = false; # fails
+
+  # hacky way to make it install *.pc
+  postInstall = ''
+    make install-libs
+    rm "$out"/lib/*.a
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = http://e2fsprogs.sourceforge.net/;
+    description = "Tools for creating and checking ext2/ext3/ext4 filesystems";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.eelco ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/e2tools/default.nix b/nixpkgs/pkgs/tools/filesystems/e2tools/default.nix
new file mode 100644
index 000000000000..dcaad81a5a3f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/e2tools/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, pkgconfig, e2fsprogs }:
+
+stdenv.mkDerivation rec {
+  pname = "e2tools";
+  version = "0.0.16";
+  name = "${pname}-${version}";
+
+  src = fetchurl {
+    url = "http://home.earthlink.net/~k_sheff/sw/${pname}/${name}.tar.gz";
+    sha256 = "16wlc54abqz06dpipjdkw58bncpkxlj5f55lkzy07k3cg0bqwg2f";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ e2fsprogs ];
+
+  enableParallelBuilding = true;
+
+  meta = {
+    homepage = http://home.earthlink.net/~k_sheff/sw/e2tools/;
+    description = "Utilities to read/write/manipulate files in an ext2/ext3 filesystem";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.leenaars ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/encfs/default.nix b/nixpkgs/pkgs/tools/filesystems/encfs/default.nix
new file mode 100644
index 000000000000..1a9951a33fd7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/encfs/default.nix
@@ -0,0 +1,34 @@
+{ stdenv, fetchFromGitHub
+, cmake, pkgconfig, perl
+, gettext, fuse, openssl, tinyxml2
+}:
+
+stdenv.mkDerivation rec {
+  name = "encfs-${version}";
+  version = "1.9.5";
+
+  src = fetchFromGitHub {
+    sha256 = "099rjb02knr6yz7przlnyj62ic0ag5ncs7vvcc36ikyqrmpqsdch";
+    rev = "v${version}";
+    repo = "encfs";
+    owner = "vgough";
+  };
+
+  buildInputs = [ gettext fuse openssl tinyxml2 ];
+  nativeBuildInputs = [ cmake pkgconfig perl ];
+
+  cmakeFlags =
+    [ "-DUSE_INTERNAL_TINYXML=OFF"
+      "-DBUILD_SHARED_LIBS=ON"
+      "-DINSTALL_LIBENCFS=ON"
+    ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "An encrypted filesystem in user-space via FUSE";
+    homepage = https://vgough.github.io/encfs;
+    license = with licenses; [ gpl3 lgpl3 ];
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/exfat/default.nix b/nixpkgs/pkgs/tools/filesystems/exfat/default.nix
new file mode 100644
index 000000000000..97a96651a68e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/exfat/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "exfat-${version}";
+  version = "1.3.0";
+
+  src = fetchFromGitHub {
+    owner = "relan";
+    repo = "exfat";
+    rev = "v${version}";
+    sha256 = "1q29pcysv747y6dis07953dkax8k9x50b5gg99gpz6rr46xwgkgb";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ fuse ];
+
+  meta = with stdenv.lib; {
+    description = "Free exFAT file system implementation";
+    inherit (src.meta) homepage;
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ dywedir ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/ext4magic/default.nix b/nixpkgs/pkgs/tools/filesystems/ext4magic/default.nix
new file mode 100644
index 000000000000..0211ab63b3e9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ext4magic/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchurl, fetchpatch, file, libuuid, e2fsprogs, zlib, bzip2 }:
+
+stdenv.mkDerivation rec {
+  version = "0.3.2";
+  name = "ext4magic-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/ext4magic/${name}.tar.gz";
+    sha256 = "8d9c6a594f212aecf4eb5410d277caeaea3adc03d35378257dfd017ef20ea115";
+  };
+
+  patches = [
+    (fetchpatch {
+        url = https://sourceforge.net/p/ext4magic/tickets/10/attachment/ext4magic-0.3.2-i_dir_acl.patch;
+        sha256 = "1accydd8kigid68yir2fbihm3r3x8ws3iyznp25snkx41w6y6x8c";
+    })
+  ];
+
+  buildInputs = [ file libuuid e2fsprogs zlib bzip2 ];
+  installFlags = [ "PREFIX=$(out)" ];
+
+  meta = with stdenv.lib; {
+    description = "Recover / undelete files from ext3 or ext4 partitions";
+    longDescription = ''
+      ext4magic can recover/undelete files from ext3 or ext4 partitions
+      by retrieving file-information from the filesystem journal.
+
+      If the information in the journal are sufficient, ext4magic can
+      recover the most file types, with original filename, owner and group,
+      file mode bits and also the old atime/mtime stamps. 
+
+      It's much more effective and works much better than extundelete.
+    '';
+    homepage = http://ext4magic.sourceforge.net/ext4magic_en.html;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.rkoe ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/extundelete/default.nix b/nixpkgs/pkgs/tools/filesystems/extundelete/default.nix
new file mode 100644
index 000000000000..e0c5ea3def4e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/extundelete/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, e2fsprogs }:
+
+stdenv.mkDerivation rec {
+  version = "0.2.4";
+  name = "extundelete-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/extundelete/extundelete-0.2.4.tar.bz2";
+    sha256 = "1x0r7ylxlp9lbj3d7sqf6j2a222dwy2nfpff05jd6mkh4ihxvyd1";
+  };
+
+  buildInputs = [ e2fsprogs ];
+
+  # inode field i_dir_acl was repurposed as i_size_high in e2fsprogs 1.44,
+  # breaking the build
+  patchPhase = ''
+    substituteInPlace src/insertionops.cc \
+      --replace "Directory ACL:" "High 32 bits of size:" \
+      --replace "inode.i_dir_acl" "inode.i_size_high"
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Utility that can recover deleted files from an ext3 or ext4 partition";
+    homepage = http://extundelete.sourceforge.net/;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.domenkozar ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/f2fs-tools/default.nix b/nixpkgs/pkgs/tools/filesystems/f2fs-tools/default.nix
new file mode 100644
index 000000000000..90bb443dfdd2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/f2fs-tools/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchgit, autoreconfHook, libselinux, libuuid, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "f2fs-tools-${version}";
+  version = "1.11.0";
+
+  src = fetchgit {
+    url = "https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git";
+    rev = "refs/tags/v${version}";
+    sha256 = "188yv77ga466wpzbirsx6vspym8idaschgi7cx92z4jwqpnkk5gv";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ libselinux libuuid ];
+
+  patches = [ ./f2fs-tools-cross-fix.patch ];
+
+  meta = with stdenv.lib; {
+    homepage = http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-tools.git/;
+    description = "Userland tools for the f2fs filesystem";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ehmry jagajaga ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/f2fs-tools/f2fs-tools-cross-fix.patch b/nixpkgs/pkgs/tools/filesystems/f2fs-tools/f2fs-tools-cross-fix.patch
new file mode 100644
index 000000000000..1503732240c3
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/f2fs-tools/f2fs-tools-cross-fix.patch
@@ -0,0 +1,27 @@
+--- f2fs-tools/configure.ac.orig	2018-11-29 05:05:57.154988687 +0300
++++ f2fs-tools/configure.ac	2018-11-29 05:06:12.667316101 +0300
+@@ -20,14 +20,16 @@
+ 				[\([0-9]*\).\([0-9]*\)\(\w\|\W\)*], [\2]),
+ 				[Minor version for f2fs-tools])
+ 
+-AC_CHECK_FILE(.git,
+-	AC_DEFINE([F2FS_TOOLS_DATE],
+-		"m4_bpatsubst(f2fs_tools_gitdate,
+-		[\([0-9-]*\)\(\w\|\W\)*], [\1])",
+-		[f2fs-tools date based on Git commits]),
+-	AC_DEFINE([F2FS_TOOLS_DATE],
+-		"f2fs_tools_date",
+-		[f2fs-tools date based on Source releases]))
++dnl AC_CHECK_FILE(.git,
++dnl 	AC_DEFINE([F2FS_TOOLS_DATE],
++dnl 		"m4_bpatsubst(f2fs_tools_gitdate,
++dnl 		[\([0-9-]*\)\(\w\|\W\)*], [\1])",
++dnl 		[f2fs-tools date based on Git commits]),
++dnl 	AC_DEFINE([F2FS_TOOLS_DATE],
++dnl 		"f2fs_tools_date",
++dnl 		[f2fs-tools date based on Source releases]))
++
++AC_DEFINE([F2FS_TOOLS_DATE], "f2fs_tools_date", [f2fs-tools date based on Source releases])
+ 
+ AC_CONFIG_SRCDIR([config.h.in])
+ AC_CONFIG_HEADER([config.h])
diff --git a/nixpkgs/pkgs/tools/filesystems/f3/default.nix b/nixpkgs/pkgs/tools/filesystems/f3/default.nix
new file mode 100644
index 000000000000..7fb9ed3c97ae
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/f3/default.nix
@@ -0,0 +1,39 @@
+{ stdenv, fetchFromGitHub
+, parted, udev
+}:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "f3";
+  version = "7.1";
+
+  enableParallelBuilding = true;
+
+  src = fetchFromGitHub {
+    owner = "AltraMayor";
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "0zglsmz683jg7f9wc6vmgljyg9w87pbnjw5x4w6x02w8233zvjqf";
+  };
+
+  buildInputs = [ parted udev ];
+
+  patchPhase = "sed -i 's/-oroot -groot//' Makefile";
+
+  buildFlags   = [ "all"                    # f3read, f3write
+                   "extra"                  # f3brew, f3fix, f3probe
+                 ];
+
+  installFlags = [ "PREFIX=$(out)"
+                   "install"
+                   "install-extra"
+                 ];
+
+  meta = {
+    description = "Fight Flash Fraud";
+    homepage = http://oss.digirati.com.br/f3/;
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ makefu ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fatresize/default.nix b/nixpkgs/pkgs/tools/filesystems/fatresize/default.nix
new file mode 100644
index 000000000000..7bb5dd415a6a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fatresize/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, parted, utillinux }:
+
+stdenv.mkDerivation rec {
+
+  version = "1.0.2";
+  name = "fatresize-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/fatresize/fatresize-${version}.tar.bz2";
+    sha256 = "04wp48jpdvq4nn0dgbw5za07g842rnxlh9mig4mslz70zqs0izjm";
+  };
+
+  buildInputs = [ parted utillinux ];
+
+  # This patch helps this unmantained piece of software to be built against recent parted
+  # It basically modifies the detection scheme for parted version (the current one has no micro version defined)
+  # The second change is to include a header for a moved function since 1.6+ to current 3.1+ parted
+  # The third change is to modify the call to PED_ASSERT that is no longer defined with 2 params
+  patches = [ ./fatresize_parted_nix.patch ];
+
+  preConfigure = ''
+    echo "Replacing calls to ped_free with free ..."
+    substituteInPlace ./fatresize.c --replace ped_free free
+  '';
+
+  # Filesystem resize functions were reintroduced in parted 3.1 due to no other available free alternatives
+  # but in a sepparate library -> libparted-fs-resize --- that's why the added LDFLAG
+  makeFlags = ''
+    LDFLAGS=-lparted-fs-resize
+  '';
+
+  propagatedBuildInputs = [ parted utillinux ];
+
+  meta = with stdenv.lib; {
+    description = "The FAT16/FAT32 non-destructive resizer";
+    homepage = https://sourceforge.net/projects/fatresize;
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fatresize/fatresize_parted_nix.patch b/nixpkgs/pkgs/tools/filesystems/fatresize/fatresize_parted_nix.patch
new file mode 100644
index 000000000000..e9aa87a2d564
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fatresize/fatresize_parted_nix.patch
@@ -0,0 +1,74 @@
+diff --git a/aclocal.m4 b/aclocal.m4
+index 18e8176..2e75592 100644
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -88,8 +88,15 @@ int main ()
+ 	if ( !(version = ped_get_version ()) )
+ 		exit(1);
+ 	if (sscanf(version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+-		printf("%s, bad version string\n", version);
+-		exit(1);
++		if (sscanf(version, "%d.%d", &major, &minor) != 2)
++		{
++		  printf("%s, bad version string\n", version);
++		  exit(1);
++		}
++		else
++		{
++		  micro = 0;
++		}
+ 	}
+ 	
+ 	if ((major > $parted_config_major_version) ||
+diff --git a/configure b/configure
+index ed31457..e5f1705 100755
+--- a/configure
++++ b/configure
+@@ -4793,8 +4793,15 @@ int main ()
+ 	if ( !(version = ped_get_version ()) )
+ 		exit(1);
+ 	if (sscanf(version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+-		printf("%s, bad version string\n", version);
+-		exit(1);
++		if (sscanf(version, "%d.%d", &major, &minor) != 2)
++		{
++		  printf("%s, bad version string\n", version);
++		  exit(1);
++		}
++		else
++		{
++		  micro = 0;
++		}
+ 	}
+ 
+ 	if ((major > $parted_config_major_version) ||
+diff --git a/fatresize.c b/fatresize.c
+index 424d5d2..e439102 100644
+--- a/fatresize.c
++++ b/fatresize.c
+@@ -30,6 +30,7 @@
+ #include <inttypes.h>
+ #include <parted/parted.h>
+ #include <parted/debug.h>
++#include <parted/filesys.h>
+ #include <parted/unit.h>
+ 
+ #include "config.h"
+@@ -217,7 +218,7 @@ fatresize_handler(PedException *ex)
+ static int
+ snap(PedSector* sector, PedSector new_sector, PedGeometry* range)
+ {
+-    PED_ASSERT(ped_geometry_test_sector_inside (range, *sector), return 0);
++    PED_ASSERT(ped_geometry_test_sector_inside (range, *sector));
+     if (!ped_geometry_test_sector_inside(range, new_sector))
+ 	return 0;
+ 
+@@ -281,7 +282,7 @@ snap_to_boundaries (PedGeometry* new_geom, PedGeometry* old_geom,
+ 			  end_part->geom.end, end_part->geom.start - 1, -1);
+ 	}
+ 
+-	PED_ASSERT (start <= end, return);
++	PED_ASSERT (start <= end);
+ 	ped_geometry_set (new_geom, start, end - start + 1);
+ }
+ 
diff --git a/nixpkgs/pkgs/tools/filesystems/fatsort/default.nix b/nixpkgs/pkgs/tools/filesystems/fatsort/default.nix
new file mode 100644
index 000000000000..18d9097dacbc
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fatsort/default.nix
@@ -0,0 +1,24 @@
+{stdenv, fetchurl, help2man}:
+
+stdenv.mkDerivation rec {
+  version = "1.5.0.456";
+  name = "fatsort-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/fatsort/${name}.tar.xz";
+    sha256 = "15fy2m4p9s8cfvnzdcd5ynkc2js0zklkkf34sjxdac7x2iwb8dd8";
+  };
+
+  patches = [ ./fatsort-Makefiles.patch ];
+
+  buildInputs = [ help2man ];
+
+  meta = with stdenv.lib; {
+    homepage = http://fatsort.sourceforge.net/;
+    description = "Sorts FAT partition table, for devices that don't do sorting of files";
+    maintainers = [ maintainers.kovirobi ];
+    license = licenses.gpl2;
+    inherit version;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fatsort/fatsort-Makefiles.patch b/nixpkgs/pkgs/tools/filesystems/fatsort/fatsort-Makefiles.patch
new file mode 100644
index 000000000000..9c9f58e97ab4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fatsort/fatsort-Makefiles.patch
@@ -0,0 +1,31 @@
+diff -uNr fatsort-1.3.365-a/Makefile fatsort-1.3.365-b/Makefile
+--- fatsort-1.3.365-a/Makefile	2014-04-08 19:19:36.000000000 +0100
++++ fatsort-1.3.365-b/Makefile	2014-12-14 18:31:55.982857720 +0000
+@@ -1,4 +1,5 @@
+-MANDIR=/usr/local/share/man/man1
++PREFIX=$(out)
++MANDIR=$(PREFIX)/share/man/man1
+ 
+ INSTALL_FLAGS=-m 0755 -p -D
+ 
+diff -uNr fatsort-1.3.365-a/src/Makefile fatsort-1.3.365-b/src/Makefile
+--- fatsort-1.3.365-a/src/Makefile	2014-04-08 19:19:36.000000000 +0100
++++ fatsort-1.3.365-b/src/Makefile	2014-12-14 18:32:08.282870461 +0000
+@@ -1,3 +1,5 @@
++PREFIX=$(out)
++
+ CC=gcc
+ LD=gcc
+ 
+@@ -33,9 +35,9 @@
+ 
+ # Mac OS X does not have a "/usr/local/sbin"
+ ifeq ($(UNAME),Darwin)
+-SBINDIR=/usr/local/bin
++SBINDIR=$(PREFIX)/bin
+ else
+-SBINDIR=/usr/local/sbin
++SBINDIR=$(PREFIX)/sbin
+ endif
+ 
+ OBJ=fatsort.o FAT_fs.o fileio.o endianness.o signal.o entrylist.o errors.o options.o clusterchain.o sort.o misc.o natstrcmp.o stringlist.o
diff --git a/nixpkgs/pkgs/tools/filesystems/file-rename/default.nix b/nixpkgs/pkgs/tools/filesystems/file-rename/default.nix
new file mode 100644
index 000000000000..6c226bb97845
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/file-rename/default.nix
@@ -0,0 +1,23 @@
+{ stdenv, fetchurl, perlPackages, makeWrapper }:
+
+perlPackages.buildPerlPackage rec {
+  name = "File-Rename-0.20";
+
+  src = fetchurl {
+    url = "mirror://cpan/authors/id/R/RM/RMBARKER/${name}.tar.gz";
+    sha256 = "1cf6xx2hiy1xalp35fh8g73j67r0w0g66jpcbc6971x9jbm7bvjy";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+
+  postInstall = ''
+    wrapProgram $out/bin/rename \
+      --prefix PERL5LIB : $out/lib/perl5/site_perl
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Perl extension for renaming multiple files";
+    license = licenses.artistic1;
+    maintainers = with maintainers; [ peterhoeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fsfs/default.nix b/nixpkgs/pkgs/tools/filesystems/fsfs/default.nix
new file mode 100644
index 000000000000..75e5280d391d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fsfs/default.nix
@@ -0,0 +1,30 @@
+{stdenv, fetchurl, openssl, fuse}:
+
+throw "It still does not build"
+
+stdenv.mkDerivation {
+  name = "fsfs-0.1.1";
+  src = fetchurl {
+    url = mirror://sourceforge/fsfs/fsfs-0.1.1.tar.gz;
+    sha256 = "05wka9aq182li2r7gxcd8bb3rhpns7ads0k59v7w1jza60l57c74";
+  };
+
+  buildInputs = [ fuse openssl ];
+
+  patchPhase = ''
+    sed -i -e 's,CONFDIR=\(.*\),CONFDIR='$out/etc, \
+      -e 's,USERCONFPREFIX=\(.*\),USERCONFPREFIX='$out/var/lib, Makefile \
+      src/Makefile src/utils/Makefile
+  '';
+
+  preInstall = ''
+    mkdir -p $out/etc $out/var/lib
+    makeFlags="$makeFlags prefix=$out"
+  '';
+
+  meta = {
+    homepage = http://fsfs.sourceforge.net/;
+    description = "Secure distributed file system in user space";
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fuse-7z-ng/default.nix b/nixpkgs/pkgs/tools/filesystems/fuse-7z-ng/default.nix
new file mode 100644
index 000000000000..82e2b404b82a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fuse-7z-ng/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub, fuse, p7zip, autoconf, automake, pkgconfig, makeWrapper }:
+
+stdenv.mkDerivation rec {
+  name = "${pname}-${version}";
+  pname = "fuse-7z-ng";
+  version = "git-2014-06-08";
+
+  src = fetchFromGitHub {
+    owner = "kedazo";
+    repo = pname;
+    rev = "eb5efb1f304c2b7bc2e0389ba06c9bf2ac4b932c";
+    sha256 = "17v1gcmg5q661b047zxjar735i4d3508dimw1x3z1pk4d1zjhp3x";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse autoconf automake makeWrapper ];
+
+  preConfigure = "./autogen.sh";
+
+  libs = stdenv.lib.makeLibraryPath [ p7zip ]; # 'cause 7z.so is loaded manually
+  postInstall = ''
+    wrapProgram $out/bin/${pname} --suffix LD_LIBRARY_PATH : "${libs}/p7zip"
+
+    mkdir -p $out/share/doc/${pname}
+    cp TODO README NEWS COPYING ChangeLog AUTHORS $out/share/doc/${pname}/
+  '';
+
+  meta = with stdenv.lib; {
+    inherit version;
+    inherit (src.homepage);
+    description = "A FUSE-based filesystem that uses the p7zip library";
+    longDescription = ''
+      fuse-7z-ng is a FUSE file system that uses the p7zip
+      library to access all archive formats supported by 7-zip.
+
+      This project is a fork of fuse-7z ( https://gitorious.org/fuse-7z/fuse-7z ).
+    '';
+    platforms = platforms.linux;
+    license = licenses.gpl3Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fuseiso/default.nix b/nixpkgs/pkgs/tools/filesystems/fuseiso/default.nix
new file mode 100644
index 000000000000..8a417cfe397d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fuseiso/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchurl, fetchpatch, pkgconfig, fuse, zlib, glib }:
+
+stdenv.mkDerivation rec {
+  name = "fuseiso-20070708";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/project/fuseiso/fuseiso/20070708/fuseiso-20070708.tar.bz2";
+    sha256 = "127xql52dcdhmh7s5m9xc6q39jdlj3zhbjar1j821kb6gl3jw94b";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse zlib glib ];
+
+  patches = let fetchPatchFromDebian = { patch, sha256 }:
+    fetchpatch {
+      inherit sha256;
+      url = "https://sources.debian.net/data/main/f/fuseiso/20070708-3.2/debian/patches/${patch}";
+    };
+  in [
+    (fetchPatchFromDebian {
+      patch = "00-support_large_iso.patch";
+      sha256 = "1lmclb1qwzz5f4wlq693g83bblwnjjl73qhgfxbsaac5hnn2shjw";
+    })
+    (fetchPatchFromDebian { # CVE-2015-8837
+      patch = "02-prevent-buffer-overflow.patch";
+      sha256 = "1ls2pp3mh91pdb51qz1fsd8pwhbky6988bpd156bn7wgfxqzh8ig";
+    })
+    (fetchPatchFromDebian { # CVE-2015-8836
+      patch = "03-prevent-integer-overflow.patch";
+      sha256 = "100cw07fk4sa3hl7a1gk2hgz4qsxdw99y20r7wpidwwwzy463zcv";
+    })
+  ];
+
+  meta = {
+    homepage = https://sourceforge.net/projects/fuseiso;
+    description = "FUSE module to mount ISO filesystem images";
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/fusesmb/default.nix b/nixpkgs/pkgs/tools/filesystems/fusesmb/default.nix
new file mode 100644
index 000000000000..ada9445218b9
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/fusesmb/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, samba, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "fusesmb-0.8.7";
+
+  src = fetchurl {
+    url = "http://www.ricardis.tudelft.nl/~vincent/fusesmb/download/${name}.tar.gz";
+    sha256 = "12gz2gn9iqjg27a233dn2wij7snm7q56h97k6gks0yijf6xcnpz1";
+  };
+
+  buildInputs = [ samba fuse ];
+
+  postInstall =
+    ''
+      mkdir -p $out/lib
+      ln -fs ${samba}/lib/libsmbclient.so $out/lib/libsmbclient.so.0
+    '';
+
+  hardeningDisable = [ "format" ];
+
+  meta = with stdenv.lib; {
+    description = "Samba mounted via FUSE";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    broken = true; # Needs vulnerable Samba, missing source link
+                   # 2018-08-21
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/gcsfuse/default.nix b/nixpkgs/pkgs/tools/filesystems/gcsfuse/default.nix
new file mode 100644
index 000000000000..215f02ccdd4e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/gcsfuse/default.nix
@@ -0,0 +1,25 @@
+# This file was generated by go2nix.
+{ lib, buildGoPackage, fetchgit }:
+
+buildGoPackage rec {
+  name = "gcsfuse-${version}";
+  version = "0.23.0";
+  rev = "v${version}";
+
+  goPackagePath = "github.com/googlecloudplatform/gcsfuse";
+
+  src = fetchgit {
+    inherit rev;
+    url = "https://github.com/googlecloudplatform/gcsfuse";
+    sha256 = "1qxbpsmz22l5w4b7wbgfdq4v85cfc9ka9i8h4c56nals1x5lcsnx";
+  };
+
+  meta = {
+    license = lib.licenses.asl20;
+    platforms = lib.platforms.linux;
+    maintainers = [];
+    homepage = https://cloud.google.com/storage/docs/gcs-fuse;
+    description =
+      "A user-space file system for interacting with Google Cloud Storage";
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/genext2fs/default.nix b/nixpkgs/pkgs/tools/filesystems/genext2fs/default.nix
new file mode 100644
index 000000000000..0ef85abd2b77
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/genext2fs/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation {
+  name = "genext2fs-1.4.1";
+  
+  src = fetchurl {
+    url = mirror://sourceforge/genext2fs/genext2fs-1.4.1.tar.gz;
+    sha256 = "1z7czvsf3ircvz2cw1cf53yifsq29ljxmj15hbgc79l6gbxbnka0";
+  };
+
+  # https://sourceforge.net/p/genext2fs/bugs/2/
+  # Will be fixed in the next release, whenever this happens
+  postPatch = ''
+    sed -e 's@4 [*] (EXT2_TIND_BLOCK+1)@-1+&@' -i genext2fs.c
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://genext2fs.sourceforge.net/;
+    description = "A tool to generate ext2 filesystem images without requiring root privileges";
+    license = licenses.gpl2;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/genimage/default.nix b/nixpkgs/pkgs/tools/filesystems/genimage/default.nix
new file mode 100644
index 000000000000..581970e34fa7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/genimage/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, pkgconfig, libconfuse, gettext }:
+
+stdenv.mkDerivation rec {
+  name = "genimage-${version}";
+  version = "9";
+
+  src = fetchurl {
+    url = "https://public.pengutronix.de/software/genimage/genimage-${version}.tar.xz";
+    sha256 = "0y4h8x8lqxam8m90rdfq8cg5137kvilxr3d1qzddpx7nxpvmmwv9";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libconfuse gettext ];
+
+  postInstall = ''
+    # As there is no manpage or built-in --help, add the README file for
+    # documentation.
+    docdir="$out/share/doc/genimage"
+    mkdir -p "$docdir"
+    cp -v README "$docdir"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://git.pengutronix.de/cgit/genimage;
+    description = "Generate filesystem images from directory trees";
+    license = licenses.gpl2Plus;
+    platforms = platforms.all;
+    maintainers = [ maintainers.bjornfor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/genromfs/default.nix b/nixpkgs/pkgs/tools/filesystems/genromfs/default.nix
new file mode 100644
index 000000000000..6a3e280aae36
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/genromfs/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  version = "0.5.2";
+  name = "genromfs-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/romfs/genromfs/${version}/${name}.tar.gz";
+    sha256 = "0q6rpq7cmclmb4ayfyknvzbqysxs4fy8aiahlax1sb2p6k3pzwrh";
+  };
+
+  postPatch = ''
+    substituteInPlace Makefile \
+      --replace "prefix = /usr" "prefix = $out" \
+      --replace "gcc" "cc"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://romfs.sourceforge.net/;
+    description = "Tool for creating romfs file system images";
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ pxc ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/gitfs/default.nix b/nixpkgs/pkgs/tools/filesystems/gitfs/default.nix
new file mode 100644
index 000000000000..ec734e52f733
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/gitfs/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub, python2Packages }:
+
+python2Packages.buildPythonApplication rec {
+  name = "gitfs-${version}";
+  version = "0.4.5.1";
+
+  src = fetchFromGitHub {
+    owner = "PressLabs";
+    repo = "gitfs";
+    rev = version;
+    sha256 = "1s9ml2ryqxvzzq9mxa9y3xmzr742qxcpw9kzzbr7vm3bxgkyi074";
+  };
+
+  patchPhase = ''
+    # requirement checks are unnecessary at runtime
+    echo > requirements.txt
+  '';
+
+  buildInputs = with python2Packages; [ pytest pytestcov mock ];
+  propagatedBuildInputs = with python2Packages; [ atomiclong fusepy pygit2 ];
+
+  checkPhase = "py.test";
+  doCheck = false;
+
+  meta = {
+    description = "A FUSE filesystem that fully integrates with git";
+    longDescription = ''
+      A git remote repository's branch can be mounted locally,
+      and any subsequent changes made to the files will be
+      automatically committed to the remote.
+    '';
+    homepage = https://github.com/PressLabs/gitfs;
+    license = stdenv.lib.licenses.asl20;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ stdenv.lib.maintainers.robbinch ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/glusterfs/default.nix b/nixpkgs/pkgs/tools/filesystems/glusterfs/default.nix
new file mode 100644
index 000000000000..e915cc1c132a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/glusterfs/default.nix
@@ -0,0 +1,195 @@
+{stdenv, fetchurl, fuse, bison, flex_2_5_35, openssl, python2, ncurses, readline,
+ autoconf, automake, libtool, pkgconfig, zlib, libaio, libxml2, acl, sqlite,
+ liburcu, attr, makeWrapper, coreutils, gnused, gnugrep, which,
+ openssh, gawk, findutils, utillinux, lvm2, btrfs-progs, e2fsprogs, xfsprogs, systemd,
+ rsync, glibc
+}:
+let
+  s =
+  rec {
+    baseName="glusterfs";
+    # NOTE: On each glusterfs release, it should be checked if gluster added
+    #       new, or changed, Python scripts whose PYTHONPATH has to be set in
+    #       `postFixup` below, and whose runtime deps need to go into
+    #       `nativeBuildInputs`.
+    #       The command
+    #         find /nix/store/...-glusterfs-.../ -name '*.py' -executable
+    #       can help with finding new Python scripts.
+    version = "4.0.0";
+    name="${baseName}-${version}";
+    url="https://github.com/gluster/glusterfs/archive/v${version}.tar.gz";
+    sha256 = "0af3fwiixddds6gdwhkyq3l214mmjl2wpjc2qayp5rpz79lnclq3";
+  };
+  buildInputs = [
+    fuse bison flex_2_5_35 openssl ncurses readline
+    autoconf automake libtool pkgconfig zlib libaio libxml2
+    acl sqlite liburcu attr makeWrapper
+    (python2.withPackages (pkgs: [
+      pkgs.flask
+      pkgs.prettytable
+      pkgs.requests
+      pkgs.pyxattr
+    ]))
+    # NOTE: `python2` has to be *AFTER* the above `python2.withPackages`,
+    #       to ensure that the packages are available but the `toPythonPath`
+    #       shell function used in `postFixup` is also still available.
+    python2
+  ];
+  # Some of the headers reference acl
+  propagatedBuildInputs = [
+    acl
+  ];
+  # Packages from which GlusterFS calls binaries at run-time from PATH,
+  # with comments on which commands are known to be called by it.
+  runtimePATHdeps = [
+    attr # getfattr setfattr
+    btrfs-progs # btrfs
+    coreutils # lots of commands in bash scripts
+    e2fsprogs # tune2fs
+    findutils # find
+    gawk # awk
+    glibc # getent
+    gnugrep # grep
+    gnused # sed
+    lvm2 # lvs
+    openssh # ssh
+    rsync # rsync, e.g. for geo-replication
+    systemd # systemctl
+    utillinux # mount umount
+    which # which
+    xfsprogs # xfs_info
+  ];
+in
+stdenv.mkDerivation
+rec {
+  inherit (s) name version;
+  inherit buildInputs propagatedBuildInputs;
+
+  postPatch = ''
+    sed -e '/chmod u+s/d' -i contrib/fuse-util/Makefile.am
+  '';
+
+  patches = [
+    # Remove when https://bugzilla.redhat.com/show_bug.cgi?id=1450546 is fixed
+    ./glusterfs-use-PATH-instead-of-hardcodes.patch
+    # Remove when https://bugzilla.redhat.com/show_bug.cgi?id=1450593 is fixed
+    ./glusterfs-python-remove-find_library.patch
+    # Remove when https://bugzilla.redhat.com/show_bug.cgi?id=1489610 is fixed
+    ./glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch
+    # Remove when https://bugzilla.redhat.com/show_bug.cgi?id=1559130 is fixed
+    ./glusterfs-glusterfind-log-remote-node_cmd-error.patch
+  ];
+
+   # Note that the VERSION file is something that is present in release tarballs
+   # but not in git tags (at least not as of writing in v3.10.1).
+   # That's why we have to create it.
+   # Without this, gluster (at least 3.10.1) will fail very late and cryptically,
+   # for example when setting up geo-replication, with a message like
+   #   Staging of operation 'Volume Geo-replication Create' failed on localhost : Unable to fetch master volume details. Please check the master cluster and master volume.
+   # What happens here is that the gverify.sh script tries to compare the versions,
+   # but fails when the version is empty.
+   # See upstream GlusterFS bug https://bugzilla.redhat.com/show_bug.cgi?id=1452705
+   preConfigure = ''
+     echo "v${s.version}" > VERSION
+    ./autogen.sh
+    '';
+
+  configureFlags = [
+    ''--localstatedir=/var''
+    ];
+
+  makeFlags = "DESTDIR=$(out)";
+
+  enableParallelBuilding = true;
+
+  postInstall = ''
+    cp -r $out/$out/* $out
+    rm -r $out/nix
+    '';
+
+  postFixup = ''
+    # glusterd invokes `gluster` and other utilities when telling other glusterd nodes to run commands.
+    # For example for `peer_georep-sshkey` key generation, so `$out/bin` is needed in the PATH.
+    # It also invokes bash scripts like `gverify.sh`.
+    # It also invokes executable Python scripts in `$out/libexec/glusterfs`, which is why we set up PYTHONPATH accordingly.
+    # We set up the paths for the main entry point executables.
+
+    GLUSTER_PATH="${stdenv.lib.makeBinPath runtimePATHdeps}:$out/bin"
+    GLUSTER_PYTHONPATH="$(toPythonPath $out):$out/libexec/glusterfs"
+    GLUSTER_LD_LIBRARY_PATH="$out/lib"
+
+    wrapProgram $out/bin/glusterd --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/bin/gluster --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/sbin/mount.glusterfs --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+
+    # Set Python environment for the Python based utilities.
+    # It would be nice if there was a better way to do this, automatically for all of them.
+    # Also, this is brittle: If we forget a dependency or gluster adds a new one, things will break deep inside gluster.
+    # We should better try to get an explicit list of Python dependencies from gluster and ensure all of them are in the PYTHONPATH of all these python scripts.
+    # But at the time of writing (gluster 3.10), gluster only provides this in form of a gluster.spec file for RPM creation,
+    # and even that one is not complete (for example it doesn't mention the `flask` dependency).
+
+    wrapProgram $out/bin/gluster-eventsapi --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/bin/gluster-georep-sshkey --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/bin/gluster-mountbroker --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/bin/glusterfind --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+
+    # Note that we only wrap the symlinks in $out/bin, not the actual executable scripts in $out/libexec/glusterfs.
+    # This is because those scripts use `__file__` in their program logic
+    # (see https://github.com/gluster/glusterfs/blob/v3.10.1/extras/cliutils/cliutils.py#L116)
+    # which would break if we changed the file name (which is what `wrapProgram` does).
+    # Luckily, `libexec` scripts are never supposed to be invoked straight from PATH,
+    # instead they are invoked directly from `gluster` or `glusterd`, which is why it is
+    # sufficient to set PYTHONPATH for those executables.
+    #
+    # Exceptions to these rules are the `glusterfind` `brickfind.py` and `changelog.py`
+    # crawlers, which are directly invoked on other gluster nodes using a remote SSH command
+    # issues by `glusterfind`.
+
+    wrapProgram $out/share/glusterfs/scripts/eventsdash.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/libexec/glusterfs/glusterfind/brickfind.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    wrapProgram $out/libexec/glusterfs/glusterfind/changelog.py --set PATH "$GLUSTER_PATH" --set PYTHONPATH "$GLUSTER_PYTHONPATH" --set LD_LIBRARY_PATH "$GLUSTER_LD_LIBRARY_PATH"
+    '';
+
+  doInstallCheck = true;
+
+  # Below we run Python programs. That generates .pyc/.pyo files.
+  # By default they are indeterministic because such files contain time stamps
+  # (see https://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html).
+  # So we use the same environment variables as in
+  #   https://github.com/NixOS/nixpkgs/blob/249b34aadca7038207492f29142a3456d0cecec3/pkgs/development/interpreters/python/mk-python-derivation.nix#L61
+  # to make these files deterministic.
+  # A general solution to this problem might be brought by #25707.
+  DETERMINISTIC_BUILD = 1;
+  PYTHONHASHSEED = 0;
+
+  installCheckPhase = ''
+    # Tests that the above programs work without import errors.
+    # For testing it manually in a shell you may want to substitute `$out` with `$(dirname $(readlink -f $(which gluster)))/../`.
+    $out/bin/glusterd --help
+    # $out/bin/gluster help # can't do this because even `gluster help` tries to write to `/var/log/glusterfs/cli.log`
+    $out/bin/gluster-eventsapi --help
+    $out/bin/gluster-georep-sshkey --help
+    $out/bin/gluster-mountbroker --help
+    $out/bin/glusterfind --help
+    # gfid_to_path.py doesn't accept --help, and it requires different arguments
+    # (a dir as single argument) than the usage prints when stdin is not a TTY.
+    # The `echo ""` is just so that stdin is not a TTY even if you try this line
+    # on a real TTY for testing purposes.
+    echo "" | (mkdir -p nix-test-dir-for-gfid_to_path && touch b && $out/libexec/glusterfs/gfind_missing_files/gfid_to_path.py nix-test-dir-for-gfid_to_path)
+    $out/share/glusterfs/scripts/eventsdash.py --help
+    '';
+
+  src = fetchurl {
+    inherit (s) url sha256;
+  };
+
+  meta = with stdenv.lib; {
+    inherit (s) version;
+    description = "Distributed storage system";
+    homepage = https://www.gluster.org;
+    license = licenses.lgpl3Plus; # dual licese: choice of lgpl3Plus or gpl2
+    maintainers = [ maintainers.raskin ];
+    platforms = with platforms; linux ++ freebsd;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch
new file mode 100644
index 000000000000..f679fb8f4c1b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-fix-bug-1489610-glusterfind-var-data-under-prefix.patch
@@ -0,0 +1,27 @@
+From f523afac49e24ecc0fa4ad85195135689cf445f0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
+Date: Wed, 27 Sep 2017 21:36:41 +0200
+Subject: [PATCH] Fix "glusterfind saves var data under $prefix instead of
+ localstatedir". Fixes #1489610
+
+Change-Id: Id2362c20f34346c37acfb9eb1ad105d0b7b8b60f
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index f87d8a454..b4d3f5d10 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1118,7 +1118,7 @@ if test "x$exec_prefix" = xNONE; then
+ 	exec_prefix="$(eval echo $prefix)"
+ fi
+ GLUSTERFS_LIBEXECDIR="$(eval echo $libexecdir)/glusterfs"
+-GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd"
++GLUSTERFSD_MISCDIR="$(eval echo $localstatedir)/var/lib/misc/glusterfsd"
+ prefix=$old_prefix
+ exec_prefix=$old_exec_prefix
+ 
+-- 
+2.12.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch
new file mode 100644
index 000000000000..8bc00fdbf75c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-glusterfind-log-remote-node_cmd-error.patch
@@ -0,0 +1,49 @@
+From 92a6b84a37e7e2e0ec0655ca45cedb64ab72080e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
+Date: Fri, 8 Sep 2017 02:40:01 +0200
+Subject: [PATCH] glusterfind: Log remote stderr on `node_cmd` error.
+
+The problem of lost stderr was introduced in
+commit feea851fad4f89b48bfe89fe3b75250cc7bd6501.
+
+Change-Id: Ic98f9bc9682ae3bd9c3ebea3855667fc8ba2843d
+---
+ tools/glusterfind/src/main.py | 17 ++++++++++++++++-
+ 1 file changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
+index c125f970a..6fffce4b3 100644
+--- a/tools/glusterfind/src/main.py
++++ b/tools/glusterfind/src/main.py
+@@ -75,12 +75,27 @@ def node_cmd(host, host_uuid, task, cmd, args, opts):
+             cmd = ["ssh",
+                    "-oNumberOfPasswordPrompts=0",
+                    "-oStrictHostKeyChecking=no",
++                   # We force TTY allocation (-t -t) so that Ctrl+C is handed
++                   # through; see:
++                   #   https://bugzilla.redhat.com/show_bug.cgi?id=1382236
++                   # Note that this turns stderr of the remote `cmd`
++                   # into stdout locally.
+                    "-t",
+                    "-t",
+                    "-i", pem_key_path,
+                    "root@%s" % host] + cmd
+ 
+-        execute(cmd, exit_msg="%s - %s failed" % (host, task), logger=logger)
++        (returncode, err, out) = execute(cmd, logger=logger)
++        if returncode != 0:
++            # Because the `-t -t` above turns the remote stderr into
++            # local stdout, we need to log both stderr and stdout
++            # here to print all error messages.
++            fail("%s - %s failed; stdout (including remote stderr):\n"
++                 "%s\n"
++                 "stderr:\n"
++                 "%s" % (host, task, out, err),
++                 returncode,
++                 logger=logger)
+ 
+         if opts.get("copy_outfile", False) and not localdir:
+             cmd_copy = ["scp",
+-- 
+2.12.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch
new file mode 100644
index 000000000000..4757f2fce771
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-python-remove-find_library.patch
@@ -0,0 +1,156 @@
+From e6293e367f56833457291e32a4df7b21a52365a7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
+Date: Sat, 13 May 2017 18:54:36 +0200
+Subject: [PATCH] python: Remove all uses of find_library. Fixes #1450593
+
+`find_library()` doesn't consider LD_LIBRARY_PATH on Python < 3.6.
+
+Change-Id: Iee26085cb5d14061001f19f032c2664d69a378a8
+---
+ api/examples/getvolfile.py                                     |  2 +-
+ geo-replication/syncdaemon/libcxattr.py                        |  3 +--
+ geo-replication/syncdaemon/libgfchangelog.py                   |  6 ++----
+ tests/features/ipctest.py                                      | 10 ++--------
+ tests/utils/libcxattr.py                                       |  5 ++---
+ tools/glusterfind/src/libgfchangelog.py                        |  3 +--
+ .../features/changelog/lib/examples/python/libgfchangelog.py   |  3 +--
+ 7 files changed, 10 insertions(+), 22 deletions(-)
+
+diff --git a/api/examples/getvolfile.py b/api/examples/getvolfile.py
+index 0c95213f0..32c2268b3 100755
+--- a/api/examples/getvolfile.py
++++ b/api/examples/getvolfile.py
+@@ -3,7 +3,7 @@
+ import ctypes
+ import ctypes.util
+ 
+-api = ctypes.CDLL(ctypes.util.find_library("gfapi"))
++api = ctypes.CDLL("libgfapi.so")
+ api.glfs_get_volfile.argtypes = [ctypes.c_void_p,
+                                  ctypes.c_void_p,
+                                  ctypes.c_ulong]
+diff --git a/geo-replication/syncdaemon/libcxattr.py b/geo-replication/syncdaemon/libcxattr.py
+index 3671e102c..f576648b7 100644
+--- a/geo-replication/syncdaemon/libcxattr.py
++++ b/geo-replication/syncdaemon/libcxattr.py
+@@ -10,7 +10,6 @@
+ 
+ import os
+ from ctypes import CDLL, create_string_buffer, get_errno
+-from ctypes.util import find_library
+ 
+ 
+ class Xattr(object):
+@@ -25,7 +24,7 @@ class Xattr(object):
+          sizes we expect
+     """
+ 
+-    libc = CDLL(find_library("c"), use_errno=True)
++    libc = CDLL("libc.so.6", use_errno=True)
+ 
+     @classmethod
+     def geterrno(cls):
+diff --git a/geo-replication/syncdaemon/libgfchangelog.py b/geo-replication/syncdaemon/libgfchangelog.py
+index 334f5e9ea..093ae157a 100644
+--- a/geo-replication/syncdaemon/libgfchangelog.py
++++ b/geo-replication/syncdaemon/libgfchangelog.py
+@@ -9,14 +9,12 @@
+ #
+ 
+ import os
+-from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, \
+-    get_errno, byref, c_ulong
+-from ctypes.util import find_library
++from ctypes import CDLL, RTLD_GLOBAL, create_string_buffer, get_errno, byref, c_ulong
+ from syncdutils import ChangelogException, ChangelogHistoryNotAvailable
+ 
+ 
+ class Changes(object):
+-    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL,
++    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL,
+                   use_errno=True)
+ 
+     @classmethod
+diff --git a/tests/features/ipctest.py b/tests/features/ipctest.py
+index 5aff319b8..933924861 100755
+--- a/tests/features/ipctest.py
++++ b/tests/features/ipctest.py
+@@ -1,14 +1,8 @@
+ #!/usr/bin/python
+ 
+ import ctypes
+-import ctypes.util
+-
+-# find_library does not lookup LD_LIBRARY_PATH and may miss the
+-# function. In that case, retry with less portable but explicit name.
+-libgfapi = ctypes.util.find_library("gfapi")
+-if libgfapi == None:
+-	libgfapi = "libgfapi.so"
+-api = ctypes.CDLL(libgfapi,mode=ctypes.RTLD_GLOBAL)
++
++api = ctypes.CDLL("libgfapi.so",mode=ctypes.RTLD_GLOBAL)
+ 
+ api.glfs_ipc.argtypes = [ ctypes.c_void_p, ctypes.c_int, ctypes.c_void_p, ctypes.c_void_p ]
+ api.glfs_ipc.restype = ctypes.c_int
+diff --git a/tests/utils/libcxattr.py b/tests/utils/libcxattr.py
+index 149db72e6..4e6e6c46d 100644
+--- a/tests/utils/libcxattr.py
++++ b/tests/utils/libcxattr.py
+@@ -11,7 +11,6 @@
+ import os
+ import sys
+ from ctypes import CDLL, c_int, create_string_buffer
+-from ctypes.util import find_library
+ 
+ 
+ class Xattr(object):
+@@ -28,9 +27,9 @@ class Xattr(object):
+ 
+     if sys.hexversion >= 0x02060000:
+         from ctypes import DEFAULT_MODE
+-        libc = CDLL(find_library("libc"), DEFAULT_MODE, None, True)
++        libc = CDLL("libc.so.6", DEFAULT_MODE, None, True)
+     else:
+-        libc = CDLL(find_library("libc"))
++        libc = CDLL("libc.so.6")
+ 
+     @classmethod
+     def geterrno(cls):
+diff --git a/tools/glusterfind/src/libgfchangelog.py b/tools/glusterfind/src/libgfchangelog.py
+index 0f6b40d6c..9ca3f326b 100644
+--- a/tools/glusterfind/src/libgfchangelog.py
++++ b/tools/glusterfind/src/libgfchangelog.py
+@@ -11,14 +11,13 @@
+ import os
+ from ctypes import CDLL, get_errno, create_string_buffer, c_ulong, byref
+ from ctypes import RTLD_GLOBAL
+-from ctypes.util import find_library
+ 
+ 
+ class ChangelogException(OSError):
+     pass
+ 
+ 
+-libgfc = CDLL(find_library("gfchangelog"), use_errno=True, mode=RTLD_GLOBAL)
++libgfc = CDLL("libgfchangelog.so", use_errno=True, mode=RTLD_GLOBAL)
+ 
+ 
+ def raise_oserr():
+diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
+index 10e73c02b..2cdbf1152 100644
+--- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py
++++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py
+@@ -1,9 +1,8 @@
+ import os
+ from ctypes import *
+-from ctypes.util import find_library
+ 
+ class Changes(object):
+-    libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True)
++    libgfc = CDLL("libgfchangelog.so", mode=RTLD_GLOBAL, use_errno=True)
+ 
+     @classmethod
+     def geterrno(cls):
+-- 
+2.12.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-use-PATH-instead-of-hardcodes.patch b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-use-PATH-instead-of-hardcodes.patch
new file mode 100644
index 000000000000..acb15464e48f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/glusterfs/glusterfs-use-PATH-instead-of-hardcodes.patch
@@ -0,0 +1,138 @@
+From 616381bc25b0e90198683fb049f994e82d467d96 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= <mail@nh2.me>
+Date: Sat, 13 May 2017 02:45:49 +0200
+Subject: [PATCH] Don't use hardcoded /sbin, /usr/bin etc. paths. Fixes
+ #1450546.
+
+Instead, rely on programs to be in PATH, as gluster already
+does in many places across its code base.
+
+Change-Id: Id21152fe42f5b67205d8f1571b0656c4d5f74246
+---
+ contrib/fuse-lib/mount-common.c               |  8 ++++----
+ xlators/mgmt/glusterd/src/glusterd-ganesha.c  |  6 +++---
+ xlators/mgmt/glusterd/src/glusterd-quota.c    |  6 +++---
+ xlators/mgmt/glusterd/src/glusterd-snapshot.c |  4 ++--
+ xlators/mgmt/glusterd/src/glusterd-utils.c    | 14 +-------------
+ 5 files changed, 13 insertions(+), 25 deletions(-)
+
+diff --git a/contrib/fuse-lib/mount-common.c b/contrib/fuse-lib/mount-common.c
+index e9f80fe81..6380dd867 100644
+--- a/contrib/fuse-lib/mount-common.c
++++ b/contrib/fuse-lib/mount-common.c
+@@ -255,16 +255,16 @@ fuse_mnt_umount (const char *progname, const char *abs_mnt,
+                         exit (1);
+                 }
+ #ifdef GF_LINUX_HOST_OS
+-                execl ("/bin/umount", "/bin/umount", "-i", rel_mnt,
++                execl ("umount", "umount", "-i", rel_mnt,
+                        lazy ? "-l" : NULL, NULL);
+-                GFFUSE_LOGERR ("%s: failed to execute /bin/umount: %s",
++                GFFUSE_LOGERR ("%s: failed to execute umount: %s",
+                                progname, strerror (errno));
+ #elif __NetBSD__
+                 /* exitting the filesystem causes the umount */
+                 exit (0);
+ #else
+-                execl ("/sbin/umount", "/sbin/umount", "-f", rel_mnt, NULL);
+-                GFFUSE_LOGERR ("%s: failed to execute /sbin/umount: %s",
++                execl ("umount", "umount", "-f", rel_mnt, NULL);
++                GFFUSE_LOGERR ("%s: failed to execute umount: %s",
+                                progname, strerror (errno));
+ #endif /* GF_LINUX_HOST_OS */
+                 exit (1);
+diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
+index 0e6629cf0..fcb4738b7 100644
+--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
++++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
+@@ -30,7 +30,7 @@
+ 
+ #ifndef _PATH_SETFATTR
+ # ifdef GF_LINUX_HOST_OS
+-#  define _PATH_SETFATTR "/usr/bin/setfattr"
++#  define _PATH_SETFATTR "setfattr"
+ # endif
+ # ifdef __NetBSD__
+ #  define _PATH_SETFATTR "/usr/pkg/bin/setfattr"
+@@ -335,7 +335,7 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv,
+ 
+                 if (type == GF_QUOTA_OPTION_TYPE_ENABLE ||
+                     type == GF_QUOTA_OPTION_TYPE_ENABLE_OBJECTS)
+-                        runner_add_args (&runner, "/usr/bin/find", ".", NULL);
++                        runner_add_args (&runner, "find", ".", NULL);
+ 
+                 else if (type == GF_QUOTA_OPTION_TYPE_DISABLE) {
+ 
+@@ -351,7 +351,7 @@ _glusterd_quota_initiate_fs_crawl (glusterd_conf_t *priv,
+                                          VIRTUAL_QUOTA_XATTR_CLEANUP_KEY, "1",
+                                          "{}", "\\", ";", NULL);
+ #else
+-                        runner_add_args (&runner, "/usr/bin/find", ".",
++                        runner_add_args (&runner, "find", ".",
+                                          "-exec", _PATH_SETFATTR, "-n",
+                                          VIRTUAL_QUOTA_XATTR_CLEANUP_KEY, "-v",
+                                          "1", "{}", "\\", ";", NULL);
+diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot.c b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+index da0152366..f0d135350 100644
+--- a/xlators/mgmt/glusterd/src/glusterd-snapshot.c
++++ b/xlators/mgmt/glusterd/src/glusterd-snapshot.c
+@@ -121,7 +121,7 @@ glusterd_build_snap_device_path (char *device, char *snapname,
+         }
+ 
+         runinit (&runner);
+-        runner_add_args (&runner, "/sbin/lvs", "--noheadings", "-o", "vg_name",
++        runner_add_args (&runner, "lvs", "--noheadings", "-o", "vg_name",
+                          device, NULL);
+         runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
+         snprintf (msg, sizeof (msg), "Get volume group for device %s", device);
+@@ -1982,7 +1982,7 @@ glusterd_is_thinp_brick (char *device, uint32_t *op_errno)
+ 
+         runinit (&runner);
+ 
+-        runner_add_args (&runner, "/sbin/lvs", "--noheadings", "-o", "pool_lv",
++        runner_add_args (&runner, "lvs", "--noheadings", "-o", "pool_lv",
+                          device, NULL);
+         runner_redir (&runner, STDOUT_FILENO, RUN_PIPE);
+         runner_log (&runner, this->name, GF_LOG_DEBUG, msg);
+diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
+index 51db13df0..6fa7b92f9 100644
+--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
++++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
+@@ -6027,7 +6027,6 @@ static struct fs_info {
+         char *fs_tool_pattern;
+         char *fs_tool_pkg;
+ } glusterd_fs[] = {
+-        /* some linux have these in /usr/sbin/and others in /sbin/? */
+         { "xfs", "xfs_info", NULL, "isize=", "xfsprogs" },
+         { "ext3", "tune2fs", "-l", "Inode size:", "e2fsprogs" },
+         { "ext4", "tune2fs", "-l", "Inode size:", "e2fsprogs" },
+@@ -6048,7 +6047,6 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count)
+         char           *trail             = NULL;
+         runner_t        runner            = {0, };
+         struct fs_info *fs                = NULL;
+-        char            fs_tool_name[256] = {0, };
+         static dict_t  *cached_fs         = NULL;
+ 
+         memset (key, 0, sizeof (key));
+@@ -6085,17 +6083,7 @@ glusterd_add_inode_size_to_dict (dict_t *dict, int count)
+                                 cur_word = "N/A";
+                                 goto cached;
+                         }
+-
+-                        snprintf (fs_tool_name, sizeof (fs_tool_name),
+-                                  "/usr/sbin/%s", fs->fs_tool_name);
+-                        if (sys_access (fs_tool_name, R_OK|X_OK) == 0)
+-                                runner_add_arg (&runner, fs_tool_name);
+-                        else {
+-                                snprintf (fs_tool_name, sizeof (fs_tool_name),
+-                                          "/sbin/%s", fs->fs_tool_name);
+-                                if (sys_access (fs_tool_name, R_OK|X_OK) == 0)
+-                                        runner_add_arg (&runner, fs_tool_name);
+-                        }
++                        runner_add_arg (&runner, fs->fs_tool_name);
+                         break;
+                 }
+         }
+-- 
+2.12.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/go-mtpfs/default.nix b/nixpkgs/pkgs/tools/filesystems/go-mtpfs/default.nix
new file mode 100644
index 000000000000..0438b9c38e4b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/go-mtpfs/default.nix
@@ -0,0 +1,20 @@
+{ stdenv, pkgconfig, libusb1, buildGoPackage, fetchgit }:
+
+buildGoPackage rec {
+  name = "go-mtpfs-${version}";
+  version = "20150917-${stdenv.lib.strings.substring 0 7 rev}";
+  rev = "bc7c0f716e3b4ed5610069a55fc00828ebba890b";
+
+  goPackagePath = "github.com/hanwen/go-mtpfs";
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ libusb1 ];
+
+  src = fetchgit {
+    inherit rev;
+    url = "https://github.com/hanwen/go-mtpfs";
+    sha256 = "1jcqp9n8fd9psfsnhfj6w97yp0zmyxplsig8pyp2gqzh4lnb5fqm";
+  };
+
+  goDeps = ./deps.nix;
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/go-mtpfs/deps.nix b/nixpkgs/pkgs/tools/filesystems/go-mtpfs/deps.nix
new file mode 100644
index 000000000000..4bba3f237392
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/go-mtpfs/deps.nix
@@ -0,0 +1,20 @@
+[
+  {
+    goPackagePath = "github.com/hanwen/go-fuse";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hanwen/go-fuse";
+      rev = "bd746dd8bcc8c059a9d953a786a6156eb83f398e";
+      sha256 = "1dvvclp418j3d02v9717sfqhl6fw6yyddr9r3j8gsiv8nb62ib56";
+    };
+  }
+  {
+    goPackagePath = "github.com/hanwen/usb";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hanwen/usb";
+      rev = "69aee4530ac705cec7c5344418d982aaf15cf0b1";
+      sha256 = "01k0c2g395j65vm1w37mmrfkg6nm900khjrrizzpmx8f8yf20dky";
+    };
+  }
+]
diff --git a/nixpkgs/pkgs/tools/filesystems/gocryptfs/default.nix b/nixpkgs/pkgs/tools/filesystems/gocryptfs/default.nix
new file mode 100644
index 000000000000..75f5e9ffe11f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/gocryptfs/default.nix
@@ -0,0 +1,50 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+{ stdenv, buildGoPackage, fetchFromGitHub, openssl, pandoc, pkgconfig }:
+
+let
+  version = "v1.5";
+  goFuseVersion = with stdenv.lib; substring 0 7 (head (filter (
+    d: d.goPackagePath == "github.com/hanwen/go-fuse"
+  ) (import ./deps.nix))).fetch.rev;
+in
+buildGoPackage rec {
+  name = "gocryptfs-${version}";
+
+  goPackagePath = "github.com/rfjakob/gocryptfs";
+
+  nativeBuildInputs = [ pandoc pkgconfig ];
+  buildInputs = [ openssl ];
+
+  src = fetchFromGitHub {
+    owner = "rfjakob";
+    repo = "gocryptfs";
+    rev = version;
+    sha256 = "0s5smjc7n9088n8a2mv7cy3cx31ci13i1i8fhg1vslc17a15qs2d";
+  };
+
+  postPatch = "rm -r tests";
+
+  buildFlagsArray = ''
+    -ldflags=
+      -X main.GitVersion=${version}
+      -X main.GitVersionFuse=${goFuseVersion}
+  '';
+
+  goDeps = ./deps.nix;
+
+  postBuild = ''
+    pushd go/src/github.com/rfjakob/gocryptfs/Documentation/
+    mkdir -p $out/share/man/man1
+    pandoc MANPAGE.md -s -t man -o $out/share/man/man1/gocryptfs.1
+    pandoc MANPAGE-XRAY.md -s -t man -o $out/share/man/man1/gocryptfs-xray.1
+    popd
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Encrypted overlay filesystem written in Go";
+    license = licenses.mit;
+    homepage = https://nuetzlich.net/gocryptfs/;
+    maintainers = with maintainers; [ flokli offline ];
+    platforms = platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/gocryptfs/deps.nix b/nixpkgs/pkgs/tools/filesystems/gocryptfs/deps.nix
new file mode 100644
index 000000000000..cb5aec527f24
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/gocryptfs/deps.nix
@@ -0,0 +1,66 @@
+# This file was generated by https://github.com/kamilchm/go2nix v1.2.1
+[
+  {
+    goPackagePath = "github.com/hanwen/go-fuse";
+    fetch = {
+      type = "git";
+      url = "https://github.com/hanwen/go-fuse";
+      rev = "291273cb8ce0f139636a6fd7414be3c7e2de6288";
+      sha256 = "1djfl6mni8k4wllhwcr6qwyg1nh6wykdalvdl6gpc1rwrjj9c6xi";
+    };
+  }
+  {
+    goPackagePath = "github.com/jacobsa/crypto";
+    fetch = {
+      type = "git";
+      url = "https://github.com/jacobsa/crypto";
+      rev = "c73681c634de898c869684602cf0c0d2ce938c4d";
+      sha256 = "02jbiy6szshbzcmp4j3gpc577hrhikxqvm4kzxixp27k9f2cx5si";
+    };
+  }
+  {
+    goPackagePath = "github.com/pkg/xattr";
+    fetch = {
+      type = "git";
+      url = "https://github.com/pkg/xattr";
+      rev = "d15dbc2bb0b5da267362b5e066e2c44c1fcff6c7";
+      sha256 = "1vab8mpk2x4vbhx0kd0i0kn6sf7z5ivilcmdklyizzcfcwghh17g";
+    };
+  }
+  {
+    goPackagePath = "github.com/rfjakob/eme";
+    fetch = {
+      type = "git";
+      url = "https://github.com/rfjakob/eme";
+      rev = "2222dbd4ba467ab3fc7e8af41562fcfe69c0d770";
+      sha256 = "0c227ly3z8pqaqg22lpd8nzgqrfsbjx5gi9rp9ks1cmd11dv2gl9";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/crypto";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/crypto";
+      rev = "a49355c7e3f8fe157a85be2f77e6e269a0f89602";
+      sha256 = "020q1laxjx5kcmnqy4wmdb63zhb0lyq6wpy40axhswzg2nd21s44";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sync";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sync";
+      rev = "1d60e4601c6fd243af51cc01ddf169918a5407ca";
+      sha256 = "046jlanz2lkxq1r57x9bl6s4cvfqaic6p2xybsj8mq1120jv4rs6";
+    };
+  }
+  {
+    goPackagePath = "golang.org/x/sys";
+    fetch = {
+      type = "git";
+      url = "https://go.googlesource.com/sys";
+      rev = "151529c776cdc58ddbe7963ba9af779f3577b419";
+      sha256 = "149yfzs4k8vxhjr8f832drndir2k5ha0ggs2dw2fd6xvxf698bcx";
+    };
+  }
+]
diff --git a/nixpkgs/pkgs/tools/filesystems/gpart/default.nix b/nixpkgs/pkgs/tools/filesystems/gpart/default.nix
new file mode 100644
index 000000000000..ca2d0a627ab8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/gpart/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "gpart-${version}";
+  version = "0.3";
+
+  # GitHub repository 'collating patches for gpart from all distributions':
+  src = fetchFromGitHub {
+    sha256 = "1lsd9k876p944k9s6sxqk5yh9yr7m42nbw9vlsllin7pd4djl4ya";
+    rev = version;
+    repo = "gpart";
+    owner = "baruch";
+  };
+
+  nativeBuildInputs = [ autoreconfHook ];
+
+  enableParallelBuilding = true;
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Guess PC-type hard disk partitions";
+    longDescription = ''
+      Gpart is a tool which tries to guess the primary partition table of a
+      PC-type hard disk in case the primary partition table in sector 0 is
+      damaged, incorrect or deleted. The guessed table can be written to a file
+      or device.
+    '';
+    license = licenses.gpl2Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/grive2/default.nix b/nixpkgs/pkgs/tools/filesystems/grive2/default.nix
new file mode 100644
index 000000000000..4f7c2248a8ed
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/grive2/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, pkgconfig, yajl, cmake, libgcrypt, curl, expat, boost, libiberty }:
+
+stdenv.mkDerivation rec {
+  version = "0.5.0";
+  name = "grive2-${version}";
+
+  src = fetchFromGitHub {
+    owner = "vitalif";
+    repo = "grive2";
+    rev =  "v${version}";
+    sha256 = "0gyic9228j25l5x8qj9xxxp2cgbw6y4skxqx0xrq6qilhv4lj23c";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig ];
+
+  buildInputs = [ libgcrypt yajl curl expat stdenv boost libiberty ];
+
+  meta = with stdenv.lib; {
+    description = "A console Google Drive client";
+    homepage = https://github.com/vitalif/grive2;
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/hfsprogs/default.nix b/nixpkgs/pkgs/tools/filesystems/hfsprogs/default.nix
new file mode 100644
index 000000000000..25ec31ea698a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/hfsprogs/default.nix
@@ -0,0 +1,45 @@
+{ stdenv, fetchurl, openssl, libbsd }:
+
+let version = "332.25";
+    package_name = "hfsprogs"; in
+stdenv.mkDerivation rec {
+  name = "${package_name}-${version}";
+  srcs = [
+    (fetchurl {
+      url = "http://ftp.de.debian.org/debian/pool/main/h/hfsprogs/${package_name}_${version}-11.debian.tar.gz";
+      sha256 = "62d9b8599c66ebffbc57ce5d776e20b41341130d9b27341d63bda08460ebde7c";
+    })
+    (fetchurl {
+      url = "https://opensource.apple.com/tarballs/diskdev_cmds/diskdev_cmds-${version}.tar.gz";
+      sha256 = "74c9aeca899ed7f4bf155c65fc45bf0f250c0f6d57360ea953b1d536d9aa45e6";
+    })
+  ];
+
+  sourceRoot = "diskdev_cmds-" + version;
+  patches = [ "../debian/patches/*.patch" ];
+
+  buildInputs = [ openssl libbsd ];
+  makefile = "Makefile.lnx";
+
+  # Inspired by PKGBUILD of https://www.archlinux.org/packages/community/x86_64/hfsprogs/
+  installPhase = ''
+    # Create required package directories
+    install -m 755 -d "$out/bin"
+    install -m 755 -d "$out/share/${package_name}"
+    install -m 755 -d "$out/share/man/man8/"
+    # Copy executables
+    install -m 755 "newfs_hfs.tproj/newfs_hfs" "$out/bin/mkfs.hfsplus"
+    install -m 755 "fsck_hfs.tproj/fsck_hfs" "$out/bin/fsck.hfsplus"
+    # Copy shared data
+    install -m 644 "newfs_hfs.tproj/hfsbootdata.img" "$out/share/${package_name}/hfsbootdata"
+    # Copy man pages
+    install -m 644 "newfs_hfs.tproj/newfs_hfs.8" "$out/share/man/man8/mkfs.hfsplus.8"
+    install -m 644 "fsck_hfs.tproj/fsck_hfs.8" "$out/share/man/man8/fsck.hfsplus.8"
+  '';
+
+  meta = {
+    description = "HFS/HFS+ user space utils";
+    license = stdenv.lib.licenses.apsl20;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/httpfs/default.nix b/nixpkgs/pkgs/tools/filesystems/httpfs/default.nix
new file mode 100644
index 000000000000..b0f7981ebb3c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/httpfs/default.nix
@@ -0,0 +1,35 @@
+{ fetchurl, stdenv, pkgconfig, fuse, openssl, asciidoc
+, docbook_xml_dtd_45, docbook_xsl , libxml2, libxslt }:
+
+stdenv.mkDerivation rec {
+  name = "httpfs2-0.1.5";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/httpfs/httpfs2/${name}.tar.gz";
+    sha256 = "1h8ggvhw30n2r6w11n1s458ypggdqx6ldwd61ma4yd7binrlpjq1";
+  };
+
+  buildInputs =
+    [ pkgconfig fuse openssl
+      asciidoc docbook_xml_dtd_45 docbook_xsl libxml2 libxslt
+    ];
+
+  installPhase =
+    '' mkdir -p "$out/bin"
+       cp -v httpfs2 "$out/bin"
+
+       mkdir -p "$out/share/man/man1"
+       cp -v *.1 "$out/share/man/man1"
+    '';
+
+  meta = {
+    description = "HTTPFS2, a FUSE-based HTTP file system for Linux";
+
+    homepage = http://httpfs.sourceforge.net/;
+
+    license = stdenv.lib.licenses.gpl2Plus;
+
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/hubicfuse/default.nix b/nixpkgs/pkgs/tools/filesystems/hubicfuse/default.nix
new file mode 100644
index 000000000000..4594aa9370ca
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/hubicfuse/default.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchFromGitHub, pkgconfig, curl, openssl, fuse, libxml2, json_c, file }:
+
+stdenv.mkDerivation rec {
+  name = "hubicfuse-${version}";
+  version = "3.0.1";
+
+  src = fetchFromGitHub {
+    owner = "TurboGit";
+    repo = "hubicfuse";
+    rev = "v${version}";
+    sha256 = "1x988hfffxgvqxh083pv3lj5031fz03sbgiiwrjpaiywfbhm8ffr";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ curl openssl fuse libxml2 json_c file ];
+  postInstall = ''
+    install hubic_token $out/bin
+    mkdir -p $out/sbin
+    ln -sf $out/bin/hubicfuse $out/sbin/mount.hubicfuse
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/TurboGit/hubicfuse;
+    description = "FUSE-based filesystem to access hubic cloud storage";
+    platforms = platforms.linux;
+    license = licenses.mit;
+    maintainers = [ maintainers.jpierre03 ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/idsk/default.nix b/nixpkgs/pkgs/tools/filesystems/idsk/default.nix
new file mode 100644
index 000000000000..617457f55b61
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/idsk/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, cmake }:
+
+stdenv.mkDerivation rec {
+
+  repo = "idsk";
+  version = "unstable-2018-02-11";
+  rev = "1846729ac3432aa8c2c0525be45cfff8a513e007";
+  name = "${repo}-${version}";
+
+  meta = with stdenv.lib; {
+    description = "Manipulating CPC dsk images and files";
+    homepage = https://github.com/cpcsdk/idsk ;
+    license = "unknown";
+    maintainers = [ maintainers.genesis ];
+    platforms = platforms.linux;
+  };
+
+  src = fetchFromGitHub {
+    inherit rev repo;
+    owner = "cpcsdk";
+    sha256 = "0d891lvf2nc8bys8kyf69k54rf3jlwqrcczbff8xi0w4wsiy5ckv";
+  };
+
+  nativeBuildInputs = [ cmake ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp iDSK $out/bin
+  '';
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/ifuse/default.nix b/nixpkgs/pkgs/tools/filesystems/ifuse/default.nix
new file mode 100644
index 000000000000..f9021c5a3aa7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ifuse/default.nix
@@ -0,0 +1,31 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, usbmuxd, fuse, libimobiledevice }:
+
+stdenv.mkDerivation rec {
+  pname = "ifuse";
+  version = "1.1.3";
+
+  name = "${pname}-${version}";
+
+  src = fetchFromGitHub {
+    owner = "libimobiledevice";
+    repo = pname;
+    rev = version;
+    sha256 = "0p01rds3vc5864v48swgqw5dv0h937nqnxggryixg9pkvzhc6cx5";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig fuse usbmuxd libimobiledevice ];
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/libimobiledevice/ifuse;
+    description = "A fuse filesystem implementation to access the contents of iOS devices";
+    longDescription = ''
+      Mount directories of an iOS device locally using fuse. By default the media
+      directory is mounted, options allow to also mount the sandbox container of an
+      app, an app's documents folder or even the root filesystem on jailbroken
+      devices.
+    '';
+    license = licenses.lgpl21Plus;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/irods/common.nix b/nixpkgs/pkgs/tools/filesystems/irods/common.nix
new file mode 100644
index 000000000000..902d7d7d1a1e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/irods/common.nix
@@ -0,0 +1,55 @@
+{ stdenv, bzip2, zlib, autoconf, automake, cmake, gnumake, help2man , texinfo, libtool , cppzmq , libarchive, avro-cpp, boost, jansson, zeromq, openssl, pam, libiodbc, kerberos, gcc, libcxx, which }:
+
+# Common attributes of irods packages
+
+with stdenv;
+
+{
+  enableParallelBuilding = true;
+
+  buildInputs = [ bzip2 zlib autoconf automake cmake gnumake help2man texinfo libtool cppzmq libarchive avro-cpp jansson zeromq openssl pam libiodbc kerberos gcc boost libcxx which ];
+
+  cmakeFlags = [
+    "-DIRODS_EXTERNALS_FULLPATH_CLANG=${stdenv.cc}"
+    "-DIRODS_EXTERNALS_FULLPATH_CLANG_RUNTIME=${stdenv.cc}"
+    "-DIRODS_EXTERNALS_FULLPATH_ARCHIVE=${libarchive.lib}"
+    "-DIRODS_EXTERNALS_FULLPATH_AVRO=${avro-cpp}"
+    "-DIRODS_EXTERNALS_FULLPATH_BOOST=${boost}"
+    "-DIRODS_EXTERNALS_FULLPATH_JANSSON=${jansson}"
+    "-DIRODS_EXTERNALS_FULLPATH_ZMQ=${zeromq}"
+    "-DIRODS_EXTERNALS_FULLPATH_CPPZMQ=${cppzmq}"
+    "-DIRODS_LINUX_DISTRIBUTION_NAME=nix"
+    "-DIRODS_LINUX_DISTRIBUTION_VERSION_MAJOR=${builtins.nixVersion}"
+    "-DCPACK_GENERATOR=TGZ"
+    "-DCMAKE_CXX_FLAGS=-I${libcxx}/include/c++/v1"
+  ];
+
+  preConfigure = ''
+    patchShebangs ./packaging
+    patchShebangs ./scripts
+    substituteInPlace CMakeLists.txt --replace "DESTINATION usr/bin" "DESTINATION bin"
+    substituteInPlace CMakeLists.txt --replace "INCLUDE_DIRS usr/include/" "INCLUDE_DIRS include/"
+    substituteInPlace CMakeLists.txt --replace "DESTINATION usr/lib/" "DESTINATION lib/"
+    export cmakeFlags="$cmakeFlags
+      -DCMAKE_INSTALL_PREFIX=$out
+    "
+  '';
+
+  meta = {
+    description = "Integrated Rule-Oriented Data System (iRODS)";
+    longDescription = ''
+      The Integrated Rule-Oriented Data System (iRODS) is open source data management
+      software used by research organizations and government agencies worldwide.
+      iRODS is released as a production-level distribution aimed at deployment in mission
+      critical environments.  It virtualizes data storage resources, so users can take
+      control of their data, regardless of where and on what device the data is stored.
+      As data volumes grow and data services become more complex, iRODS is increasingly
+      important in data management. The development infrastructure supports exhaustive
+      testing on supported platforms; plug-in support for microservices, storage resources,
+      drivers, and databases; and extensive documentation, training and support services.'';
+    homepage = https://irods.org;
+    license = stdenv.lib.licenses.bsd3;
+    maintainers = [ stdenv.lib.maintainers.bzizou ];
+    platforms = stdenv.lib.platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/irods/default.nix b/nixpkgs/pkgs/tools/filesystems/irods/default.nix
new file mode 100644
index 000000000000..24a88349bf43
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/irods/default.nix
@@ -0,0 +1,87 @@
+{ stdenv, fetchurl, bzip2, zlib, autoconf, automake, cmake, gnumake, help2man , texinfo, libtool , cppzmq , libarchive, avro-cpp_llvm, boost, jansson, zeromq, openssl , pam, libiodbc, kerberos, gcc, libcxx, which }:
+
+with stdenv;
+
+let
+  avro-cpp=avro-cpp_llvm;
+in
+let
+  common = import ./common.nix {
+    inherit stdenv bzip2 zlib autoconf automake cmake gnumake
+            help2man texinfo libtool cppzmq libarchive jansson
+            zeromq openssl pam libiodbc kerberos gcc libcxx
+            boost avro-cpp which;
+  };
+in rec {
+
+  # irods: libs and server package
+  irods = stdenv.mkDerivation (common // rec {
+    version = "4.2.2";
+    prefix = "irods";
+    name = "${prefix}-${version}";
+
+    src = fetchurl {
+      url = "https://github.com/irods/irods/releases/download/${version}/irods-${version}.tar.gz";
+      sha256 = "0b89hs7sizwrs2ja7jl521byiwb58g297p0p7zg5frxmv4ig8dw7";
+    };
+
+    # Patches:
+    # irods_root_path.patch : the root path is obtained by stripping 3 items of the path,
+    #                         but we don't use /usr with nix, so remove only 2 items.
+    patches = [ ./irods_root_path.patch ];
+
+    preConfigure = common.preConfigure + ''
+      patchShebangs ./test
+      substituteInPlace plugins/database/CMakeLists.txt --replace "COMMAND cpp" "COMMAND ${gcc.cc}/bin/cpp"
+      substituteInPlace cmake/server.cmake --replace "DESTINATION usr/sbin" "DESTINATION sbin"
+      substituteInPlace cmake/server.cmake --replace "IRODS_DOC_DIR usr/share" "IRODS_DOC_DIR share"
+      substituteInPlace cmake/runtime_library.cmake --replace "DESTINATION usr/lib" "DESTINATION lib"
+      substituteInPlace cmake/development_library.cmake --replace "DESTINATION usr/lib" "DESTINATION lib"
+      substituteInPlace cmake/development_library.cmake --replace "DESTINATION usr/include" "DESTINATION include"
+      export cmakeFlags="$cmakeFlags
+        -DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,$out/lib
+        -DCMAKE_MODULE_LINKER_FLAGS=-Wl,-rpath,$out/lib
+        -DCMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath,$out/lib
+        "
+
+      substituteInPlace cmake/server.cmake --replace SETUID ""
+    '';
+
+    meta = common.meta // {
+      longDescription = common.meta.longDescription + ''
+        This package provides the servers and libraries.'';
+    };
+  });
+
+
+  # icommands (CLI) package, depends on the irods package
+  irods-icommands = stdenv.mkDerivation (common // rec {
+     version = "4.2.2";
+     name = "irods-icommands-${version}";
+     src = fetchurl {
+       url = "http://github.com/irods/irods_client_icommands/archive/${version}.tar.gz";
+       sha256 = "15zcxrx0q5c3rli3snd0b2q4i0hs3zzcrbpnibbhsip855qvs77h";
+     };
+
+     buildInputs = common.buildInputs ++ [ irods ];
+
+     preConfigure = common.preConfigure + ''
+       patchShebangs ./bin
+     '';
+
+     cmakeFlags = common.cmakeFlags ++ [
+       "-DCMAKE_INSTALL_PREFIX=${out}"
+       "-DIRODS_DIR=${irods}/lib/irods/cmake"
+       "-DCMAKE_EXE_LINKER_FLAGS=-Wl,-rpath,${irods}/lib"
+       "-DCMAKE_MODULE_LINKER_FLAGS=-Wl,-rpath,${irods}/lib"
+       "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath,${irods}/lib"
+    ];
+
+     meta = common.meta // {
+       description = common.meta.description + " CLI clients";
+       longDescription = common.meta.longDescription + ''
+         This package provides the CLI clients, called 'icommands'.'';
+     };
+  });
+}
+
diff --git a/nixpkgs/pkgs/tools/filesystems/irods/irods_root_path.patch b/nixpkgs/pkgs/tools/filesystems/irods/irods_root_path.patch
new file mode 100644
index 000000000000..16b6ba08cbb2
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/irods/irods_root_path.patch
@@ -0,0 +1,71 @@
+diff -r -u irods-4.2.0.orig/lib/core/src/irods_default_paths.cpp irods-4.2.0/lib/core/src/irods_default_paths.cpp
+--- irods-4.2.0.orig/lib/core/src/irods_default_paths.cpp	2016-11-15 06:23:55.000000000 +0000
++++ irods-4.2.0/lib/core/src/irods_default_paths.cpp	2016-12-20 18:03:17.156883399 +0000
+@@ -18,7 +18,7 @@
+         try {
+             boost::filesystem::path path{dl_info.dli_fname};
+             path = boost::filesystem::canonical(path);
+-            path.remove_filename().remove_filename().remove_filename(); // Removes filename and the two directories (usr and lib) between libirods_common.so and base of irods install
++            path.remove_filename().remove_filename(); // Removes filename and the two directories (usr and lib) between libirods_common.so and base of irods install
+             return path;
+         } catch(const boost::filesystem::filesystem_error& e) {
+             THROW(-1, e.what());
+@@ -27,8 +27,7 @@
+ 
+     boost::filesystem::path
+     get_irods_config_directory() {
+-        boost::filesystem::path path{get_irods_root_directory()};
+-        path.append("etc").append("irods");
++        boost::filesystem::path path("/etc/irods");
+         return path;
+     }
+ 
+diff -r -u irods-4.2.0.orig/scripts/irods/paths.py irods-4.2.0/scripts/irods/paths.py
+--- irods-4.2.0.orig/scripts/irods/paths.py	2016-11-15 06:23:55.000000000 +0000
++++ irods-4.2.0/scripts/irods/paths.py	2016-12-21 15:17:07.437864606 +0000
+@@ -10,7 +10,7 @@
+     return os.path.join(root_directory(), 'var', 'lib', 'irods')
+ 
+ def config_directory():
+-    return os.path.join(root_directory(), 'etc', 'irods')
++    return os.path.join(os.path.abspath('/'), 'etc', 'irods')
+ 
+ def plugins_directory():
+     return os.path.join(root_directory(), 'usr', 'lib', 'irods', 'plugins')
+@@ -37,7 +37,7 @@
+ 
+ def version_path():
+     return os.path.join(
+-        irods_directory(),
++        home_directory(),
+         'VERSION.json')
+ 
+ def hosts_config_path():
+@@ -64,7 +64,7 @@
+ 
+ def log_directory():
+     return os.path.join(
+-        irods_directory(),
++        home_directory(),
+         'log')
+ 
+ def control_log_path():
+@@ -110,8 +110,7 @@
+ def server_bin_directory():
+     return os.path.join(
+         root_directory(),
+-        'usr',
+-        'sbin')
++        'bin')
+ 
+ def server_executable():
+     return os.path.join(
+@@ -132,7 +131,7 @@
+     return os.path.join(config_directory(), 'service_account.config')
+ 
+ def genosauth_path():
+-    return os.path.join(irods_directory(), 'clients', 'bin', 'genOSAuth')
++    return os.path.join(home_directory(), 'clients', 'bin', 'genOSAuth')
+ 
+ def irods_user_and_group_entries():
+     try:
diff --git a/nixpkgs/pkgs/tools/filesystems/jfsutils/ar-fix.patch b/nixpkgs/pkgs/tools/filesystems/jfsutils/ar-fix.patch
new file mode 100644
index 000000000000..697029cd5a8c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/jfsutils/ar-fix.patch
@@ -0,0 +1,10 @@
+--- jfsutils-1.1.15/configure.in.orig	2018-11-27 20:46:55.830242385 +0300
++++ jfsutils-1.1.15/configure.in	2018-11-27 20:47:00.596307630 +0300
+@@ -15,6 +15,7 @@
+ AC_PATH_PROG(LN, ln, ln)
+ AC_PROG_LN_S
+ AC_PROG_RANLIB
++AM_PROG_AR
+ 
+ dnl Checks for header files.
+ AC_HEADER_STDC
diff --git a/nixpkgs/pkgs/tools/filesystems/jfsutils/default.nix b/nixpkgs/pkgs/tools/filesystems/jfsutils/default.nix
new file mode 100644
index 000000000000..92dfe00c9514
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/jfsutils/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, libuuid, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "jfsutils-1.1.15";
+
+  src = fetchurl {
+    url = "http://jfs.sourceforge.net/project/pub/${name}.tar.gz";
+    sha256 = "0kbsy2sk1jv4m82rxyl25gwrlkzvl3hzdga9gshkxkhm83v1aji4";
+  };
+
+  patches = [
+    ./types.patch
+    ./hardening-format.patch
+    # required for cross-compilation
+    ./ar-fix.patch
+  ];
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ libuuid ];
+
+  meta = with stdenv.lib; {
+    description = "IBM JFS utilities";
+    homepage = http://jfs.sourceforge.net;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/jfsutils/hardening-format.patch b/nixpkgs/pkgs/tools/filesystems/jfsutils/hardening-format.patch
new file mode 100644
index 000000000000..dd2a93a81ec6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/jfsutils/hardening-format.patch
@@ -0,0 +1,37 @@
+--- a/fscklog/fscklog.c	2016-01-29 04:59:54.102223291 +0000
++++ b/fscklog/fscklog.c	2016-01-29 05:00:10.707552565 +0000
+@@ -252,8 +252,8 @@
+ 
+ 	sprintf(debug_detail, " [%s:%d]\n", basename(file_name), line_number);
+ 
+-	printf(msg_string);
+-	printf(debug_detail);
++	printf("%s", msg_string);
++	printf("%s", debug_detail);
+ 
+ 	return 0;
+ }
+--- a/fscklog/display.c	2016-01-29 05:05:42.582133444 +0000
++++ b/fscklog/display.c	2016-01-29 05:05:47.541231780 +0000
+@@ -182,7 +182,7 @@
+ 				} else {
+ 					/* the record looks ok */
+ 					msg_txt = &log_entry[log_entry_pos];
+-					printf(msg_txt);
++					printf("%s", msg_txt);
+ 					/*
+ 					 * set up for the next record
+ 					 */
+--- a/logdump/helpers.c	2016-01-29 05:06:26.081996021 +0000
++++ b/logdump/helpers.c	2016-01-29 05:06:43.097333425 +0000
+@@ -95,8 +95,8 @@
+ 
+ 	sprintf(debug_detail, " [%s:%d]\n", file_name, line_number);
+ 
+-	printf(msg_string);
+-	printf(debug_detail);
++	printf("%s", msg_string);
++	printf("%s", debug_detail);
+ 
+ 	return 0;
+ }
diff --git a/nixpkgs/pkgs/tools/filesystems/jfsutils/types.patch b/nixpkgs/pkgs/tools/filesystems/jfsutils/types.patch
new file mode 100644
index 000000000000..a682f2695f9e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/jfsutils/types.patch
@@ -0,0 +1,12 @@
+diff -ru -x '*~' jfsutils-1.1.15-orig/libfs/devices.h jfsutils-1.1.15/libfs/devices.h
+--- jfsutils-1.1.15-orig/libfs/devices.h	2005-11-22 21:43:55.000000000 +0100
++++ jfsutils-1.1.15/libfs/devices.h	2013-01-28 13:58:56.888630278 +0100
+@@ -18,6 +18,8 @@
+ #ifndef H_DEVICES
+ #define H_DEVICES
+ 
++#include <inttypes.h>
++
+ #define GET	0
+ #define PUT	1
+ #define VRFY	2
diff --git a/nixpkgs/pkgs/tools/filesystems/jmtpfs/default.nix b/nixpkgs/pkgs/tools/filesystems/jmtpfs/default.nix
new file mode 100644
index 000000000000..6044806a34b7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/jmtpfs/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchFromGitHub, pkgconfig, file, fuse, libmtp }:
+
+let version = "0.5"; in
+stdenv.mkDerivation {
+  name = "jmtpfs-${version}";
+
+  src = fetchFromGitHub {
+    sha256 = "1pm68agkhrwgrplrfrnbwdcvx5lrivdmqw8pb5gdmm3xppnryji1";
+    rev = "v${version}";
+    repo = "jmtpfs";
+    owner = "JasonFerrara";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ file fuse libmtp ];
+
+  meta = with stdenv.lib; {
+    description = "A FUSE filesystem for MTP devices like Android phones";
+    homepage = https://github.com/JasonFerrara/jmtpfs;
+    license = licenses.gpl3;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.coconnor ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/lizardfs/default.nix b/nixpkgs/pkgs/tools/filesystems/lizardfs/default.nix
new file mode 100644
index 000000000000..f6637b621b8e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/lizardfs/default.nix
@@ -0,0 +1,70 @@
+{ stdenv
+, fetchzip
+, fetchFromGitHub
+, cmake
+, makeWrapper
+, python
+, db
+, fuse
+, asciidoc
+, libxml2
+, libxslt
+, docbook_xml_dtd_412
+, docbook_xsl
+, boost
+, pkgconfig
+, judy
+, pam
+, zlib # optional
+}:
+
+let
+  # See https://github.com/lizardfs/lizardfs/blob/3.12/cmake/Libraries.cmake
+  # We have to download it ourselves, as the build script normally does a download
+  # on-build, which is not good
+  spdlog = fetchzip {
+    name = "spdlog-0.14.0";
+    url = "https://github.com/gabime/spdlog/archive/v0.14.0.zip";
+    sha256 = "13730429gwlabi432ilpnja3sfvy0nn2719vnhhmii34xcdyc57q";
+  };
+in stdenv.mkDerivation rec {
+  name = "lizardfs-${version}";
+  version = "3.12.0";
+
+  src = fetchFromGitHub {
+    owner = "lizardfs";
+    repo = "lizardfs";
+    rev = "v${version}";
+    sha256 = "0zk73wmx82ari3m2mv0zx04x1ggsdmwcwn7k6bkl5c0jnxffc4ax";
+  };
+
+  nativeBuildInputs = [ cmake pkgconfig makeWrapper ];
+
+  buildInputs =
+    [ db fuse asciidoc libxml2 libxslt docbook_xml_dtd_412 docbook_xsl
+      zlib boost judy pam
+    ];
+
+  patches = [
+    ./remove-download-external.patch
+  ];
+
+  postUnpack = ''
+    mkdir $sourceRoot/external/spdlog-0.14.0
+    cp -R ${spdlog}/* $sourceRoot/external/spdlog-0.14.0/
+    chmod -R 755 $sourceRoot/external/spdlog-0.14.0/
+  '';
+
+  postInstall = ''
+    wrapProgram $out/sbin/lizardfs-cgiserver \
+        --prefix PATH ":" "${python}/bin"
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://lizardfs.com;
+    description = "A highly reliable, scalable and efficient distributed file system";
+    platforms = platforms.linux;
+    license = licenses.gpl3;
+    maintainers = [ maintainers.rushmorem ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/lizardfs/remove-download-external.patch b/nixpkgs/pkgs/tools/filesystems/lizardfs/remove-download-external.patch
new file mode 100644
index 000000000000..6bbe95197772
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/lizardfs/remove-download-external.patch
@@ -0,0 +1,25 @@
+From d3f8111ade372c1eb7f3973031f59198508fb588 Mon Sep 17 00:00:00 2001
+From: Kevin Liu <kevin@potatofrom.space>
+Date: Thu, 23 Aug 2018 10:31:42 -0400
+Subject: [PATCH] Remove download_external for spdlog
+
+---
+ cmake/Libraries.cmake | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake
+index 1f951e59..2134444a 100644
+--- a/cmake/Libraries.cmake
++++ b/cmake/Libraries.cmake
+@@ -7,11 +7,6 @@ if(ENABLE_TESTS)
+                     "ef5e700c8a0f3ee123e2e0209b8b4961")
+ endif()
+ 
+-download_external(SPDLOG "spdlog-0.14.0"
+-                  "https://github.com/gabime/spdlog/archive/v0.14.0.zip"
+-                  "f213d83c466aa7044a132e2488d71b11"
+-                  "spdlog-1")
+-
+ # Find standard libraries
+ find_package(Socket REQUIRED)
+ find_package(Threads REQUIRED)
diff --git a/nixpkgs/pkgs/tools/filesystems/mergerfs/default.nix b/nixpkgs/pkgs/tools/filesystems/mergerfs/default.nix
new file mode 100644
index 000000000000..d84855ebb305
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mergerfs/default.nix
@@ -0,0 +1,35 @@
+{ stdenv, fetchFromGitHub, automake, autoconf, pkgconfig, gettext, libtool, pandoc, which, attr, libiconv }:
+
+stdenv.mkDerivation rec {
+  name = "mergerfs-${version}";
+  version = "2.25.1";
+
+  src = fetchFromGitHub {
+    owner = "trapexit";
+    repo = "mergerfs";
+    rev = version;
+    sha256 = "1xrd18spp3wj25dd8513bah856w44gw8hilk190v13g6yafx64n6";
+  };
+
+  nativeBuildInputs = [
+    automake autoconf pkgconfig gettext libtool pandoc which
+  ];
+  buildInputs = [ attr libiconv ];
+
+  preConfigure = ''
+    cat > src/version.hpp <<EOF
+    #pragma once
+    static const char MERGERFS_VERSION[] = "${version}";
+    EOF
+  '';
+
+  makeFlags = [ "PREFIX=$(out)" "XATTR_AVAILABLE=1" ];
+
+  meta = {
+    description = "A FUSE based union filesystem";
+    homepage = https://github.com/trapexit/mergerfs;
+    license = stdenv.lib.licenses.isc;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ jfrankenau makefu ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mergerfs/tools.nix b/nixpkgs/pkgs/tools/filesystems/mergerfs/tools.nix
new file mode 100644
index 000000000000..01f0de25a900
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mergerfs/tools.nix
@@ -0,0 +1,36 @@
+{ stdenv, fetchFromGitHub, coreutils, makeWrapper
+, rsync, python3, pythonPackages }:
+
+stdenv.mkDerivation rec {
+  name = "mergerfs-tools-${version}";
+  version = "20171221";
+
+  src = fetchFromGitHub {
+    owner = "trapexit";
+    repo = "mergerfs-tools";
+    rev = "9b4fe0097b5b51e1a7411a26eb344a24cc8ce1b4";
+    sha256 = "0qrixh3j58gzkmc8r2sgzgy56gm8bmhakwlc2gjb0yrpa1213na1";
+  };
+
+  nativeBuildInputs = [ makeWrapper ];
+  buildInputs = [ python3 ];
+
+  makeFlags = [
+    "INSTALL=${coreutils}/bin/install"
+    "PREFIX=$(out)"
+  ];
+
+  postInstall = with stdenv.lib; ''
+    wrapProgram $out/bin/mergerfs.balance --prefix PATH : ${makeBinPath [ rsync ]}
+    wrapProgram $out/bin/mergerfs.dup --prefix PATH : ${makeBinPath [ rsync ]}
+    wrapProgram $out/bin/mergerfs.mktrash --prefix PATH : ${makeBinPath [ pythonPackages.xattr ]}
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Optional tools to help manage data in a mergerfs pool";
+    homepage = https://github.com/trapexit/mergerfs-tools;
+    license = licenses.isc;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ jfrankenau ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mhddfs/default.nix b/nixpkgs/pkgs/tools/filesystems/mhddfs/default.nix
new file mode 100644
index 000000000000..697256982bbf
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mhddfs/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, fuse, pkgconfig, attr, uthash }:
+
+stdenv.mkDerivation rec {
+  name = "mhddfs-${version}";
+  version = "0.1.39";
+
+  src = fetchurl {
+    url = "http://mhddfs.uvw.ru/downloads/mhddfs_${version}.tar.gz";
+    sha256 = "14ggmh91vv69fp2qpz0nxp0hprlw2wsijss2k2485hb0ci4cabvh";
+  };
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse attr uthash ];
+
+  patches = [
+    ./fix-format-security-error.patch
+  ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp mhddfs $out/bin/
+  '';
+
+  meta = {
+    homepage = http://mhddfs.uvw.ru/;
+    description = "Combines a several mount points into the single one";
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.makefu ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mhddfs/fix-format-security-error.patch b/nixpkgs/pkgs/tools/filesystems/mhddfs/fix-format-security-error.patch
new file mode 100644
index 000000000000..35e58cf0ce9e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mhddfs/fix-format-security-error.patch
@@ -0,0 +1,12 @@
+--- mhddfs-0.1.39/src/usage.c.old	2017-02-28 15:00:25.435438622 +0100
++++ mhddfs-0.1.39/src/usage.c	2017-02-28 15:00:33.847454958 +0100
+@@ -43,7 +43,7 @@
+ 		"\n"
+ 		" see fusermount(1) for information about other options\n"
+ 		"";
+-	fprintf(to, usage);
++	fputs(usage, to);
+ 	if (to==stdout) exit(0);
+ 	exit(-1);
+ }
+
diff --git a/nixpkgs/pkgs/tools/filesystems/mkspiffs/default.nix b/nixpkgs/pkgs/tools/filesystems/mkspiffs/default.nix
new file mode 100644
index 000000000000..48f13925ab08
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mkspiffs/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchFromGitHub, git }:
+
+# Changing the variables CPPFLAGS and BUILD_CONFIG_NAME can be done by
+# overriding the same-named attributes. See ./presets.nix for examples.
+
+stdenv.mkDerivation rec {
+  name = "mkspiffs-${version}";
+  version = "0.2.3";
+
+  src = fetchFromGitHub {
+    owner = "igrr";
+    repo = "mkspiffs";
+    rev = version;
+    fetchSubmodules = true;
+    sha256 = "1fgw1jqdlp83gv56mgnxpakky0q6i6f922niis4awvxjind8pbm1";
+  };
+
+  nativeBuildInputs = [ git ];
+  buildFlags = [ "dist" ];
+  installPhase = ''
+    mkdir -p $out/bin
+    cp mkspiffs $out/bin
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Tool to build and unpack SPIFFS images";
+    license = licenses.mit;
+    homepage = https://github.com/igrr/mkspiffs;
+    maintainers = with maintainers; [ haslersn ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mkspiffs/presets.nix b/nixpkgs/pkgs/tools/filesystems/mkspiffs/presets.nix
new file mode 100644
index 000000000000..c0b74d9cf1b7
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mkspiffs/presets.nix
@@ -0,0 +1,20 @@
+{ lib, mkspiffs }:
+
+# We provide the same presets as the upstream
+
+lib.mapAttrs (
+  name: { CPPFLAGS }:
+  mkspiffs.overrideAttrs (drv: {
+    inherit CPPFLAGS;
+    BUILD_CONFIG_NAME = "-${name}";
+  })
+) {
+  arduino-esp8266.CPPFLAGS = [
+    "-DSPIFFS_USE_MAGIC_LENGTH=0"
+    "-DSPIFFS_ALIGNED_OBJECT_INDEX_TABLES=1"
+  ];
+
+  arduino-esp32.CPPFLAGS = [ "-DSPIFFS_OBJ_META_LEN=4" ];
+
+  esp-idf.CPPFLAGS = [ "-DSPIFFS_OBJ_META_LEN=4" ];
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mp3fs/default.nix b/nixpkgs/pkgs/tools/filesystems/mp3fs/default.nix
new file mode 100644
index 000000000000..cc8ca8411248
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mp3fs/default.nix
@@ -0,0 +1,32 @@
+{ stdenv, fetchurl, flac, fuse, lame, libid3tag, pkgconfig }:
+
+stdenv.mkDerivation rec {
+  name = "mp3fs-${version}";
+  version = "0.91";
+
+  src = fetchurl {
+    url = "https://github.com/khenriks/mp3fs/releases/download/v${version}/${name}.tar.gz";
+    sha256 = "14ngiqg24p3a0s6hp33zjl4i46d8qn4v9id36psycq3n3csmwyx4";
+  };
+
+  patches = [ ./fix-statfs-operation.patch ];
+
+  buildInputs = [ flac fuse lame libid3tag ];
+  nativeBuildInputs = [ pkgconfig ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    description = "FUSE file system that transparently transcodes to MP3";
+    longDescription = ''
+      A read-only FUSE filesystem which transcodes between audio formats
+      (currently only FLAC to MP3) on the fly when files are opened and read.
+      It can let you use a FLAC collection with software and/or hardware
+      which only understands the MP3 format, or transcode files through
+      simple drag-and-drop in a file browser.
+    '';
+    homepage = https://khenriks.github.io/mp3fs/;
+    license = licenses.gpl3Plus;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mp3fs/fix-statfs-operation.patch b/nixpkgs/pkgs/tools/filesystems/mp3fs/fix-statfs-operation.patch
new file mode 100644
index 000000000000..9b3094e60053
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mp3fs/fix-statfs-operation.patch
@@ -0,0 +1,39 @@
+From fea072084ff9d7c4d2c688059a2462bb0e59a2ec Mon Sep 17 00:00:00 2001
+From: K Henriksson <kthenriksson@gmail.com>
+Date: Wed, 27 Aug 2014 21:55:18 -0700
+Subject: [PATCH] Fix statfs operation
+
+The statfs implementation does not properly translate names back to the
+original, since the major encoding rewrite. This corrects that, and
+should fix issue #27.
+---
+ src/fuseops.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/fuseops.c b/src/fuseops.c
+index e7b4e7e..c333cbd 100644
+--- a/src/fuseops.c
++++ b/src/fuseops.c
+@@ -337,9 +337,20 @@ static int mp3fs_statfs(const char *path, struct statvfs *stbuf) {
+     if (!origpath) {
+         goto translate_fail;
+     }
+-    
++
++    /* pass-through for regular files */
++    if (statvfs(origpath, stbuf) == 0) {
++        goto passthrough;
++    } else {
++        /* Not really an error. */
++        errno = 0;
++    }
++
++    find_original(origpath);
++
+     statvfs(origpath, stbuf);
+-    
++
++passthrough:
+     free(origpath);
+ translate_fail:
+     return -errno;
diff --git a/nixpkgs/pkgs/tools/filesystems/mtdutils/default.nix b/nixpkgs/pkgs/tools/filesystems/mtdutils/default.nix
new file mode 100644
index 000000000000..d0ceaf94a75f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mtdutils/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, libuuid, lzo, zlib, acl }:
+
+stdenv.mkDerivation rec {
+  name = "mtd-utils-${version}";
+  version = "1.5.2";
+
+  src = fetchurl {
+    url = ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.5.2.tar.bz2;
+    sha256 = "007lhsd8yb34l899r4m37whhzdw815cz4fnjbpnblfha524p7dax";
+  };
+
+  patchPhase = ''
+    sed -i -e s,/usr/local,, -e s,/usr,$out, common.mk
+  '';
+
+  buildInputs = [ libuuid lzo zlib acl ];
+
+  meta = {
+    description = "Tools for MTD filesystems";
+    license = stdenv.lib.licenses.gpl2Plus;
+    homepage = http://www.linux-mtd.infradead.org/;
+    maintainers = with stdenv.lib.maintainers; [viric];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mtools/UNUSED-darwin.patch b/nixpkgs/pkgs/tools/filesystems/mtools/UNUSED-darwin.patch
new file mode 100644
index 000000000000..46b790afd30a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mtools/UNUSED-darwin.patch
@@ -0,0 +1,11 @@
+--- mtools/sysincludes.h.orig	2017-04-01 20:59:46.083196540 +0100
++++ mtools/sysincludes.h	2017-04-01 20:59:12.855030456 +0100
+@@ -103,7 +103,7 @@
+ # define PACKED __attribute__ ((packed))
+ # if __GNUC__ == 2 && __GNUC_MINOR__ > 6 || __GNUC__ >= 3
+ /* gcc 2.6.3 doesn't have "unused" */		/* mool */
+-#  define UNUSED(x) x __attribute__ ((unused));x
++#  define UNUSED(x) x
+ #  define UNUSEDP __attribute__ ((unused))
+ # else
+ #  define UNUSED(x) x
diff --git a/nixpkgs/pkgs/tools/filesystems/mtools/default.nix b/nixpkgs/pkgs/tools/filesystems/mtools/default.nix
new file mode 100644
index 000000000000..b477ad8deace
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mtools/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  name = "mtools-4.0.23";
+
+  src = fetchurl {
+    url = "mirror://gnu/mtools/${name}.tar.bz2";
+    sha256 = "1qwfxzr964fasxlzhllahk8mzh7c82s808wvly95dsqsflkdp27i";
+  };
+
+  patches = stdenv.lib.optional stdenv.isDarwin ./UNUSED-darwin.patch;
+
+  # fails to find X on darwin
+  configureFlags = stdenv.lib.optional stdenv.isDarwin "--without-x";
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://www.gnu.org/software/mtools/;
+    description = "Utilities to access MS-DOS disks";
+    platforms = platforms.unix;
+    license = licenses.gpl3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/mtpfs/default.nix b/nixpkgs/pkgs/tools/filesystems/mtpfs/default.nix
new file mode 100644
index 000000000000..bf048113714f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/mtpfs/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, pkgconfig, fuse, libmtp, glib, libmad, libid3tag }:
+
+stdenv.mkDerivation rec {
+  name = "mtpfs-1.1";
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ fuse libmtp glib libid3tag libmad ];
+
+  # adding LIBS is a hack, duno why it does not find libid3tag.so by adding buildInputs
+  preConfigure = ''
+    export MAD_CFLAGS=${libmad}/include
+    export MAD_LIBS=${libmad}/lib/libmad.so
+    export LIBS=${libid3tag}/lib/libid3tag.so
+  '';
+
+  src = fetchurl {
+    url = "https://www.adebenham.com/files/mtp/${name}.tar.gz";
+    sha256 = "07acrqb17kpif2xcsqfqh5j4axvsa4rnh6xwnpqab5b9w5ykbbqv";
+  };
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/cjd/mtpfs;
+    description = "FUSE Filesystem providing access to MTP devices";
+    platforms = platforms.all;
+    license = licenses.gpl3;
+    maintainers = [ maintainers.qknight ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/netatalk/default.nix b/nixpkgs/pkgs/tools/filesystems/netatalk/default.nix
new file mode 100644
index 000000000000..797ce40a561f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/netatalk/default.nix
@@ -0,0 +1,60 @@
+{ fetchurl, stdenv, autoreconfHook, pkgconfig, perl, python
+, db, libgcrypt, avahi, libiconv, pam, openssl, acl
+, ed, glibc
+}:
+
+stdenv.mkDerivation rec{
+  name = "netatalk-3.1.11";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/netatalk/netatalk/${name}.tar.bz2";
+    sha256 = "3434472ba96d3bbe3b024274438daad83b784ced720f7662a4c1d0a1078799a6";
+  };
+
+  patches = [
+    ./no-suid.patch
+    ./omitLocalstatedirCreation.patch
+  ];
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig perl python python.pkgs.wrapPython ];
+
+  buildInputs = [ db libgcrypt avahi libiconv pam openssl acl ];
+
+  configureFlags = [
+    "--with-bdb=${db.dev}"
+    "--with-ssl-dir=${openssl.dev}"
+    "--with-lockfile=/run/lock/netatalk"
+    "--localstatedir=/var/lib"
+  ];
+
+  # Expose librpcsvc to the linker for afpd
+  # Fixes errors that showed up when closure-size was merged:
+  # afpd-nfsquota.o: In function `callaurpc':
+  # netatalk-3.1.7/etc/afpd/nfsquota.c:78: undefined reference to `xdr_getquota_args'
+  # netatalk-3.1.7/etc/afpd/nfsquota.c:78: undefined reference to `xdr_getquota_rslt'
+  postConfigure = ''
+    ${ed}/bin/ed -v etc/afpd/Makefile << EOF
+    /^afpd_LDADD
+    /am__append_2
+    a
+      ${glibc.static}/lib/librpcsvc.a \\
+    .
+    w
+    EOF
+  '';
+
+  postInstall = ''
+    buildPythonPath ${python.pkgs.dbus-python}
+    patchPythonScript $out/bin/afpstats
+  '';
+
+  enableParallelBuilding = true;
+
+  meta = {
+    description = "Apple Filing Protocol Server";
+    homepage = http://netatalk.sourceforge.net/;
+    license = stdenv.lib.licenses.gpl3;
+    platforms = stdenv.lib.platforms.linux;
+    maintainers = with stdenv.lib.maintainers; [ jcumming ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/netatalk/no-suid.patch b/nixpkgs/pkgs/tools/filesystems/netatalk/no-suid.patch
new file mode 100644
index 000000000000..194c1f5fac9f
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/netatalk/no-suid.patch
@@ -0,0 +1,11 @@
+diff --git a/bin/afppasswd/Makefile.am b/bin/afppasswd/Makefile.am
+index 578eac1..d17aa22 100644
+--- a/bin/afppasswd/Makefile.am
++++ b/bin/afppasswd/Makefile.am
+@@ -16,5 +16,5 @@ AM_CFLAGS = @SSL_CFLAGS@ -I$(top_srcdir)/sys \
+ 
+ install-exec-hook:
+ if HAVE_OPENSSL
+-	chmod u+s $(DESTDIR)$(bindir)/afppasswd
++#	chmod u+s $(DESTDIR)$(bindir)/afppasswd
+ endif
diff --git a/nixpkgs/pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patch b/nixpkgs/pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patch
new file mode 100644
index 000000000000..01c4ee9ba478
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/netatalk/omitLocalstatedirCreation.patch
@@ -0,0 +1,19 @@
+diff --git a/config/Makefile.am b/config/Makefile.am
+index c98a2ab..58b7f0a 100644
+--- a/config/Makefile.am
++++ b/config/Makefile.am
+@@ -36,10 +36,10 @@ endif
+ #
+ 
+ install-data-local: install-config-files
+-	mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/
+-	mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/CNID/
+-	$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/
+-	$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/CNID/
++#	mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/
++#	mkdir -pm 0755 $(DESTDIR)$(localstatedir)/netatalk/CNID/
++#	$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/
++#	$(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(localstatedir)/netatalk/CNID/
+ 
+ uninstall-local:
+ 	@for f in $(CONFFILES) $(GENFILES); do \
diff --git a/nixpkgs/pkgs/tools/filesystems/nilfs-utils/default.nix b/nixpkgs/pkgs/tools/filesystems/nilfs-utils/default.nix
new file mode 100644
index 000000000000..eccd72ceb238
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nilfs-utils/default.nix
@@ -0,0 +1,57 @@
+{ stdenv, fetchurl, fetchpatch, libuuid, libselinux }:
+let
+  sourceInfo = rec {
+    version = "2.2.7";
+    url = "http://nilfs.sourceforge.net/download/nilfs-utils-${version}.tar.bz2";
+    sha256 = "01f09bvjk2crx65pxmxiw362wkkl3v2v144dfn3i7bk5gz253xic";
+    baseName = "nilfs-utils";
+    name = "${baseName}-${version}";
+  };
+in
+stdenv.mkDerivation rec {
+  src = fetchurl {
+    url = sourceInfo.url;
+    sha256 = sourceInfo.sha256;
+  };
+
+  inherit (sourceInfo) name version;
+  buildInputs = [libuuid libselinux];
+
+  preConfigure = ''
+    sed -e '/sysconfdir=\/etc/d; ' -i configure
+    sed -e "s@sbindir=/sbin@sbindir=$out/sbin@" -i configure
+    sed -e 's@/sbin/@'"$out"'/sbin/@' -i ./lib/cleaner*.c
+  '';
+
+  patches = [
+    # Fix w/musl
+    (fetchpatch {
+      url = "https://github.com/nilfs-dev/nilfs-utils/commit/115fe4b976858c487cf83065f513d8626089579a.patch";
+      sha256 = "0h89jz9l5d4rqj647ljbnv451l4ncqpsvzj0v70mn5391hfwsjlv";
+    })
+    (fetchpatch {
+      url =  "https://github.com/nilfs-dev/nilfs-utils/commit/51b32c614be9e98c32de7f531ee600ca0740946f.patch";
+      sha256 = "1ycq83c6jjy74aif47v075k5y2szzwhq6mbcrpd1z4b4i1x6yhpn";
+    })
+  ];
+
+  configureFlags = [ "--with-libmount" ];
+
+  # FIXME: https://github.com/NixOS/patchelf/pull/98 is in, but stdenv
+  # still doesn't use it
+  #
+  # To make sure patchelf doesn't mistakenly keep the reference via
+  # build directory
+  postInstall = ''
+    find . -name .libs | xargs rm -rf
+  '';
+
+  meta = with stdenv.lib; {
+    description = "NILFS utilities";
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    license =  with licenses; [ gpl2 lgpl21 ];
+    downloadPage = "http://nilfs.sourceforge.net/en/download.html";
+    updateWalker = true;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.nix
new file mode 100644
index 000000000000..24aab7dc6dd4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.nix
@@ -0,0 +1,50 @@
+# FIXME: Unify with pkgs/development/python-modules/blivet/default.nix.
+
+{ stdenv, fetchurl, buildPythonApplication, pykickstart, pyparted, pyblock
+, libselinux, cryptsetup, multipath_tools, lsof, utillinux
+, useNixUdev ? true, systemd ? null
+}:
+
+assert useNixUdev -> systemd != null;
+
+buildPythonApplication rec {
+  name = "blivet-${version}";
+  version = "0.17-1";
+
+  src = fetchurl {
+    url = "https://git.fedorahosted.org/cgit/blivet.git/snapshot/"
+        + "${name}.tar.bz2";
+    sha256 = "1k3mws2q0ryb7422mml6idmaasz2i2v6ngyvg6d976dx090qnmci";
+  };
+
+  patches = [ ./blivet.patch ];
+
+  postPatch = ''
+    sed -i -e 's|"multipath"|"${multipath_tools}/sbin/multipath"|' \
+      blivet/devicelibs/mpath.py blivet/devices.py
+    sed -i -e '/"wipefs"/ {
+      s|wipefs|${utillinux.bin}/sbin/wipefs|
+      s/-f/--force/
+    }' blivet/formats/__init__.py
+    sed -i -e 's|"lsof"|"${lsof}/bin/lsof"|' blivet/formats/fs.py
+    sed -i -r -e 's|"(u?mount)"|"${utillinux.bin}/bin/\1"|' blivet/util.py
+  '' + stdenv.lib.optionalString useNixUdev ''
+    sed -i -e '/find_library/,/find_library/ {
+      c libudev = "${systemd.lib}/lib/libudev.so.1"
+    }' blivet/pyudev.py
+  '';
+
+  propagatedBuildInputs = [
+    pykickstart pyparted pyblock libselinux.py cryptsetup
+  ] ++ stdenv.lib.optional useNixUdev systemd;
+
+  # tests are currently _heavily_ broken upstream
+  doCheck = false;
+
+  meta = with stdenv.lib; {
+    homepage = https://fedoraproject.org/wiki/Blivet;
+    description = "Module for management of a system's storage configuration";
+    license = with licenses; [ gpl2Plus lgpl21Plus ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.patch b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.patch
new file mode 100644
index 000000000000..d53231a84fd6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/blivet.patch
@@ -0,0 +1,51 @@
+diff --git a/blivet/pyudev.py b/blivet/pyudev.py
+index 705b93d..7268d71 100644
+--- a/blivet/pyudev.py
++++ b/blivet/pyudev.py
+@@ -7,9 +7,9 @@ from ctypes import *
+ 
+ 
+ # XXX this one may need some tweaking...
+-def find_library(name, somajor=0):
++def find_library(name):
+     env = os.environ.get("LD_LIBRARY_PATH")
+-    common = ["/lib64", "/lib"]
++    common = ["/lib64", "/lib", "/lib/x86_64-linux-gnu", "/lib/i686-linux-gnu"]
+ 
+     if env:
+         libdirs = env.split(":") + common
+@@ -19,7 +19,7 @@ def find_library(name, somajor=0):
+     libdirs = filter(os.path.isdir, libdirs)
+ 
+     for dir in libdirs:
+-        files = fnmatch.filter(os.listdir(dir), "lib%s.so.%d" % (name, somajor))
++        files = fnmatch.filter(os.listdir(dir), "lib%s.so.*" % name)
+         files = [os.path.join(dir, file) for file in files]
+ 
+         if files:
+@@ -32,11 +32,10 @@ def find_library(name, somajor=0):
+ 
+ # find the udev library
+ name = "udev"
+-somajor = 1
+-libudev = find_library(name=name, somajor=somajor)
++libudev = find_library(name)
+ 
+ if not libudev or not os.path.exists(libudev):
+-    raise ImportError, "No library named %s.%d" % (name, somajor)
++    raise ImportError, "No library named lib%s.so" % name
+ 
+ # load the udev library
+ libudev = CDLL(libudev)
+diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py
+index 705b93d..60f8f32 100644
+--- a/blivet/deviceaction.py
++++ b/blivet/deviceaction.py
+@@ -467,6 +467,7 @@ def execute(self):
+ 
+                 self.device.disk.format.commitToDisk()
+ 
++            self.device.setup()
+             self.device.format.create(device=self.device.path,
+                                       options=self.device.formatArgs)
+ 
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/cryptsetup.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/cryptsetup.nix
new file mode 100644
index 000000000000..9fe4f90f258b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/cryptsetup.nix
@@ -0,0 +1,29 @@
+{ stdenv, fetchurl, lvm2, libgcrypt, libuuid, pkgconfig, popt
+, enablePython ? true, python ? null
+}:
+
+assert enablePython -> python != null;
+
+stdenv.mkDerivation rec {
+  name = "cryptsetup-1.6.3";
+
+  src = fetchurl {
+    url = "http://cryptsetup.googlecode.com/files/${name}.tar.bz2";
+    sha256 = "1n1qk5chyjspbiianrdb55fhb4wl0vfyqz2br05vfb24v4qlgbx2";
+  };
+
+  configureFlags = [ "--enable-cryptsetup-reencrypt" ]
+                ++ stdenv.lib.optional enablePython "--enable-python";
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ lvm2 libgcrypt libuuid popt ]
+             ++ stdenv.lib.optional enablePython python;
+
+  meta = {
+    homepage = http://code.google.com/p/cryptsetup/;
+    description = "LUKS for dm-crypt";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = with stdenv.lib.maintainers; [ chaoflow ];
+    platforms = with stdenv.lib.platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/default.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/default.nix
new file mode 100644
index 000000000000..6a1c12e3e722
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/default.nix
@@ -0,0 +1,75 @@
+{ stdenv, fetchurl, python, buildPythonApplication
+# Propagated to blivet
+, useNixUdev ? true
+# Needed by NixOps
+, udevSoMajor ? null
+# Propagated dependencies
+, pkgs, urlgrabber
+}:
+
+let
+  blivet = import ./blivet.nix {
+    inherit stdenv fetchurl buildPythonApplication;
+    inherit pykickstart pyparted pyblock cryptsetup multipath_tools;
+    inherit useNixUdev;
+    inherit (pkgs) lsof utillinux systemd;
+    libselinux = pkgs.libselinux.override { enablePython = true; };
+  };
+
+  cryptsetup = import ./cryptsetup.nix {
+    inherit stdenv fetchurl python;
+    inherit (pkgs) pkgconfig libgcrypt libuuid popt lvm2;
+  };
+
+  dmraid = import ./dmraid.nix {
+    inherit stdenv fetchurl lvm2;
+  };
+
+  lvm2 = import ./lvm2.nix {
+    inherit stdenv fetchurl;
+    inherit (pkgs) pkgconfig utillinux systemd coreutils;
+  };
+
+  multipath_tools = import ./multipath-tools.nix {
+    inherit stdenv fetchurl lvm2;
+    inherit (pkgs) readline systemd libaio gzip;
+  };
+
+  parted = import ./parted.nix {
+    inherit stdenv fetchurl;
+    inherit (pkgs) utillinux readline libuuid gettext check lvm2;
+  };
+
+  pyblock = import ./pyblock.nix {
+    inherit stdenv fetchurl python lvm2 dmraid;
+  };
+
+  pykickstart = import ./pykickstart.nix {
+    inherit stdenv fetchurl python buildPythonApplication urlgrabber;
+  };
+
+  pyparted = import ./pyparted.nix {
+    inherit stdenv fetchurl python buildPythonApplication parted;
+    inherit (pkgs) pkgconfig e2fsprogs;
+  };
+
+in buildPythonApplication rec {
+  name = "nixpart-${version}";
+  version = "0.4.1";
+
+  src = fetchurl {
+    url = "https://github.com/aszlig/nixpart/archive/v${version}.tar.gz";
+    sha256 = "0avwd8p47xy9cydlbjxk8pj8q75zyl68gw2w6fnkk78dcb1a3swp";
+  };
+
+  propagatedBuildInputs = [ blivet ];
+
+  doCheck = false;
+
+  meta = {
+    description = "NixOS storage manager/partitioner";
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.aszlig ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/dmraid.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/dmraid.nix
new file mode 100644
index 000000000000..fd6088891023
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/dmraid.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, lvm2 }:
+
+stdenv.mkDerivation rec {
+  name = "dmraid-1.0.0.rc15";
+
+  src = fetchurl {
+    url = "https://people.redhat.com/~heinzm/sw/dmraid/src/old/${name}.tar.bz2";
+    sha256 = "01bcaq0sc329ghgj7f182xws7jgjpdc41bvris8fsiprnxc7511h";
+  };
+
+  preConfigure = "cd */";
+
+  buildInputs = [ lvm2 ];
+
+  meta = {
+    description = "Old-style RAID configuration utility";
+    longDescription = ''
+      Old RAID configuration utility (still under development, though).
+      It is fully compatible with modern kernels and mdadm recognizes
+      its volumes. May be needed for rescuing an older system or nuking
+      the metadata when reformatting.
+    '';
+    maintainers = [ stdenv.lib.maintainers.raskin ];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/lvm2.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/lvm2.nix
new file mode 100644
index 000000000000..7c92dc95268e
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/lvm2.nix
@@ -0,0 +1,64 @@
+{ stdenv, fetchurl, pkgconfig, systemd, utillinux, coreutils }:
+
+let
+  v = "2.02.106";
+in
+
+stdenv.mkDerivation {
+  name = "lvm2-${v}";
+
+  src = fetchurl {
+    url = "ftp://sources.redhat.com/pub/lvm2/releases/LVM2.${v}.tgz";
+    sha256 = "0nr833bl0q4zq52drjxmmpf7bs6kqxwa5kahwwxm9411khkxz0vc";
+  };
+
+  configureFlags = [
+    "--disable-readline"
+    "--enable-udev_rules"
+    "--enable-udev_sync"
+    "--enable-pkgconfig"
+    "--enable-applib"
+  ];
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ systemd ];
+
+  preConfigure =
+    ''
+      substituteInPlace scripts/lvmdump.sh \
+        --replace /usr/bin/tr ${coreutils}/bin/tr
+      substituteInPlace scripts/lvm2_activation_generator_systemd_red_hat.c \
+        --replace /usr/sbin/lvm $out/sbin/lvm \
+        --replace /usr/bin/udevadm ${systemd}/bin/udevadm
+
+      sed -i /DEFAULT_SYS_DIR/d Makefile.in
+      sed -i /DEFAULT_PROFILE_DIR/d conf/Makefile.in
+    '';
+
+  enableParallelBuilding = true;
+
+  #patches = [ ./purity.patch ];
+
+  # To prevent make install from failing.
+  preInstall = "installFlags=\"OWNER= GROUP= confdir=$out/etc\"";
+
+  # Install systemd stuff.
+  #installTargets = "install install_systemd_generators install_systemd_units install_tmpfiles_configuration";
+
+  postInstall =
+    ''
+      substituteInPlace $out/lib/udev/rules.d/13-dm-disk.rules \
+        --replace $out/sbin/blkid ${utillinux.bin}/sbin/blkid
+
+      # Systemd stuff
+      mkdir -p $out/etc/systemd/system $out/lib/systemd/system-generators
+      cp scripts/blk_availability_systemd_red_hat.service $out/etc/systemd/system
+      cp scripts/lvm2_activation_generator_systemd_red_hat $out/lib/systemd/system-generators
+    '';
+
+  meta = {
+    homepage = http://sourceware.org/lvm2/;
+    description = "Tools to support Logical Volume Management (LVM) on Linux";
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/multipath-tools.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/multipath-tools.nix
new file mode 100644
index 000000000000..f30bd958cf3a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/multipath-tools.nix
@@ -0,0 +1,36 @@
+# FIXME: unify with pkgs/os-specific/linux/multipath-tools/default.nix.
+
+{ stdenv, fetchurl, lvm2, libaio, gzip, readline, systemd }:
+
+stdenv.mkDerivation rec {
+  name = "multipath-tools-0.4.9";
+
+  src = fetchurl {
+    url = "http://christophe.varoqui.free.fr/multipath-tools/${name}.tar.bz2";
+    sha256 = "04n7kazp1zrlqfza32phmqla0xkcq4zwn176qff5ida4a60whi4d";
+  };
+
+  sourceRoot = ".";
+
+  buildInputs = [ lvm2 libaio readline gzip ];
+
+  preBuild =
+    ''
+      makeFlagsArray=(GZIP="-9" prefix=$out mandir=$out/share/man/man8 man5dir=$out/share/man/man5 LIB=lib)
+
+      substituteInPlace multipath/Makefile --replace /etc $out/etc
+      substituteInPlace kpartx/Makefile --replace /etc $out/etc
+
+      substituteInPlace kpartx/kpartx.rules --replace /sbin/kpartx $out/sbin/kpartx
+      substituteInPlace kpartx/kpartx_id --replace /sbin/dmsetup ${lvm2}/sbin/dmsetup
+
+      substituteInPlace libmultipath/defaults.h --replace /lib/udev/scsi_id ${systemd.lib}/lib/udev/scsi_id
+      substituteInPlace libmultipath/hwtable.c --replace /lib/udev/scsi_id ${systemd.lib}/lib/udev/scsi_id
+    '';
+
+  meta = {
+    description = "Tools for the Linux multipathing driver";
+    homepage = http://christophe.varoqui.free.fr/;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/parted.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/parted.nix
new file mode 100644
index 000000000000..046fe81e64ac
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/parted.nix
@@ -0,0 +1,50 @@
+{ stdenv, fetchurl, lvm2, libuuid, gettext, readline
+, utillinux, check, enableStatic ? false }:
+
+stdenv.mkDerivation rec {
+  name = "parted-3.1";
+
+  src = fetchurl {
+    url = "mirror://gnu/parted/${name}.tar.xz";
+    sha256 = "05fa4m1bky9d13hqv91jlnngzlyn7y4rnnyq6d86w0dg3vww372y";
+  };
+
+  buildInputs = [ libuuid ]
+    ++ stdenv.lib.optional (readline != null) readline
+    ++ stdenv.lib.optional (gettext != null) gettext
+    ++ stdenv.lib.optional (lvm2 != null) lvm2;
+
+  configureFlags =
+       (if (readline != null)
+        then [ "--with-readline" ]
+        else [ "--without-readline" ])
+    ++ stdenv.lib.optional (lvm2 == null) "--disable-device-mapper"
+    ++ stdenv.lib.optional enableStatic "--enable-static";
+
+  doCheck = true;
+  checkInputs = [ check utillinux ];
+
+  meta = {
+    description = "Create, destroy, resize, check, and copy partitions";
+
+    longDescription = ''
+      GNU Parted is an industrial-strength package for creating, destroying,
+      resizing, checking and copying partitions, and the file systems on
+      them.  This is useful for creating space for new operating systems,
+      reorganising disk usage, copying data on hard disks and disk imaging.
+
+      It contains a library, libparted, and a command-line frontend, parted,
+      which also serves as a sample implementation and script backend.
+    '';
+
+    homepage = https://www.gnu.org/software/parted/;
+    license = stdenv.lib.licenses.gpl3Plus;
+
+    maintainers = [
+      # Add your name here!
+    ];
+
+    # GNU Parted requires libuuid, which is part of util-linux-ng.
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyblock.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyblock.nix
new file mode 100644
index 000000000000..881301ed38e5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyblock.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchurl, python, lvm2, dmraid }:
+
+stdenv.mkDerivation rec {
+  name = "pyblock-${version}";
+  version = "0.53";
+  md5_path = "f6d33a8362dee358517d0a9e2ebdd044";
+
+  src = fetchurl rec {
+    url = "https://src.fedoraproject.org/repo/pkgs/python-pyblock/"
+        + "${name}.tar.bz2/${md5_path}/${name}.tar.bz2";
+    sha256 = "f6cef88969300a6564498557eeea1d8da58acceae238077852ff261a2cb1d815";
+  };
+
+  postPatch = ''
+    sed -i -e 's|/usr/include/python|${python}/include/python|' \
+           -e 's/-Werror *//' -e 's|/usr/|'"$out"'/|' Makefile
+  '';
+
+  buildInputs = [ python lvm2 dmraid ];
+
+  makeFlags = [
+    "USESELINUX=0"
+    "SITELIB=$(out)/lib/${python.libPrefix}/site-packages"
+  ];
+
+  meta = {
+    description = "Interface for working with block devices";
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pykickstart.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pykickstart.nix
new file mode 100644
index 000000000000..ce1d0bf28a16
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pykickstart.nix
@@ -0,0 +1,31 @@
+{ stdenv, python, buildPythonApplication, fetchurl, urlgrabber }:
+
+buildPythonApplication rec {
+  name = "pykickstart-${version}";
+  version = "1.99.39";
+  md5_path = "d249f60aa89b1b4facd63f776925116d";
+
+  src = fetchurl rec {
+    url = "https://src.fedoraproject.org/repo/pkgs/pykickstart/"
+        + "${name}.tar.gz/${md5_path}/${name}.tar.gz";
+    sha256 = "e0d0f98ac4c5607e6a48d5c1fba2d50cc804de1081043f9da68cbfc69cad957a";
+  };
+
+  postPatch = ''
+    sed -i -e "s/for tst in tstList/for tst in sorted(tstList, \
+               key=lambda m: m.__name__)/" tests/baseclass.py
+  '';
+
+  propagatedBuildInputs = [ urlgrabber ];
+
+  checkPhase = ''
+    export PYTHONPATH="$PYTHONPATH:."
+    ${python}/bin/${python.executable} tests/baseclass.py -vv
+  '';
+
+  meta = {
+    homepage = http://fedoraproject.org/wiki/Pykickstart;
+    description = "Read and write Fedora kickstart files";
+    license = stdenv.lib.licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyparted.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyparted.nix
new file mode 100644
index 000000000000..fd6c5b913093
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/0.4/pyparted.nix
@@ -0,0 +1,42 @@
+{ stdenv, fetchurl, pkgconfig, python, buildPythonApplication, parted, e2fsprogs }:
+
+buildPythonApplication rec {
+  name = "pyparted-${version}";
+  version = "3.10";
+
+  src = fetchurl {
+    url = "https://fedorahosted.org/releases/p/y/pyparted/${name}.tar.gz";
+    sha256 = "17wq4invmv1nfazaksf59ymqyvgv3i8h4q03ry2az0s9lldyg3dv";
+  };
+
+  postPatch = ''
+    sed -i -e 's|/sbin/mke2fs|${e2fsprogs}&|' tests/baseclass.py
+    sed -i -e '
+      s|e\.path\.startswith("/tmp/temp-device-")|"temp-device-" in e.path|
+    ' tests/test__ped_ped.py
+  '' + stdenv.lib.optionalString stdenv.isi686 ''
+    # remove some integers in this test case which overflow on 32bit systems
+    sed -i -r -e '/class *UnitGetSizeTestCase/,/^$/{/[0-9]{11}/d}' \
+      tests/test__ped_ped.py
+  '';
+
+  preConfigure = ''
+    PATH="${parted}/sbin:$PATH"
+  '';
+
+  nativeBuildInputs = [ pkgconfig ];
+
+  propagatedBuildInputs = [ parted ];
+
+  checkPhase = ''
+    patchShebangs Makefile
+    make test PYTHON=${python.executable}
+  '';
+
+  meta = {
+    homepage = https://fedorahosted.org/pyparted/;
+    description = "Python interface for libparted";
+    license = stdenv.lib.licenses.gpl2Plus;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/nixpart/default.nix b/nixpkgs/pkgs/tools/filesystems/nixpart/default.nix
new file mode 100644
index 000000000000..ce00367c771c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/nixpart/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, buildPythonApplication, blivet }:
+
+buildPythonApplication rec {
+  name = "nixpart-${version}";
+  version = "1.0.0";
+
+  src = fetchurl {
+    url = "https://github.com/aszlig/nixpart/archive/v${version}.tar.gz";
+    sha256 = "0avwd8p47xy9cydlbjxk8pj8q75zyl68gw2w6fnkk78dcb1a3swp";
+  };
+
+  propagatedBuildInputs = [ blivet ];
+
+  meta = {
+    description = "NixOS storage manager/partitioner";
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = [ stdenv.lib.maintainers.aszlig ];
+    platforms = stdenv.lib.platforms.linux;
+    broken = true;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/ntfs-3g/default.nix b/nixpkgs/pkgs/tools/filesystems/ntfs-3g/default.nix
new file mode 100644
index 000000000000..7ee54a63fbb8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/ntfs-3g/default.nix
@@ -0,0 +1,56 @@
+{stdenv, fetchurl, fetchpatch, utillinux, libuuid
+, crypto ? false, libgcrypt, gnutls, pkgconfig}:
+
+stdenv.mkDerivation rec {
+  pname = "ntfs3g";
+  version = "2017.3.23";
+  name = "${pname}-${version}";
+
+  outputs = [ "out" "dev" "man" "doc" ];
+
+  buildInputs = [ libuuid ] ++ stdenv.lib.optionals crypto [ gnutls libgcrypt ];
+  nativeBuildInputs = stdenv.lib.optional crypto pkgconfig;
+
+  src = fetchurl {
+    url = "http://tuxera.com/opensource/ntfs-3g_ntfsprogs-${version}.tgz";
+    sha256 = "1mb228p80hv97pgk3myyvgp975r9mxq56c6bdn1n24kngcfh4niy";
+  };
+
+  patches = [
+    (fetchpatch {
+      url = "https://sources.debian.org/data/main/n/ntfs-3g/1:2016.2.22AR.1+dfsg-1/debian/patches/0003-CVE-2017-0358.patch";
+      sha256 = "0hd05q9q06r18k8pmppvch1sslzqln5fvqj51d5r72g4mnpavpj3";
+    })
+  ];
+
+  patchPhase = ''
+    substituteInPlace src/Makefile.in --replace /sbin '@sbindir@'
+    substituteInPlace ntfsprogs/Makefile.in --replace /sbin '@sbindir@'
+    substituteInPlace libfuse-lite/mount_util.c \
+      --replace /bin/mount ${utillinux}/bin/mount \
+      --replace /bin/umount ${utillinux}/bin/umount
+  '';
+
+  configureFlags = [
+    "--disable-ldconfig"
+    "--exec-prefix=\${prefix}"
+    "--enable-mount-helper"
+    "--enable-posix-acls"
+    "--enable-xattr-mappings"
+    "--${if crypto then "enable" else "disable"}-crypto"
+  ];
+
+  postInstall =
+    ''
+      # Prefer ntfs-3g over the ntfs driver in the kernel.
+      ln -sv mount.ntfs-3g $out/sbin/mount.ntfs
+    '';
+
+  meta = with stdenv.lib; {
+    homepage = https://www.tuxera.com/community/open-source-ntfs-3g/;
+    description = "FUSE-based NTFS driver with full write support";
+    maintainers = with maintainers; [ dezgeg ];
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus; # and (lib)fuse-lite under LGPL2+
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/rdfind/default.nix b/nixpkgs/pkgs/tools/filesystems/rdfind/default.nix
new file mode 100644
index 000000000000..2457ac59a213
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/rdfind/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, fetchurl, nettle }:
+
+stdenv.mkDerivation rec {
+  name = "rdfind-${version}";
+  version = "1.4.1";
+
+  src = fetchurl {
+    url = "https://rdfind.pauldreik.se/${name}.tar.gz";
+    sha256 = "132y3wwgnbpdx6f90q0yahd3nkr4cjzcy815ilc8p97b4vn17iih";
+  };
+
+  buildInputs = [ nettle ];
+
+  meta = with stdenv.lib; {
+    homepage = https://rdfind.pauldreik.se/;
+    description = "Removes or hardlinks duplicate files very swiftly";
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ maintainers.wmertens ];
+    platforms = platforms.all;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/reiser4progs/default.nix b/nixpkgs/pkgs/tools/filesystems/reiser4progs/default.nix
new file mode 100644
index 000000000000..967a8ee43bef
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/reiser4progs/default.nix
@@ -0,0 +1,31 @@
+{stdenv, fetchurl, libaal}:
+
+let version = "1.2.1"; in
+stdenv.mkDerivation rec {
+  name = "reiser4progs-${version}";
+
+  src = fetchurl {
+    url = "mirror://sourceforge/reiser4/reiser4-utils/${name}.tar.gz";
+    sha256 = "03vdqvpyd48wxrpqpb9kg76giaffw9b8k334kr4wc0zxgybknhl7";
+  };
+
+  buildInputs = [libaal];
+
+  hardeningDisable = [ "format" ];
+
+  preConfigure = ''
+    substituteInPlace configure --replace " -static" ""
+  '';
+
+  preInstall = ''
+    substituteInPlace Makefile --replace ./run-ldconfig true
+  '';
+
+  meta = with stdenv.lib; {
+    inherit version;
+    homepage = https://sourceforge.net/projects/reiser4/;
+    description = "Reiser4 utilities";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/default.nix b/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/default.nix
new file mode 100644
index 000000000000..345974bed58d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchurl, libuuid, autoreconfHook }:
+
+let version = "3.6.24"; in
+stdenv.mkDerivation rec {
+  name = "reiserfsprogs-${version}";
+
+  src = fetchurl {
+    url = "https://www.kernel.org/pub/linux/kernel/people/jeffm/reiserfsprogs/v${version}/${name}.tar.xz";
+    sha256 = "0q07df9wxxih8714a3mdp61h5n347l7j2a0l351acs3xapzgwi3y";
+  };
+
+  patches = [ ./reiserfsprogs-ar-fix.patch ];
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ libuuid ];
+
+  NIX_CFLAGS_COMPILE = "-std=gnu90";
+
+  meta = {
+    inherit version;
+    homepage = http://www.namesys.com/;
+    description = "ReiserFS utilities";
+    license = stdenv.lib.licenses.gpl2;
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/reiserfsprogs-ar-fix.patch b/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/reiserfsprogs-ar-fix.patch
new file mode 100644
index 000000000000..356782a3d984
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/reiserfsprogs/reiserfsprogs-ar-fix.patch
@@ -0,0 +1,10 @@
+--- reiserfsprogs-3.6.24/configure.ac.orig	2018-11-29 17:16:52.313624894 +0300
++++ reiserfsprogs-3.6.24/configure.ac	2018-11-29 17:16:54.480669132 +0300
+@@ -21,6 +21,7 @@
+ AC_PROG_LN_S
+ AC_PROG_MAKE_SET
+ AC_PROG_RANLIB
++AM_PROG_AR
+ 
+ dnl Checks for libraries.
+ 
diff --git a/nixpkgs/pkgs/tools/filesystems/relfs/default.nix b/nixpkgs/pkgs/tools/filesystems/relfs/default.nix
new file mode 100644
index 000000000000..04a15dfa22be
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/relfs/default.nix
@@ -0,0 +1,51 @@
+{ stdenv, fetchcvs, ocaml, fuse, postgresql, pcre
+, libuuid, gnome_vfs, pkgconfig, GConf }:
+
+stdenv.mkDerivation rec {
+	name = "relfs-2008.03.05";
+
+	src = fetchcvs {
+		cvsRoot = ":pserver:anonymous@relfs.cvs.sourceforge.net:/cvsroot/relfs";
+		module = "relfs";
+		date = "2008-03-05";
+		sha256 = "949f8eff7e74ff2666cccf8a1efbfcce8d54bc41bec6ad6db8c029de7ca832a3";
+	};
+
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [ ocaml fuse postgresql pcre libuuid gnome_vfs GConf ];
+
+  buildPhase = ''
+    cd deps
+		sed -e 's/^CPP/#&/ ; s/^# CPP=gcc/CPP=gcc/' -i Makefile.camlidl
+		make
+		cd ../src
+		sed -e 's/NULL\\|FALSE/0/g' -i Mimetype_lib.c
+		sed -e 's@/usr/local/@'\$out/'@' -i Makefile
+		sed -e '/install:/a\\\tmkdir -p '\$out'/share' -i Makefile
+		make
+		mkdir -p \$out/bin
+		echo '
+		  createuser -A -D \$1
+			dropdb relfs_\$1 ;
+			rm -rf /tmp/relfs-\$1-tmp;
+			mkdir /tmp/relfs-\$1-tmp;
+			USER=\$1 relfs -f -s /tmp/relfs-\$1-tmp  &
+			sleep 1 &&
+			kill -15 \''${!};
+			rm -rf /tmp/relfs-\$1-tmp ;
+			psql -d relfs_\$1 <<< \"ALTER DATABASE relfs_\$1 OWNER TO \$1;
+				ALTER TABLE obj OWNER TO \$1;
+				ALTER TABLE obj_mimetype OWNER TO \$1;
+				ALTER TABLE membership OWNER TO \$1;\"' > \$out/bin/relfs_grant;
+		chmod a+x \$out/bin/relfs_grant;
+  '';
+
+	meta = with stdenv.lib; {
+		description = "A relational filesystem on top of FUSE";
+    homepage = http://relfs.sourceforge.net;
+    license = licenses.gpl2;
+    maintainers = [ maintainers.raskin ];
+    platforms = platforms.linux;
+    broken = true;
+	};
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/s3backer/default.nix b/nixpkgs/pkgs/tools/filesystems/s3backer/default.nix
new file mode 100644
index 000000000000..16ecb1c9d153
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/s3backer/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub
+, autoreconfHook, pkgconfig
+, fuse, curl, expat }:
+
+stdenv.mkDerivation rec {
+  name = "s3backer-${version}";
+  version = "1.5.0";
+
+  src = fetchFromGitHub {
+    sha256 = "0pmszcnnlqyysljfyysd6jsvdz7fqgbk8z4vnkmda5dwwcm8b8fs";
+    rev = version;
+    repo = "s3backer";
+    owner = "archiecobbs";
+  };
+
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+  buildInputs = [ fuse curl expat ];
+
+  autoreconfPhase = ''
+    patchShebangs ./autogen.sh
+    ./autogen.sh
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/archiecobbs/s3backer;
+    description = "FUSE-based single file backing store via Amazon S3";
+    license = licenses.gpl2Plus;
+    platforms = with platforms; linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/s3fs/default.nix b/nixpkgs/pkgs/tools/filesystems/s3fs/default.nix
new file mode 100644
index 000000000000..4d71d501b3c1
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/s3fs/default.nix
@@ -0,0 +1,30 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, curl, openssl, libxml2, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "s3fs-fuse-${version}";
+  version = "1.84";
+
+  src = fetchFromGitHub {
+    owner  = "s3fs-fuse";
+    repo   = "s3fs-fuse";
+    rev    = "v${version}";
+    sha256 = "1iafzlrqrjyphd1p74q5xzhgacc4gzijq8f6mdkvikbdsibch871";
+  };
+
+  buildInputs = [ curl openssl libxml2 fuse ];
+  nativeBuildInputs = [ autoreconfHook pkgconfig ];
+
+  configureFlags = [
+    "--with-openssl"
+  ];
+
+  postInstall = ''
+    ln -s $out/bin/s3fs $out/bin/mount.s3fs
+  '';
+
+  meta = with stdenv.lib; {
+    description = "Mount an S3 bucket as filesystem through FUSE";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/securefs/default.nix b/nixpkgs/pkgs/tools/filesystems/securefs/default.nix
new file mode 100644
index 000000000000..37eb8b9aa72c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/securefs/default.nix
@@ -0,0 +1,37 @@
+{ stdenv, fetchFromGitHub
+, cmake
+, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "securefs-${version}";
+  version = "0.8.2";
+
+  src = fetchFromGitHub {
+    sha256 = "0m3nv748g31b5nzxbwqqqjvygmz41x9vmhrjh655086g26gzrfib";
+    rev = version;
+    repo = "securefs";
+    owner = "netheril96";
+  };
+
+  nativeBuildInputs = [ cmake ];
+  buildInputs = [ fuse ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "Transparent encryption filesystem";
+    longDescription = ''
+      Securefs is a filesystem in userspace (FUSE) that transparently encrypts
+      and authenticates data stored. It is particularly designed to secure
+      data stored in the cloud.
+      Securefs mounts a regular directory onto a mount point. The mount point
+      appears as a regular filesystem, where one can read/write/create files,
+      directories and symbolic links. The underlying directory will be
+      automatically updated to contain the encrypted and authenticated
+      contents.
+    '';
+    license = with licenses; [ bsd2 mit ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/simg2img/default.nix b/nixpkgs/pkgs/tools/filesystems/simg2img/default.nix
new file mode 100644
index 000000000000..94c45ec4689a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/simg2img/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, zlib }:
+
+stdenv.mkDerivation rec {
+  name = "simg2img-${version}";
+  version = "1.1.3";
+
+  src = fetchFromGitHub {
+    owner = "anestisb";
+    repo = "android-simg2img";
+    rev = "${version}";
+    sha256 = "119gl9i61g2wr07hzv6mi1ihql6yd6pwq94ki2pgcpfbamv8f6si";
+  };
+
+  buildInputs = [ zlib ];
+
+  makeFlags = [ "PREFIX=$(out)" ];
+
+  meta = with stdenv.lib; {
+    description = "Tool to convert Android sparse images to raw images";
+    homepage = "https://github.com/anestisb/android-simg2img";
+    license = licenses.asl20;
+    platforms = platforms.linux;
+    maintainers = [ maintainers.dezgeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.nix b/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.nix
new file mode 100644
index 000000000000..8a9af4ba13c1
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, fetchurl, fuse, samba, pkgconfig, glib, autoconf, attr, libsecret }:
+
+stdenv.mkDerivation rec {
+  name = "smbnetfs-${version}";
+  version = "0.6.1";
+  src = fetchurl {
+    url = "mirror://sourceforge/project/smbnetfs/smbnetfs/SMBNetFS-${version}/${name}.tar.bz2";
+    sha256 = "02iqjnm6pdwc1q38z56akiwdbp0xisr6qwrmxs1lrk5mq7j8x2w4";
+  };
+
+  nativeBuildInputs = [ pkgconfig autoconf ];
+  buildInputs = [ fuse samba glib attr libsecret ];
+
+  meta = with stdenv.lib; {
+    description = "A FUSE FS for mounting Samba shares";
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+    downloadPage = "https://sourceforge.net/projects/smbnetfs/files/smbnetfs";
+    updateWalker = true;
+    inherit version;
+    homepage = https://sourceforge.net/projects/smbnetfs/;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.upstream b/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.upstream
new file mode 100644
index 000000000000..d56fa42f1d1b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/smbnetfs/default.upstream
@@ -0,0 +1,6 @@
+url https://sourceforge.net/projects/smbnetfs/files/smbnetfs/
+version_link '[-][0-9.]+[a-z]*/$'
+version_link '[.]tar[.][a-z0-9]+/download$'
+SF_redirect
+version '.*[-]([0-9.]+[a-z]*)[.]tar[.].*' '\1'
+do_overwrite () { do_overwrite_just_version; }
diff --git a/nixpkgs/pkgs/tools/filesystems/snapraid/default.nix b/nixpkgs/pkgs/tools/filesystems/snapraid/default.nix
new file mode 100644
index 000000000000..725ff3e56dcd
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/snapraid/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchFromGitHub, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "snapraid-${version}";
+  version = "11.3";
+
+  src = fetchFromGitHub {
+    owner = "amadvance";
+    repo = "snapraid";
+    rev = "v${version}";
+    sha256 = "08rwz55njkr1w794y3hs8nxc11vzbv4drds9wgxpf6ps8qf9q49f";
+  };
+
+  VERSION = version;
+
+  doCheck = true;
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ ];
+
+  meta = {
+    homepage = http://www.snapraid.it/;
+    description = "A backup program for disk arrays";
+    license = stdenv.lib.licenses.gpl3;
+    maintainers = [ stdenv.lib.maintainers.makefu ];
+    platforms = stdenv.lib.platforms.unix;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch b/nixpkgs/pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
new file mode 100644
index 000000000000..5626800e723c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
@@ -0,0 +1,90 @@
+From 0ab12a8585373be2de5129e14d979c62e7a90d82 Mon Sep 17 00:00:00 2001
+From: Chris Lamb <lamby@debian.org>
+Date: Mon, 21 Nov 2016 09:33:05 +0100
+Subject: [PATCH] If SOURCE_DATE_EPOCH is set, override timestamps with that
+ value.
+
+See https://reproducible-builds.org/specs/source-date-epoch/ for more
+information about this environment variable.
+
+Based on a patch by Alexander Couzens <lynxis@fe...> posted on
+https://sourceforge.net/p/squashfs/mailman/message/34673610/
+
+Signed-off-by: Chris Lamb <lamby@debian.org>
+---
+ squashfs-tools/mksquashfs.c | 38 ++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 37 insertions(+), 1 deletion(-)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index c2098bd..b49e956 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -137,6 +137,9 @@ unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
+ /* inode lookup table */
+ squashfs_inode *inode_lookup_table = NULL;
+ 
++/* override filesystem creation time */
++time_t mkfs_fixed_time = -1;
++
+ /* in memory directory data */
+ #define I_COUNT_SIZE		128
+ #define DIR_ENTRIES		32
+@@ -5104,6 +5107,9 @@ int main(int argc, char *argv[])
+ 	int total_mem = get_default_phys_mem();
+ 	int progress = TRUE;
+ 	int force_progress = FALSE;
++	char *source_date_epoch, *endptr;
++	unsigned long long epoch;
++
+ 	struct file_buffer **fragment = NULL;
+ 
+ 	if(argc > 1 && strcmp(argv[1], "-version") == 0) {
+@@ -5641,6 +5647,36 @@ printOptions:
+ 		}
+ 	}
+ 
++	/* if SOURCE_DATE_EPOCH is set, use that timestamp for the mkfs time */
++	source_date_epoch = getenv("SOURCE_DATE_EPOCH");
++	if(source_date_epoch) {
++		errno = 0;
++		epoch = strtoull(source_date_epoch, &endptr, 10);
++		if((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
++				|| (errno != 0 && epoch == 0)) {
++			ERROR("Environment variable $SOURCE_DATE_EPOCH: "
++				"strtoull: %s\n", strerror(errno));
++			EXIT_MKSQUASHFS();
++		}
++		if(endptr == source_date_epoch) {
++			ERROR("Environment variable $SOURCE_DATE_EPOCH: "
++				"No digits were found: %s\n", endptr);
++			EXIT_MKSQUASHFS();
++		}
++		if(*endptr != '\0') {
++			ERROR("Environment variable $SOURCE_DATE_EPOCH: "
++				"Trailing garbage: %s\n", endptr);
++			EXIT_MKSQUASHFS();
++		}
++		if(epoch > ULONG_MAX) {
++			ERROR("Environment variable $SOURCE_DATE_EPOCH: "
++				"value must be smaller than or equal to "
++				"%lu but was found to be: %llu \n", ULONG_MAX, epoch);
++			EXIT_MKSQUASHFS();
++		}
++		mkfs_fixed_time = (time_t)epoch;
++	}
++
+ 	/*
+ 	 * Some compressors may need the options to be checked for validity
+ 	 * once all the options have been processed
+@@ -5993,7 +6029,7 @@ printOptions:
+	sBlk.flags = SQUASHFS_MKFLAGS(noI, noD, noF, noX, no_fragments,
+		always_use_fragments, duplicate_checking, exportable,
+		no_xattrs, comp_opts);
+-	sBlk.mkfs_time = time(NULL);
++	sBlk.mkfs_time = mkfs_fixed_time != -1 ? mkfs_fixed_time : time(NULL);
+ 
+ 	disable_info();
+ 
+-- 
+2.17.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch b/nixpkgs/pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
new file mode 100644
index 000000000000..5002375887fb
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
@@ -0,0 +1,83 @@
+From 32a07d4156a281084c90a4b78affc8b0b32a26fc Mon Sep 17 00:00:00 2001
+From: intrigeri <intrigeri@boum.org>
+Date: Mon, 21 Nov 2016 11:41:28 +0000
+Subject: [PATCH] If SOURCE_DATE_EPOCH is set, also clamp content timestamps
+ with that value.
+
+Based on a patch by Alexander Couzens <lynxis@fe...> posted on
+https://sourceforge.net/p/squashfs/mailman/message/34673610/
+---
+ squashfs-tools/mksquashfs.c | 15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index b49e956..9f020bf 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -137,6 +137,9 @@ unsigned int cache_bytes = 0, cache_size = 0, inode_count = 0;
+ /* inode lookup table */
+ squashfs_inode *inode_lookup_table = NULL;
+ 
++/* clamp all timestamps to SOURCE_DATE_EPOCH */
++time_t content_clamp_time = -1;
++
+ /* override filesystem creation time */
+ time_t mkfs_fixed_time = -1;
+ 
+@@ -2246,6 +2249,8 @@ restat:
+ 			  pathname_reader(dir_ent), strerror(errno));
+ 		goto read_err;
+ 	}
++	if(content_clamp_time != -1 && buf2.st_mtime >= content_clamp_time)
++		buf2.st_mtime = content_clamp_time;
+ 
+ 	if(read_size != buf2.st_size) {
+ 		close(file);
+@@ -3101,7 +3106,7 @@ void dir_scan(squashfs_inode *inode, char *pathname,
+ 		buf.st_mode = S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR;
+ 		buf.st_uid = getuid();
+ 		buf.st_gid = getgid();
+-		buf.st_mtime = time(NULL);
++		buf.st_mtime = content_clamp_time != -1 ? content_clamp_time : time(NULL);
+ 		buf.st_dev = 0;
+ 		buf.st_ino = 0;
+ 		dir_ent->inode = lookup_inode2(&buf, PSEUDO_FILE_OTHER, 0);
+@@ -3127,6 +3115,8 @@ void dir_scan(squashfs_inode *inode, char *pathname,
+			/* source directory has disappeared? */
+			BAD_ERROR("Cannot stat source directory %s because %s\n",
+				pathname, strerror(errno));
++		if(content_clamp_time != -1 && buf.st_mtime >= content_clamp_time)
++			buf.st_mtime = content_clamp_time;
+ 		dir_ent->inode = lookup_inode(&buf);
+ 	}
+ 
+@@ -3365,6 +3372,8 @@ struct dir_info *dir_scan1(char *filename, char *subpath,
+ 			free_dir_entry(dir_ent);
+ 			continue;
+ 		}
++		if(content_clamp_time != -1 && buf.st_mtime >= content_clamp_time)
++			buf.st_mtime = content_clamp_time;
+ 
+ 		if((buf.st_mode & S_IFMT) != S_IFREG &&
+ 				(buf.st_mode & S_IFMT) != S_IFDIR &&
+@@ -3544,7 +3553,7 @@ void dir_scan2(struct dir_info *dir, struct pseudo *pseudo)
+		buf.st_gid = pseudo_ent->dev->gid;
+		buf.st_rdev = makedev(pseudo_ent->dev->major,
+			pseudo_ent->dev->minor);
+-		buf.st_mtime = time(NULL);
++		buf.st_mtime = content_clamp_time != -1 ? content_clamp_time : time(NULL);
+ 		buf.st_ino = pseudo_ino ++;
+ 
+ 		if(pseudo_ent->dev->type == 'd') {
+@@ -5674,7 +5683,7 @@ printOptions:
+ 				"%lu but was found to be: %llu \n", ULONG_MAX, epoch);
+ 			EXIT_MKSQUASHFS();
+ 		}
+-		mkfs_fixed_time = (time_t)epoch;
++		mkfs_fixed_time = content_clamp_time = (time_t)epoch;
+ 	}
+ 
+ 	/*
+-- 
+2.17.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patch b/nixpkgs/pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patch
new file mode 100644
index 000000000000..4be4b96369a8
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/0003-remove-frag-deflator-thread.patch
@@ -0,0 +1,220 @@
+From afc0c76a170bd17cbd29bbec6ae6d2227e398570 Mon Sep 17 00:00:00 2001
+From: Alexander Couzens <lynxis@fe80.eu>
+Date: Fri, 13 Jan 2017 22:00:37 +0100
+Subject: [PATCH] remove frag_deflator_thread
+
+frag_deflator_thread compress fragments.
+Replace the deflator_thread with a function and
+use the function instead of the to_frag queue.
+---
+ squashfs-tools/info.c       |  5 ---
+ squashfs-tools/mksquashfs.c | 76 +++++++++++++------------------------
+ squashfs-tools/mksquashfs.h |  2 +-
+ squashfs-tools/restore.c    | 15 +-------
+ 4 files changed, 30 insertions(+), 68 deletions(-)
+
+diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
+index 7968c77..028d578 100644
+--- a/squashfs-tools/info.c
++++ b/squashfs-tools/info.c
+@@ -96,11 +96,6 @@ void dump_state()
+ 	printf("compressed block queue (deflate thread(s) -> main thread)\n");
+ 	dump_seq_queue(to_main, 0);
+ 
+-	printf("uncompressed packed fragment queue (main thread -> fragment"
+-						" deflate thread(s))\n");
+-	dump_queue(to_frag);
+-
+-
+ 	printf("locked frag queue (compressed frags waiting while multi-block"
+ 						" file is written)\n");
+ 	dump_queue(locked_fragment);
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index cf48e40..cacf14c 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -270,10 +270,10 @@ unsigned int sid_count = 0, suid_count = 0, sguid_count = 0;
+ struct cache *reader_buffer, *fragment_buffer, *reserve_cache;
+ struct cache *bwriter_buffer, *fwriter_buffer;
+ struct queue *to_reader, *to_deflate, *to_writer, *from_writer,
+-	*to_frag, *locked_fragment, *to_process_frag;
++	*locked_fragment, *to_process_frag;
+ struct seq_queue *to_main;
+ pthread_t reader_thread, writer_thread, main_thread;
+-pthread_t *deflator_thread, *frag_deflator_thread, *frag_thread;
++pthread_t *deflator_thread, *frag_thread;
+ pthread_t *restore_thread = NULL;
+ pthread_mutex_t	fragment_mutex = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_t	pos_mutex = PTHREAD_MUTEX_INITIALIZER;
+@@ -323,7 +323,7 @@ struct dir_info *scan1_opendir(char *pathname, char *subpath, int depth);
+ void write_filesystem_tables(struct squashfs_super_block *sBlk, int nopad);
+ unsigned short get_checksum_mem(char *buff, int bytes);
+ void check_usable_phys_mem(int total_mem);
+-
++void frag_deflator(struct file_buffer *file_buffer);
+ 
+ void prep_exit()
+ {
+@@ -1540,7 +1540,7 @@ void write_fragment(struct file_buffer *fragment)
+ 	pthread_mutex_lock(&fragment_mutex);
+ 	fragment_table[fragment->block].unused = 0;
+ 	fragments_outstanding ++;
+-	queue_put(to_frag, fragment);
++	frag_deflator(fragment);
+ 	pthread_cleanup_pop(1);
+ }
+ 
+@@ -2412,51 +2412,34 @@ void *deflator(void *arg)
+ }
+ 
+ 
+-void *frag_deflator(void *arg)
++void frag_deflator(struct file_buffer *file_buffer)
+ {
+-	void *stream = NULL;
+-	int res;
+ 
+-	res = compressor_init(comp, &stream, block_size, 1);
+-	if(res)
+-		BAD_ERROR("frag_deflator:: compressor_init failed\n");
+-
+-	pthread_cleanup_push((void *) pthread_mutex_unlock, &fragment_mutex);
+-
+-	while(1) {
+-		int c_byte, compressed_size;
+-		struct file_buffer *file_buffer = queue_get(to_frag);
+-		struct file_buffer *write_buffer =
++	int c_byte, compressed_size;
++	struct file_buffer *write_buffer =
+ 			cache_get(fwriter_buffer, file_buffer->block);
+ 
+-		c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
+-			file_buffer->size, block_size, noF, 1);
+-		compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
+-		write_buffer->size = compressed_size;
+-		pthread_mutex_lock(&fragment_mutex);
+-		if(fragments_locked == FALSE) {
+-			fragment_table[file_buffer->block].size = c_byte;
+-			fragment_table[file_buffer->block].start_block = bytes;
+-			write_buffer->block = bytes;
+-			bytes += compressed_size;
+-			fragments_outstanding --;
+-			queue_put(to_writer, write_buffer);
+-			pthread_mutex_unlock(&fragment_mutex);
+-			TRACE("Writing fragment %lld, uncompressed size %d, "
+-				"compressed size %d\n", file_buffer->block,
+-				file_buffer->size, compressed_size);
+-		} else {
+-				add_pending_fragment(write_buffer, c_byte,
+-					file_buffer->block);
+-				pthread_mutex_unlock(&fragment_mutex);
+-		}
+-		cache_block_put(file_buffer);
++	c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
++			 file_buffer->size, block_size, noF, 1);
++	compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
++	write_buffer->size = compressed_size;
++	if(fragments_locked == FALSE) {
++		fragment_table[file_buffer->block].size = c_byte;
++		fragment_table[file_buffer->block].start_block = bytes;
++		write_buffer->block = bytes;
++		bytes += compressed_size;
++		fragments_outstanding --;
++		queue_put(to_writer, write_buffer);
++		TRACE("Writing fragment %lld, uncompressed size %d, "
++		      "compressed size %d\n", file_buffer->block,
++		      file_buffer->size, compressed_size);
++	} else {
++		add_pending_fragment(write_buffer, c_byte,
++				     file_buffer->block);
+ 	}
+-
+-	pthread_cleanup_pop(0);
++	cache_block_put(file_buffer);
+ }
+ 
+-
+ struct file_buffer *get_file_buffer()
+ {
+ 	struct file_buffer *file_buffer = seq_queue_get(to_main);
+@@ -4257,19 +4240,17 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
+ 			multiply_overflow(processors * 3, sizeof(pthread_t)))
+ 		BAD_ERROR("Processors too large\n");
+ 
+-	deflator_thread = malloc(processors * 3 * sizeof(pthread_t));
++	deflator_thread = malloc(processors * 2 * sizeof(pthread_t));
+ 	if(deflator_thread == NULL)
+ 		MEM_ERROR();
+ 
+-	frag_deflator_thread = &deflator_thread[processors];
+-	frag_thread = &frag_deflator_thread[processors];
++	frag_thread = &deflator_thread[processors];
+ 
+ 	to_reader = queue_init(1);
+ 	to_deflate = queue_init(reader_size);
+ 	to_process_frag = queue_init(reader_size);
+ 	to_writer = queue_init(bwriter_size + fwriter_size);
+ 	from_writer = queue_init(1);
+-	to_frag = queue_init(fragment_size);
+ 	locked_fragment = queue_init(fragment_size);
+ 	to_main = seq_queue_init();
+ 	reader_buffer = cache_init(block_size, reader_size, 0, 0);
+@@ -4285,9 +4266,6 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
+ 	for(i = 0; i < processors; i++) {
+ 		if(pthread_create(&deflator_thread[i], NULL, deflator, NULL))
+ 			BAD_ERROR("Failed to create thread\n");
+-		if(pthread_create(&frag_deflator_thread[i], NULL, frag_deflator,
+-				NULL) != 0)
+-			BAD_ERROR("Failed to create thread\n");
+ 		if(pthread_create(&frag_thread[i], NULL, frag_thrd,
+ 				(void *) destination_file) != 0)
+ 			BAD_ERROR("Failed to create thread\n");
+diff --git a/squashfs-tools/mksquashfs.h b/squashfs-tools/mksquashfs.h
+index 55708a3..dc5bde4 100644
+--- a/squashfs-tools/mksquashfs.h
++++ b/squashfs-tools/mksquashfs.h
+@@ -135,7 +135,7 @@ struct append_file {
+ extern struct cache *reader_buffer, *fragment_buffer, *reserve_cache;
+ struct cache *bwriter_buffer, *fwriter_buffer;
+ extern struct queue *to_reader, *to_deflate, *to_writer, *from_writer,
+-	*to_frag, *locked_fragment, *to_process_frag;
++	*locked_fragment, *to_process_frag;
+ extern struct append_file **file_mapping;
+ extern struct seq_queue *to_main;
+ extern pthread_mutex_t fragment_mutex, dup_mutex;
+diff --git a/squashfs-tools/restore.c b/squashfs-tools/restore.c
+index 5e336b3..a7aaf2e 100644
+--- a/squashfs-tools/restore.c
++++ b/squashfs-tools/restore.c
+@@ -47,8 +47,8 @@
+ #define TRUE 1
+ 
+ extern pthread_t reader_thread, writer_thread, main_thread;
+-extern pthread_t *deflator_thread, *frag_deflator_thread, *frag_thread;
+-extern struct queue *to_deflate, *to_writer, *to_frag, *to_process_frag;
++extern pthread_t *deflator_thread, *frag_thread;
++extern struct queue *to_deflate, *to_writer, *to_process_frag;
+ extern struct seq_queue *to_main;
+ extern void restorefs();
+ extern int processors;
+@@ -120,17 +120,6 @@ void *restore_thrd(void *arg)
+ 		pthread_cancel(main_thread);
+ 		pthread_join(main_thread, NULL);
+ 
+-		/* then flush the main thread to fragment deflator thread(s)
+-		 * queue.  The fragment deflator thread(s) will idle
+-		 */
+-		queue_flush(to_frag);
+-
+-		/* now kill the fragment deflator thread(s) */
+-		for(i = 0; i < processors; i++)
+-			pthread_cancel(frag_deflator_thread[i]);
+-		for(i = 0; i < processors; i++)
+-			pthread_join(frag_deflator_thread[i], NULL);
+-
+ 		/*
+ 		 * then flush the main thread/fragment deflator thread(s)
+ 		 * to writer thread queue.  The writer thread will idle
+-- 
+2.17.0
+
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/darwin.patch b/nixpkgs/pkgs/tools/filesystems/squashfs/darwin.patch
new file mode 100644
index 000000000000..6022e65be479
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/darwin.patch
@@ -0,0 +1,431 @@
+diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
+index 4b06ccb..26365e7 100644
+--- a/squashfs-tools/action.c
++++ b/squashfs-tools/action.c
+@@ -38,6 +38,10 @@
+ #include <limits.h>
+ #include <errno.h>
+ 
++#ifndef FNM_EXTMATCH /* glibc extension */
++ #define FNM_EXTMATCH 0
++#endif
++
+ #include "squashfs_fs.h"
+ #include "mksquashfs.h"
+ #include "action.h"
+@@ -2284,9 +2288,12 @@ static char *get_start(char *s, int n)
+ 
+ static int subpathname_fn(struct atom *atom, struct action_data *action_data)
+ {
+-	return fnmatch(atom->argv[0], get_start(strdupa(action_data->subpath),
++	char *path = strdup(action_data->subpath);
++	int is_match = fnmatch(atom->argv[0], get_start(path,
+ 		count_components(atom->argv[0])),
+ 		FNM_PATHNAME|FNM_PERIOD|FNM_EXTMATCH) == 0;
++	free(path);
++	return is_match;
+ }
+ 
+ /*
+diff --git a/squashfs-tools/info.c b/squashfs-tools/info.c
+index 7968c77..c8e4c52 100644
+--- a/squashfs-tools/info.c
++++ b/squashfs-tools/info.c
+@@ -134,31 +134,22 @@ void dump_state()
+ void *info_thrd(void *arg)
+ {
+ 	sigset_t sigmask;
+-	struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
+-	int sig, waiting = 0;
++    int sig, err, waiting = 0;
+ 
+ 	sigemptyset(&sigmask);
+ 	sigaddset(&sigmask, SIGQUIT);
+ 	sigaddset(&sigmask, SIGHUP);
++    sigaddset(&sigmask, SIGALRM);
+ 
+ 	while(1) {
+-		if(waiting)
+-			sig = sigtimedwait(&sigmask, NULL, &timespec);
+-		else
+-			sig = sigwaitinfo(&sigmask, NULL);
++		err = sigwait(&sigmask, &sig);
+ 
+-		if(sig == -1) {
++		if(err == -1) {
+ 			switch(errno) {
+-			case EAGAIN:
+-				/* interval timed out */
+-				waiting = 0;
+-				/* FALLTHROUGH */
+ 			case EINTR:
+-				/* if waiting, the wait will be longer, but
+-				   that's OK */
+ 				continue;
+ 			default:
+-				BAD_ERROR("sigtimedwait/sigwaitinfo failed "
++				BAD_ERROR("sigwaitfailed "
+ 					"because %s\n", strerror(errno));
+ 			}
+ 		}
+@@ -169,8 +160,12 @@ void *info_thrd(void *arg)
+ 			/* set one second interval period, if ^\ received
+ 			   within then, dump queue and cache status */
+ 			waiting = 1;
+-		} else
++			alarm(1);
++		} else if (sig == SIGQUIT) {
+ 			dump_state();
++		} else if (sig == SIGALRM) {
++			waiting = 0;
++		}
+ 	}
+ }
+ 
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index d696a51..c86d1b3 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -50,6 +50,10 @@
+ #include <limits.h>
+ #include <ctype.h>
+ 
++#ifndef FNM_EXTMATCH /* glibc extension */
++    #define FNM_EXTMATCH 0
++#endif
++
+ #ifndef linux
+ #define __BYTE_ORDER BYTE_ORDER
+ #define __BIG_ENDIAN BIG_ENDIAN
+@@ -831,13 +835,13 @@ char *subpathname(struct dir_ent *dir_ent)
+ }
+ 
+ 
+-inline unsigned int get_inode_no(struct inode_info *inode)
++static inline unsigned int get_inode_no(struct inode_info *inode)
+ {
+ 	return inode->inode_number;
+ }
+ 
+ 
+-inline unsigned int get_parent_no(struct dir_info *dir)
++static inline unsigned int get_parent_no(struct dir_info *dir)
+ {
+ 	return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
+ }
+@@ -2030,7 +2034,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
+ }
+ 
+ 
+-inline int is_fragment(struct inode_info *inode)
++static inline int is_fragment(struct inode_info *inode)
+ {
+ 	off_t file_size = inode->buf.st_size;
+ 
+@@ -2999,13 +3003,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
+ }
+ 
+ 
+-inline struct inode_info *lookup_inode(struct stat *buf)
++static inline struct inode_info *lookup_inode(struct stat *buf)
+ {
+ 	return lookup_inode2(buf, 0, 0);
+ }
+ 
+ 
+-inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
++static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
+ {
+ 	if (inode->inode_number == 0) {
+ 		inode->inode_number = use_this ? : inode_no ++;
+@@ -3016,7 +3020,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
+ }
+ 
+ 
+-inline struct dir_ent *create_dir_entry(char *name, char *source_name,
++static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
+ 	char *nonstandard_pathname, struct dir_info *dir)
+ {
+ 	struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
+@@ -3034,7 +3038,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
+ }
+ 
+ 
+-inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
++static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
+ 	struct inode_info *inode_info)
+ {
+ 	struct dir_info *dir = dir_ent->our_dir;
+@@ -3050,7 +3054,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
+ }
+ 
+ 
+-inline void add_dir_entry2(char *name, char *source_name,
++static inline void add_dir_entry2(char *name, char *source_name,
+ 	char *nonstandard_pathname, struct dir_info *sub_dir,
+ 	struct inode_info *inode_info, struct dir_info *dir)
+ {
+@@ -3062,7 +3066,7 @@ inline void add_dir_entry2(char *name, char *source_name,
+ }
+ 
+ 
+-inline void free_dir_entry(struct dir_ent *dir_ent)
++static inline void free_dir_entry(struct dir_ent *dir_ent)
+ {
+ 	if(dir_ent->name)
+ 		free(dir_ent->name);
+@@ -3083,7 +3087,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
+ }
+ 
+ 
+-inline void add_excluded(struct dir_info *dir)
++static inline void add_excluded(struct dir_info *dir)
+ {
+ 	dir->excluded ++;
+ }
+@@ -4200,6 +4204,7 @@ void initialise_threads(int readq, int fragq, int bwriteq, int fwriteq,
+ 	sigemptyset(&sigmask);
+ 	sigaddset(&sigmask, SIGQUIT);
+ 	sigaddset(&sigmask, SIGHUP);
++	sigaddset(&sigmask, SIGALRM);
+ 	if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
+ 		BAD_ERROR("Failed to set signal mask in intialise_threads\n");
+ 
+@@ -4987,6 +4992,36 @@ int parse_num(char *arg, int *res)
+ 
+ int get_physical_memory()
+ {
++	int phys_mem;
++#ifndef linux
++	#ifdef HW_MEMSIZE
++		#define SYSCTL_PHYSMEM HW_MEMSIZE
++	#elif defined(HW_PHYSMEM64)
++		#define SYSCTL_PHYSMEM HW_PHYSMEM64
++	#else
++		#define SYSCTL_PHYSMEM HW_PHYSMEM
++	#endif
++
++	int mib[2];
++	uint64_t sysctl_physmem = 0;
++	size_t sysctl_len = sizeof(sysctl_physmem);
++
++	mib[0] = CTL_HW;
++	mib[1] = SYSCTL_PHYSMEM;
++
++	if(sysctl(mib, 2, &sysctl_physmem, &sysctl_len, NULL, 0) == 0) {
++		/* some systems use 32-bit values, work with what we're given */
++		if (sysctl_len == 4)
++			sysctl_physmem = *(uint32_t*)&sysctl_physmem;
++		phys_mem = sysctl_physmem >> 20;
++	} else {
++		ERROR_START("Failed to get amount of available "
++			"memory.");
++		ERROR_EXIT("  Defaulting to least viable amount\n");
++		phys_mem = SQUASHFS_LOWMEM;
++	}
++	#undef SYSCTL_PHYSMEM
++#else
+ 	/*
+ 	 * Long longs are used here because with PAE, a 32-bit
+ 	 * machine can have more than 4GB of physical memory
+@@ -4996,10 +5031,11 @@ int get_physical_memory()
+ 	 */
+ 	long long num_pages = sysconf(_SC_PHYS_PAGES);
+ 	long long page_size = sysconf(_SC_PAGESIZE);
+-	int phys_mem = num_pages * page_size >> 20;
++	phys_mem = num_pages * page_size >> 20;
+ 
+ 	if(num_pages == -1 || page_size == -1)
+ 		return 0;
++#endif
+ 
+ 	if(phys_mem < SQUASHFS_LOWMEM)
+ 		BAD_ERROR("Mksquashfs requires more physical memory than is "
+diff --git a/squashfs-tools/mksquashfs.h b/squashfs-tools/mksquashfs.h
+index 55708a3..d44d1fd 100644
+--- a/squashfs-tools/mksquashfs.h
++++ b/squashfs-tools/mksquashfs.h
+@@ -24,6 +24,7 @@
+  * mksquashfs.h
+  *
+  */
++#include <pthread.h>
+ 
+ struct dir_info {
+ 	char			*pathname;
+diff --git a/squashfs-tools/pseudo.c b/squashfs-tools/pseudo.c
+index cb74cf6..fe2b4bc 100644
+--- a/squashfs-tools/pseudo.c
++++ b/squashfs-tools/pseudo.c
+@@ -30,6 +30,7 @@
+ #include <errno.h>
+ #include <string.h>
+ #include <stdlib.h>
++#include <sys/stat.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ #include <sys/stat.h>
+diff --git a/squashfs-tools/read_xattrs.c b/squashfs-tools/read_xattrs.c
+index 42106f5..837d3fb 100644
+--- a/squashfs-tools/read_xattrs.c
++++ b/squashfs-tools/read_xattrs.c
+@@ -39,13 +39,13 @@
+ #include <endian.h>
+ #endif
+ 
++#include <stdlib.h>
++
+ #include "squashfs_fs.h"
+ #include "squashfs_swap.h"
+ #include "xattr.h"
+ #include "error.h"
+ 
+-#include <stdlib.h>
+-
+ extern int read_fs_bytes(int, long long, int, void *);
+ extern int read_block(int, long long, long long *, int, void *);
+ 
+diff --git a/squashfs-tools/unsquashfs.c b/squashfs-tools/unsquashfs.c
+index f190e96..927e441 100644
+--- a/squashfs-tools/unsquashfs.c
++++ b/squashfs-tools/unsquashfs.c
+@@ -32,7 +32,12 @@
+ #include "stdarg.h"
+ #include "fnmatch_compat.h"
+ 
++#ifndef linux
++#include <sys/sysctl.h>
++#else
+ #include <sys/sysinfo.h>
++#endif
++
+ #include <sys/types.h>
+ #include <sys/time.h>
+ #include <sys/resource.h>
+@@ -2185,6 +2190,7 @@ void initialise_threads(int fragment_buffer_size, int data_buffer_size)
+ 	sigemptyset(&sigmask);
+ 	sigaddset(&sigmask, SIGQUIT);
+ 	sigaddset(&sigmask, SIGHUP);
++	sigaddset(&sigmask, SIGALRM);
+ 	if(pthread_sigmask(SIG_BLOCK, &sigmask, NULL) == -1)
+ 		EXIT_UNSQUASH("Failed to set signal mask in initialise_threads"
+ 			"\n");
+diff --git a/squashfs-tools/unsquashfs.h b/squashfs-tools/unsquashfs.h
+index 0edbd25..cea9caa 100644
+--- a/squashfs-tools/unsquashfs.h
++++ b/squashfs-tools/unsquashfs.h
+@@ -46,6 +46,10 @@
+ #include <sys/ioctl.h>
+ #include <sys/time.h>
+ 
++#ifndef FNM_EXTMATCH /* glibc extension */
++    #define FNM_EXTMATCH 0
++#endif
++
+ #ifndef linux
+ #define __BYTE_ORDER BYTE_ORDER
+ #define __BIG_ENDIAN BIG_ENDIAN
+diff --git a/squashfs-tools/unsquashfs_info.c b/squashfs-tools/unsquashfs_info.c
+index c8e2b9b..7d4f7af 100644
+--- a/squashfs-tools/unsquashfs_info.c
++++ b/squashfs-tools/unsquashfs_info.c
+@@ -97,31 +97,22 @@ void dump_state()
+ void *info_thrd(void *arg)
+ {
+ 	sigset_t sigmask;
+-	struct timespec timespec = { .tv_sec = 1, .tv_nsec = 0 };
+-	int sig, waiting = 0;
++	int sig, err, waiting = 0;
+ 
+ 	sigemptyset(&sigmask);
+ 	sigaddset(&sigmask, SIGQUIT);
+ 	sigaddset(&sigmask, SIGHUP);
++	sigaddset(&sigmask, SIGALRM);
+ 
+ 	while(1) {
+-		if(waiting)
+-			sig = sigtimedwait(&sigmask, NULL, &timespec);
+-		else
+-			sig = sigwaitinfo(&sigmask, NULL);
++		err = sigwait(&sigmask, &sig);
+ 
+-		if(sig == -1) {
++		if(err == -1) {
+ 			switch(errno) {
+-			case EAGAIN:
+-				/* interval timed out */
+-				waiting = 0;
+-				/* FALLTHROUGH */
+ 			case EINTR:
+-				/* if waiting, the wait will be longer, but
+-				   that's OK */
+ 				continue;
+ 			default:
+-				BAD_ERROR("sigtimedwait/sigwaitinfo failed "
++				BAD_ERROR("sigwait failed "
+ 					"because %s\n", strerror(errno));
+ 			}
+ 		}
+@@ -133,8 +124,12 @@ void *info_thrd(void *arg)
+ 			/* set one second interval period, if ^\ received
+ 			   within then, dump queue and cache status */
+ 			waiting = 1;
+-		} else
++			alarm(1);
++		} else if (sig == SIGQUIT) {
+ 			dump_state();
++		} else if (sig == SIGALRM) {
++			waiting = 0;
++		}
+ 	}
+ }
+ 
+diff --git a/squashfs-tools/unsquashfs_xattr.c b/squashfs-tools/unsquashfs_xattr.c
+index 59f4aae..13f0e35 100644
+--- a/squashfs-tools/unsquashfs_xattr.c
++++ b/squashfs-tools/unsquashfs_xattr.c
+@@ -27,6 +27,11 @@
+ 
+ #include <sys/xattr.h>
+ 
++#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
++    #define lsetxattr(path_, name_, val_, sz_, flags_) \
++        setxattr(path_, name_, val_, sz_, 0, flags_ | XATTR_NOFOLLOW)
++#endif
++
+ #define NOSPACE_MAX 10
+ 
+ extern int root_process;
+diff --git a/squashfs-tools/xattr.c b/squashfs-tools/xattr.c
+index b46550c..5b32eca 100644
+--- a/squashfs-tools/xattr.c
++++ b/squashfs-tools/xattr.c
+@@ -22,6 +22,14 @@
+  * xattr.c
+  */
+ 
++#ifndef linux
++#define __BYTE_ORDER BYTE_ORDER
++#define __BIG_ENDIAN BIG_ENDIAN
++#define __LITTLE_ENDIAN LITTLE_ENDIAN
++#else
++#include <endian.h>
++#endif
++
+ #define TRUE 1
+ #define FALSE 0
+ 
+@@ -36,6 +44,13 @@
+ #include <stdlib.h>
+ #include <sys/xattr.h>
+ 
++#ifdef XATTR_NOFOLLOW /* Apple's xattrs */
++    #define llistxattr(path_, buf_, sz_) \
++        listxattr(path_, buf_, sz_, XATTR_NOFOLLOW)
++    #define lgetxattr(path_, name_, val_, sz_) \
++        getxattr(path_, name_, val_, sz_, 0, XATTR_NOFOLLOW)
++#endif
++
+ #include "squashfs_fs.h"
+ #include "squashfs_swap.h"
+ #include "mksquashfs.h"
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/default.nix b/nixpkgs/pkgs/tools/filesystems/squashfs/default.nix
new file mode 100644
index 000000000000..389a614f54b0
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/default.nix
@@ -0,0 +1,48 @@
+{ stdenv, fetchFromGitHub, zlib, xz
+, lz4 ? null
+, lz4Support ? false
+}:
+
+assert lz4Support -> (lz4 != null);
+
+stdenv.mkDerivation rec {
+  name = "squashfs-4.4dev";
+
+  src = fetchFromGitHub {
+    owner = "plougher";
+    repo = "squashfs-tools";
+    sha256 = "059pa2shdysr3zfmwrhq28s12zbi5nyzbpzyaf5lmspgfh1493ks";
+    rev = "9c1db6d13a51a2e009f0027ef336ce03624eac0d";
+  };
+
+  patches = [
+    # These patches ensures that mksquashfs output is reproducible.
+    # See also https://reproducible-builds.org/docs/system-images/
+    # and https://github.com/NixOS/nixpkgs/issues/40144.
+    ./0001-If-SOURCE_DATE_EPOCH-is-set-override-timestamps-with.patch
+    ./0002-If-SOURCE_DATE_EPOCH-is-set-also-clamp-content-times.patch
+    ./0003-remove-frag-deflator-thread.patch
+
+    # This patch adds an option to pad filesystems (increasing size) in
+    # exchange for better chunking / binary diff calculation.
+    ./squashfs-tools-4.3-4k-align.patch
+  ] ++ stdenv.lib.optional stdenv.isDarwin ./darwin.patch;
+
+  buildInputs = [ zlib xz ]
+    ++ stdenv.lib.optional lz4Support lz4;
+
+  preBuild = "cd squashfs-tools";
+
+  installFlags = "INSTALL_DIR=\${out}/bin";
+
+  makeFlags = [ "XZ_SUPPORT=1" ]
+    ++ stdenv.lib.optional lz4Support "LZ4_SUPPORT=1";
+
+  meta = {
+    homepage = http://squashfs.sourceforge.net/;
+    description = "Tool for creating and unpacking squashfs filesystems";
+    platforms = stdenv.lib.platforms.unix;
+    license = stdenv.lib.licenses.gpl2Plus;
+    maintainers = with stdenv.lib.maintainers; [ ruuda ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfs/squashfs-tools-4.3-4k-align.patch b/nixpkgs/pkgs/tools/filesystems/squashfs/squashfs-tools-4.3-4k-align.patch
new file mode 100644
index 000000000000..b7c949182e0b
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfs/squashfs-tools-4.3-4k-align.patch
@@ -0,0 +1,92 @@
+From 7bda7c75748f36b0a50f93e46144d5a4de4974ad Mon Sep 17 00:00:00 2001
+From: Amin Hassani <ahassani@google.com>
+Date: Thu, 15 Dec 2016 10:43:15 -0800
+Subject: [PATCH] mksquashfs 4K aligns the files inside the squashfs image
+
+Files inside a squashfs image are not necessarily 4k (4096)
+aligned. This patch starts each file in a 4k aligned address and pads
+zero to the end of the file until it reaches the next 4k aligned
+address. This will not change the size of the compressed
+blocks (especially the last one) and hence it will not change how the
+files are being loaded in kernel or unsquashfs. However on average this
+increases the size of the squashfs image which can be calculated by the
+following formula:
+
+increased_size = (number_of_unfragmented_files_in_image + number of fragments) * 2048
+
+The 4k alignment can be enabled by flag '-4k-align'
+---
+ squashfs-tools/mksquashfs.c | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
+index 8b1376f..683973d 100644
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -99,6 +99,8 @@ int old_exclude = TRUE;
+ int use_regex = FALSE;
+ int nopad = FALSE;
+ int exit_on_error = FALSE;
++int do_4k_align = FALSE;
++#define ALIGN_UP(bytes, size) (bytes = (bytes + size - 1) & ~(size - 1))
+ 
+ long long global_uid = -1, global_gid = -1;
+ 
+@@ -1513,6 +1515,9 @@ void unlock_fragments()
+ 	 * queue at this time.
+ 	 */
+ 	while(!queue_empty(locked_fragment)) {
++		// 4k align the start of remaining queued fragments.
++		if(do_4k_align)
++			ALIGN_UP(bytes, 4096);
+ 		write_buffer = queue_get(locked_fragment);
+ 		frg = write_buffer->block;	
+ 		size = SQUASHFS_COMPRESSED_SIZE_BLOCK(fragment_table[frg].size);
+@@ -2420,6 +2420,9 @@
+ 	compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
+ 	write_buffer->size = compressed_size;
+ 	if(fragments_locked == FALSE) {
++		// 4k align the start of each fragment.
++		if(do_4k_align)
++			ALIGN_UP(bytes, 4096);
+ 		fragment_table[file_buffer->block].size = c_byte;
+ 		fragment_table[file_buffer->block].start_block = bytes;
+ 		write_buffer->block = bytes;
+@@ -2761,6 +2769,10 @@ int write_file_blocks(squashfs_inode *inode, struct dir_ent *dir_ent,
+ 	long long sparse = 0;
+ 	struct file_buffer *fragment_buffer = NULL;
+ 
++	// 4k align the start of each file.
++	if(do_4k_align)
++		ALIGN_UP(bytes, 4096);
++
+ 	if(pre_duplicate(read_size))
+ 		return write_file_blocks_dup(inode, dir_ent, read_buffer, dup);
+ 
+@@ -4692,6 +4704,7 @@ void write_filesystem_tables(struct squashfs_super_block *sBlk, int nopad)
+ 		"compressed", no_fragments ? "no" : noF ? "uncompressed" :
+ 		"compressed", no_xattrs ? "no" : noX ? "uncompressed" :
+ 		"compressed");
++	printf("\t4k %saligned\n", do_4k_align ? "" : "un");
+ 	printf("\tduplicates are %sremoved\n", duplicate_checking ? "" :
+ 		"not ");
+ 	printf("Filesystem size %.2f Kbytes (%.2f Mbytes)\n", bytes / 1024.0,
+@@ -5346,6 +5359,8 @@ print_compressor_options:
+ 			root_name = argv[i];
+ 		} else if(strcmp(argv[i], "-version") == 0) {
+ 			VERSION();
++		} else if(strcmp(argv[i], "-4k-align") == 0) {
++			do_4k_align = TRUE;
+ 		} else {
+ 			ERROR("%s: invalid option\n\n", argv[0]);
+ printOptions:
+@@ -5387,6 +5402,7 @@ printOptions:
+ 			ERROR("\t\t\tdirectory containing that directory, "
+ 				"rather than the\n");
+ 			ERROR("\t\t\tcontents of the directory\n");
++			ERROR("-4k-align\t\tenables 4k alignment of all files\n");
+ 			ERROR("\nFilesystem filter options:\n");
+ 			ERROR("-p <pseudo-definition>\tAdd pseudo file "
+ 				"definition\n");
+-- 
+2.14.1.480.gb18f417b89-goog (previously; hand-patched by charles-dyfis-net)
diff --git a/nixpkgs/pkgs/tools/filesystems/squashfuse/default.nix b/nixpkgs/pkgs/tools/filesystems/squashfuse/default.nix
new file mode 100644
index 000000000000..d7d917d5e9fb
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/squashfuse/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchFromGitHub, autoreconfHook, libtool, fuse,
+  pkgconfig, lz4, xz, zlib, lzo, zstd }:
+
+with stdenv.lib;
+
+stdenv.mkDerivation rec {
+
+  pname = "squashfuse";
+  version = "0.1.103";
+  name = "${pname}-${version}";
+
+  meta = {
+    description = "FUSE filesystem to mount squashfs archives";
+    homepage = https://github.com/vasi/squashfuse;
+    maintainers = [ maintainers.genesis ];
+    platforms = platforms.linux;
+    license = "BSD-2-Clause";
+  };
+
+  # platforms.darwin should be supported : see PLATFORMS file in src.
+  # we could use a nix fuseProvider, and let the derivation choose the OS
+  # specific implementation.
+
+  src = fetchFromGitHub {
+    owner = "vasi";
+    repo  = "${pname}";
+    rev = "540204955134eee44201d50132a5f66a246bcfaf";
+    sha256 = "07jv4qjjz9ky3mw3p5prgs19g1bna9dcd7jjdz8083s1wyipdgcq";
+  };
+
+  nativeBuildInputs = [ autoreconfHook libtool pkgconfig ];
+  buildInputs = [ lz4 xz zlib lzo zstd fuse ];
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/sshfs-fuse/default.nix b/nixpkgs/pkgs/tools/filesystems/sshfs-fuse/default.nix
new file mode 100644
index 000000000000..1a24cf7e75c4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/sshfs-fuse/default.nix
@@ -0,0 +1,49 @@
+{ stdenv, fetchFromGitHub, meson, pkgconfig, ninja, docutils
+, fuse3, glib
+, which, python3Packages
+}:
+
+stdenv.mkDerivation rec {
+  version = "3.5.1";
+  name = "sshfs-fuse-${version}";
+
+  src = fetchFromGitHub {
+    owner = "libfuse";
+    repo = "sshfs";
+    rev = "sshfs-${version}";
+    sha256 = "07ryavfbbzfxaswsbr8ifnnfn6g8yxgxam6mk6gvcskld6rkf6gd";
+  };
+
+  nativeBuildInputs = [ meson pkgconfig ninja docutils ];
+  buildInputs = [ fuse3 glib ];
+  checkInputs = [ which python3Packages.pytest ];
+
+  NIX_CFLAGS_COMPILE = stdenv.lib.optional
+    (stdenv.hostPlatform.system == "i686-linux")
+    "-D_FILE_OFFSET_BITS=64";
+
+  postInstall = ''
+    mkdir -p $out/sbin
+    ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
+  '';
+
+  #doCheck = true;
+  checkPhase = ''
+    # The tests need fusermount:
+    mkdir bin && cp ${fuse3}/bin/fusermount3 bin/fusermount
+    export PATH=bin:$PATH
+    # Can't access /dev/fuse within the sandbox: "FUSE kernel module does not seem to be loaded"
+    substituteInPlace test/util.py --replace "/dev/fuse" "/dev/null"
+    # TODO: "fusermount executable not setuid, and we are not root"
+    # We should probably use a VM test instead
+    python3 -m pytest test/
+  '';
+
+  meta = with stdenv.lib; {
+    inherit (src.meta) homepage;
+    description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH";
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+    maintainers = with maintainers; [ primeos ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/svnfs/default.nix b/nixpkgs/pkgs/tools/filesystems/svnfs/default.nix
new file mode 100644
index 000000000000..333714182177
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/svnfs/default.nix
@@ -0,0 +1,28 @@
+{ stdenv, fetchurl, automake, autoconf, subversion, fuse, apr, perl }: 
+
+stdenv.mkDerivation {
+  name = "svnfs-0.4";
+
+  src = fetchurl {
+    url = http://www.jmadden.eu/wp-content/uploads/svnfs/svnfs-0.4.tgz;
+    sha256 = "1lrzjr0812lrnkkwk60bws9k1hq2iibphm0nhqyv26axdsygkfky";
+  };
+
+  buildInputs = [automake autoconf subversion fuse apr perl];
+
+  # why is this required?
+  preConfigure=''
+    export LD_LIBRARY_PATH=${subversion.out}/lib
+  '';
+
+  NIX_CFLAGS_COMPILE="-I ${subversion.dev}/include/subversion-1";
+  NIX_LDFLAGS="-lsvn_client-1";
+
+  meta = {
+    description = "FUSE filesystem for accessing Subversion repositories";
+    homepage = http://www.jmadden.eu/index.php/svnfs/;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [stdenv.lib.maintainers.marcweber];
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/tmsu/default.nix b/nixpkgs/pkgs/tools/filesystems/tmsu/default.nix
new file mode 100644
index 000000000000..3c6dd2648ef6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/tmsu/default.nix
@@ -0,0 +1,61 @@
+{ stdenv, fetchgit, fetchFromGitHub, go, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "tmsu-${version}";
+  version = "0.7.1";
+
+  go-sqlite3 = fetchgit {
+    url = "git://github.com/mattn/go-sqlite3";
+    rev = "c9a0db5d8951646743317f0756da0339fe144dd5";
+    sha256 = "1m0q9869fis0dhg34g5wc5xi6pby491spfxi23w461h29higbrqh";
+  };
+
+  go-fuse = fetchgit {
+    url = "git://github.com/hanwen/go-fuse";
+    rev = "8c85ded140ac1889372a0e22d8d21e3d10a303bd";
+    sha256 = "1iph2hpvby2mfwqg9pp39xjqdl9a09h4442yfdn5l67pznljh2bi";
+  };
+
+  src = fetchFromGitHub {
+    owner = "oniony";
+    repo = "tmsu";
+    rev = "v${version}";
+    sha256 = "0d1sryq80chb9vrf9z0lfx4xb3sdkg01f9hqf3bb9c89vm6v2lwg";
+  };
+
+  buildInputs = [ go fuse ];
+
+  preBuild = ''
+    mkdir -p src/github.com/mattn/go-sqlite3/
+    ln -s ${go-sqlite3}/* src/github.com/mattn/go-sqlite3
+
+    mkdir -p src/github.com/hanwen/go-fuse
+    ln -s ${go-fuse}/* src/github.com/hanwen/go-fuse
+
+    mkdir -p src/github.com/oniony/tmsu
+    ln -s ${src}/* src/github.com/oniony/tmsu
+
+    patchShebangs tests/.
+
+    export GOPATH=$PWD
+  '';
+
+  installPhase = ''
+    mkdir -p $out/bin
+    mkdir -p $out/sbin
+    mkdir -p $out/share/man
+    mkdir -p $out/share/zsh/site-functions
+    make install INSTALL_DIR=$out/bin \
+                 MOUNT_INSTALL_DIR=$out/sbin \
+                 MAN_INSTALL_DIR=$out/share/man \
+                 ZSH_COMP_INSTALL_DIR=$out/share/zsh/site-functions
+  '';
+
+  meta = with stdenv.lib; {
+    homepage    = http://www.tmsu.org;
+    description = "A tool for tagging your files using a virtual filesystem";
+    maintainers = with maintainers; [ pSub ];
+    license     = licenses.gpl3;
+    platforms   = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/u3-tool/default.nix b/nixpkgs/pkgs/tools/filesystems/u3-tool/default.nix
new file mode 100644
index 000000000000..65eafe76710d
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/u3-tool/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, fetchurl }:
+
+stdenv.mkDerivation rec {
+  pname = "u3-tool";
+  version = "0.3";
+  name = "${pname}-${version}";
+
+  enableParallelBuilding = true;
+
+  src = fetchurl {
+    url = "mirror://sourceforge/${pname}/${name}.tar.gz";
+    sha256 = "1p9c9kibd1pdbdfa0nd0i3n7bvzi3xg0chm38jg3xfl8gsn0390f";
+  };
+
+  meta = with stdenv.lib; {
+    description = "Tool for controlling the special features of a 'U3 smart drive' USB Flash disk";
+    homepage = https://sourceforge.net/projects/u3-tool/ ;
+    license = licenses.gpl2;
+    platforms = with platforms; linux;
+    maintainers = with maintainers; [ makefu ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/udftools/default.nix b/nixpkgs/pkgs/tools/filesystems/udftools/default.nix
new file mode 100644
index 000000000000..f17f9e0d2de5
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/udftools/default.nix
@@ -0,0 +1,41 @@
+{ stdenv, fetchFromGitHub, ncurses, readline, autoreconfHook }:
+
+stdenv.mkDerivation rec {
+  name = "udftools-${version}";
+  version = "2.0";
+  src = fetchFromGitHub {
+    owner = "pali";
+    repo = "udftools";
+    rev = "${version}";
+    sha256 = "0mz04h3rki6ljwfs15z83gf4vv816w7xgz923waiqgmfj9xpvx87";
+  };
+
+  buildInputs = [ ncurses readline ];
+  nativeBuildInputs = [ autoreconfHook ];
+
+  hardeningDisable = [ "fortify" ];
+
+  NIX_CFLAGS_COMPILE = "-std=gnu90";
+
+  preConfigure = ''
+    sed -e '1i#include <limits.h>' -i cdrwtool/cdrwtool.c -i pktsetup/pktsetup.c
+    sed -e 's@[(]char[*][)]spm [+]=@spm = ((char*) spm) + @' -i wrudf/wrudf.c
+    sed -e '27i#include <string.h>' -i include/udf_endian.h
+    sed -e '38i#include <string.h>' -i wrudf/wrudf-cdrw.c
+    sed -e '12i#include <string.h>' -i wrudf/wrudf-cdr.c
+    sed -e '37i#include <stdlib.h>' -i wrudf/ide-pc.c
+
+    sed -e "s@\$(DESTDIR)/lib/udev/rules.d@$out/lib/udev/rules.d@" -i pktsetup/Makefile.am
+  '';
+
+  postFixup = ''
+    sed -i -e "s@/usr/sbin/pktsetup@$out/sbin/pktsetup@" $out/lib/udev/rules.d/80-pktsetup.rules
+  '';
+
+  meta = with stdenv.lib; {
+    description = "UDF tools";
+    maintainers = with maintainers; [ raskin ];
+    platforms = platforms.linux;
+    license = licenses.gpl2Plus;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/default.nix b/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/default.nix
new file mode 100644
index 000000000000..cfe3ff421fe4
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/default.nix
@@ -0,0 +1,44 @@
+{ stdenv, fetchFromGitHub, cmake, fuse }:
+
+stdenv.mkDerivation rec {
+  name = "unionfs-fuse-${version}";
+  version = "2.0";
+
+  src = fetchFromGitHub {
+    owner = "rpodgorny";
+    repo = "unionfs-fuse";
+    rev = "v${version}";
+    sha256 = "0lb8zgdxnjy2fjr2284hvdfn7inc1in44ynzgcr66x54bxzvynj6";
+  };
+
+  patches =
+    [ # Prevent the unionfs daemon from being killed during
+      # shutdown. See
+      # http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
+      # for details.
+      ./prevent-kill-on-shutdown.patch
+    ];
+
+  buildInputs = [ cmake fuse ];
+
+  # Put the unionfs mount helper in place as mount.unionfs-fuse. This makes it
+  # possible to do:
+  #   mount -t unionfs-fuse none /dest -o dirs=/source1=RW,/source2=RO
+  #
+  # This must be done in preConfigure because the build process removes
+  # helper from the source directory during the build.
+  preConfigure = ''
+    mkdir -p $out/sbin
+    cp -a mount.unionfs $out/sbin/mount.unionfs-fuse
+    substituteInPlace $out/sbin/mount.unionfs-fuse --replace mount.fuse ${fuse}/sbin/mount.fuse
+    substituteInPlace $out/sbin/mount.unionfs-fuse --replace unionfs $out/bin/unionfs
+  '';
+
+  meta = with stdenv.lib; {
+    description = "FUSE UnionFS implementation";
+    homepage = https://github.com/rpodgorny/unionfs-fuse;
+    license = licenses.bsd3;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ orivej ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/prevent-kill-on-shutdown.patch b/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/prevent-kill-on-shutdown.patch
new file mode 100644
index 000000000000..0a98b83282b6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/unionfs-fuse/prevent-kill-on-shutdown.patch
@@ -0,0 +1,14 @@
+diff -ru -x '*~' unionfs-fuse-0.26-orig/src/unionfs.c unionfs-fuse-0.26/src/unionfs.c
+--- unionfs-fuse-0.26-orig/src/unionfs.c	2012-09-11 00:06:32.000000000 +0200
++++ unionfs-fuse-0.26/src/unionfs.c	2014-05-21 14:22:03.597861805 +0200
+@@ -831,6 +831,10 @@
+ 	}
+ #endif
+ 
++	/* Prevent systemd's shutdown from killing us. */
++	if (access("/etc/initrd-release", F_OK) >= 0)
++		argv[0][0] = '@';
++
+ 	umask(0);
+ 	int res = fuse_main(args.argc, args.argv, &unionfs_oper, NULL);
+ 	RETURN(uopt.doexit ? uopt.retval : res);
diff --git a/nixpkgs/pkgs/tools/filesystems/vmfs-tools/default.nix b/nixpkgs/pkgs/tools/filesystems/vmfs-tools/default.nix
new file mode 100644
index 000000000000..6cc049a44092
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/vmfs-tools/default.nix
@@ -0,0 +1,25 @@
+{ stdenv, fetchFromGitHub, pkgconfig
+, asciidoc, docbook_xsl, fuse, libuuid, libxslt }:
+
+stdenv.mkDerivation rec {
+  name = "vmfs-tools";
+
+  src = fetchFromGitHub {
+    owner  = "glandium";
+    repo   = "vmfs-tools";
+    rev    = "4ab76ef5b074bdf06e4b518ff6d50439de05ae7f";
+    sha256 = "14y412ww5hxk336ils62s3fwykfh6mx1j0iiaa5cwc615pi6qvi4";
+  };
+
+  nativeBuildInputs = [ asciidoc docbook_xsl fuse libuuid libxslt pkgconfig ];
+
+  enableParallelBuilding = true;
+
+  meta = with stdenv.lib; {
+    homepage = https://github.com/glandium/vmfs-tools;
+    description = "FUSE-based VMFS (vmware) mounting tools";
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms = platforms.linux;
+    license = licenses.gpl2;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/wdfs/default.nix b/nixpkgs/pkgs/tools/filesystems/wdfs/default.nix
new file mode 100644
index 000000000000..135373e09f42
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/wdfs/default.nix
@@ -0,0 +1,19 @@
+{stdenv, fetchurl, glib, neon, fuse, pkgconfig}:
+
+stdenv.mkDerivation rec
+{
+  name = "wdfs-fuse-1.4.2";
+  src = fetchurl {
+    url = "http://noedler.de/projekte/wdfs/wdfs-1.4.2.tar.gz";
+    sha256 = "fcf2e1584568b07c7f3683a983a9be26fae6534b8109e09167e5dff9114ba2e5";
+  };
+  nativeBuildInputs = [ pkgconfig ];
+  buildInputs = [fuse glib neon];
+
+  meta = with stdenv.lib; {
+    homepage = http://noedler.de/projekte/wdfs/;
+    license = licenses.gpl2;
+    description = "User-space filesystem that allows to mount a webdav share";
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/xfsprogs/default.nix b/nixpkgs/pkgs/tools/filesystems/xfsprogs/default.nix
new file mode 100644
index 000000000000..98cc327bc29c
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/xfsprogs/default.nix
@@ -0,0 +1,65 @@
+{ stdenv, buildPackages, fetchpatch, fetchgit, autoconf, automake, gettext, libtool, pkgconfig
+, icu, libuuid, readline
+}:
+
+let
+  gentooPatch = name: sha256: fetchpatch {
+    url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-fs/xfsprogs/files/${name}?id=2517dd766cf84d251631f4324f7ec4bce912abb9";
+    inherit sha256;
+  };
+in
+
+stdenv.mkDerivation rec {
+  name = "xfsprogs-${version}";
+  version = "4.19.0";
+
+  src = fetchgit {
+    url = "https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git";
+    rev = "v${version}";
+    sha256 = "18728hzfxr1bg4bdzqlxjs893ac1zwlfr7nmc2q4a1sxs0sphd1d";
+  };
+
+  outputs = [ "bin" "dev" "out" "doc" ];
+
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
+  nativeBuildInputs = [
+    autoconf automake libtool gettext pkgconfig
+    libuuid # codegen tool uses libuuid
+  ];
+  buildInputs = [ readline icu ];
+  propagatedBuildInputs = [ libuuid ]; # Dev headers include <uuid/uuid.h>
+
+  enableParallelBuilding = true;
+
+  # Why is all this garbage needed? Why? Why?
+  patches = [
+    (gentooPatch "xfsprogs-4.15.0-sharedlibs.patch" "0bv2naxpiw7vcsg8p1v2i47wgfda91z1xy1kfwydbp4wmb4nbyyv")
+    (gentooPatch "xfsprogs-4.15.0-docdir.patch" "1srgdidvq2ka0rmfdwpqp92fapgh53w1h7rajm4nnby5vp2v8dfr")
+    (gentooPatch "xfsprogs-4.9.0-underlinking.patch" "1r7l8jphspy14i43zbfnjrnyrdm4cpgyfchblascxylmans0gci7")
+  ];
+
+  preConfigure = ''
+    sed -i Makefile -e '/cp include.install-sh/d'
+    make configure
+  '';
+
+  configureFlags = [
+    "--disable-lib64"
+    "--enable-readline"
+  ];
+
+  installFlags = [ "install-dev" ];
+
+  # FIXME: forbidden rpath
+  postInstall = ''
+    find . -type d -name .libs | xargs rm -rf
+  '';
+
+  meta = with stdenv.lib; {
+    homepage = http://xfs.org/;
+    description = "SGI XFS utilities";
+    license = licenses.lgpl21;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ dezgeg ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/xtreemfs/default.nix b/nixpkgs/pkgs/tools/filesystems/xtreemfs/default.nix
new file mode 100644
index 000000000000..4c0c2343dd2a
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/xtreemfs/default.nix
@@ -0,0 +1,70 @@
+{ stdenv, boost, fuse, openssl, cmake, attr, jdk, ant, which, file, python
+, lib, valgrind, makeWrapper, fetchFromGitHub }:
+
+stdenv.mkDerivation rec {
+  src = fetchFromGitHub {
+    # using unstable release because stable (v1.5.1) has broken repl java plugin
+    rev = "7ddcb081aa125b0cfb008dc98addd260b8353ab3";
+    owner = "xtreemfs";
+    repo = "xtreemfs";
+    sha256 = "1hjmd32pla27zf98ghzz6r5ml8ry86m9dsryv1z01kxv5l95b3m0";
+  };
+
+  name = "XtreemFS-${version}";
+  version = "1.5.1.81";
+
+  buildInputs = [ which attr makeWrapper python ];
+
+  preConfigure = ''
+    export JAVA_HOME=${jdk}
+    export ANT_HOME=${ant}
+
+    export BOOST_INCLUDEDIR=${boost.dev}/include
+    export BOOST_LIBRARYDIR=${boost.out}/lib
+    export CMAKE_INCLUDE_PATH=${openssl.dev}/include
+    export CMAKE_LIBRARY_PATH=${openssl.out}/lib
+
+    substituteInPlace cpp/cmake/FindValgrind.cmake \
+      --replace "/usr/local" "${valgrind}"
+
+    substituteInPlace cpp/CMakeLists.txt \
+      --replace '"/lib64" "/usr/lib64"' '"${attr.out}/lib" "${fuse}/lib"'
+
+    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${fuse}/include"
+    export NIX_CFLAGS_LINK="$NIX_CFLAGS_LINK -L${fuse}/lib"
+
+    export DESTDIR=$out
+
+    substituteInPlace Makefile \
+      --replace "/usr/share/" "/share/" \
+      --replace 'BIN_DIR=$(DESTDIR)/usr/bin' "BIN_DIR=$out/bin"
+
+    substituteInPlace etc/init.d/generate_initd_scripts.sh \
+      --replace "/bin/bash" "${stdenv.shell}"
+
+    substituteInPlace cpp/thirdparty/gtest-1.7.0/configure \
+      --replace "/usr/bin/file" "${file}/bin/file"
+
+    substituteInPlace cpp/thirdparty/protobuf-2.5.0/configure \
+      --replace "/usr/bin/file" "${file}/bin/file"
+
+    substituteInPlace cpp/thirdparty/protobuf-2.5.0/gtest/configure \
+      --replace "/usr/bin/file" "${file}/bin/file"
+
+    # do not put cmake into buildInputs
+    export PATH="$PATH:${cmake}/bin"
+  '';
+
+  doCheck = false;
+
+  postInstall = ''
+    rm -r $out/sbin
+  '';
+
+  meta = {
+    description = "A distributed filesystem";
+    maintainers = with lib.maintainers; [ raskin matejc ];
+    platforms = lib.platforms.linux;
+    license = lib.licenses.bsd3;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/yandex-disk/default.nix b/nixpkgs/pkgs/tools/filesystems/yandex-disk/default.nix
new file mode 100644
index 000000000000..6acb034d75b6
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/yandex-disk/default.nix
@@ -0,0 +1,64 @@
+{ stdenv, fetchurl, writeText, zlib, rpmextract, patchelf, which }:
+
+let
+  p = if stdenv.is64bit then {
+      arch = "x86_64";
+      gcclib = "${stdenv.cc.cc.lib}/lib64";
+      sha256 = "1skbzmrcjbw00a3jnbl2llqwz3ahsgvq74mjav68s2hw1wjidvk6";
+    }
+    else {
+      arch = "i386";
+      gcclib = "${stdenv.cc.cc.lib}/lib";
+      sha256 = "09h71i3k9d24ki81jdwhnav63fqbc44glbx228s9g3cr4ap41jcx";
+    };
+in
+stdenv.mkDerivation rec {
+
+  name = "yandex-disk-${version}";
+  version = "0.1.5.978";
+
+  src = fetchurl {
+    url = "https://repo.yandex.ru/yandex-disk/rpm/stable/${p.arch}/${name}-1.fedora.${p.arch}.rpm";
+    sha256 = p.sha256;
+  };
+
+  builder = writeText "builder.sh" ''
+    . $stdenv/setup
+    mkdir -pv $out/bin
+    mkdir -pv $out/share
+    mkdir -pv $out/etc
+
+    mkdir -pv unpacked
+    cd unpacked
+    ${rpmextract}/bin/rpmextract $src
+
+    cp -r -t $out/bin usr/bin/*
+    cp -r -t $out/share usr/share/*
+    cp -r -t $out/etc etc/*
+
+    sed -i 's@have@${which}/bin/which >/dev/null 2>\&1@' \
+      $out/etc/bash_completion.d/yandex-disk-completion.bash
+
+    ${patchelf}/bin/patchelf \
+      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
+      --set-rpath "${zlib.out}/lib:${p.gcclib}" \
+      $out/bin/yandex-disk
+  '';
+
+  meta = {
+    homepage = http://help.yandex.com/disk/cli-clients.xml;
+    description = "A free cloud file storage service";
+    maintainers = with stdenv.lib.maintainers; [ smironov jagajaga ];
+    platforms = ["i686-linux" "x86_64-linux"];
+    license = stdenv.lib.licenses.unfree;
+    longDescription = ''
+      Yandex.Disk console client for Linux lets you manage files on Disk without
+      using a window interface or programs that support WebDAV. The advantages
+      of the console client compared to a WebDAV connection:
+       * low system resource requirements;
+       * faster file reading and writing speeds;
+       * faster syncing with Disk's server;
+       * no need to be constantly connected to work with files.
+    '';
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/zerofree/default.nix b/nixpkgs/pkgs/tools/filesystems/zerofree/default.nix
new file mode 100644
index 000000000000..c311ac1af231
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/zerofree/default.nix
@@ -0,0 +1,26 @@
+{ stdenv, fetchurl, e2fsprogs }:
+
+stdenv.mkDerivation rec {
+  name = "zerofree-${version}";
+  version = "1.1.1";
+
+  src = fetchurl {
+    url = "https://frippery.org/uml/${name}.tgz";
+    sha256 = "0rrqfa5z103ws89vi8kfvbks1cfs74ix6n1wb6vs582vnmhwhswm";
+  };
+
+  buildInputs = [ e2fsprogs ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp zerofree $out/bin
+'';
+
+  meta = {
+    homepage = https://frippery.org/uml/;
+    description = "Zero free blocks from ext2, ext3 and ext4 file-systems";
+    platforms = stdenv.lib.platforms.linux;
+    license = stdenv.lib.licenses.gpl2;
+    maintainers = [ stdenv.lib.maintainers.theuni ];
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/zfstools/default.nix b/nixpkgs/pkgs/tools/filesystems/zfstools/default.nix
new file mode 100644
index 000000000000..518e92814a41
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/zfstools/default.nix
@@ -0,0 +1,40 @@
+{ stdenv, fetchFromGitHub, ruby, zfs }:
+
+let version = "0.3.6"; in
+stdenv.mkDerivation rec {
+  name = "zfstools-${version}";
+
+  src = fetchFromGitHub {
+    sha256 = "16lvw3xbmxp2pr8nixqn7lf4504zaaxvbbdnjkv4dggwd4lsdjyg";
+    rev = "v${version}";
+    repo = "zfstools";
+    owner = "bdrewery";
+  };
+
+  buildInputs = [ ruby ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp bin/* $out/bin/
+
+    cp -R lib $out/
+
+    for f in $out/bin/*; do
+      substituteInPlace $f --replace "/usr/bin/env ruby" "ruby -I$out/lib"
+    done
+
+    sed -e 's|cmd.*=.*"zfs |cmd = "${zfs}/sbin/zfs |g' -i $out/lib/zfstools/{dataset,snapshot}.rb
+  '';
+
+  meta = with stdenv.lib; {
+    inherit version;
+    inherit (src.meta) homepage;
+    description = "OpenSolaris-compatible auto-snapshotting script for ZFS";
+    longDescription = ''
+      zfstools is an OpenSolaris-like and compatible auto snapshotting script
+      for ZFS, which also supports auto snapshotting mysql databases.
+    '';
+    license = licenses.bsd2;
+    platforms = platforms.linux;
+  };
+}
diff --git a/nixpkgs/pkgs/tools/filesystems/zkfuse/default.nix b/nixpkgs/pkgs/tools/filesystems/zkfuse/default.nix
new file mode 100644
index 000000000000..0e182d3bd2ea
--- /dev/null
+++ b/nixpkgs/pkgs/tools/filesystems/zkfuse/default.nix
@@ -0,0 +1,22 @@
+{ stdenv, lib, zookeeper, zookeeper_mt, fuse, autoreconfHook, log4cxx, boost }:
+
+stdenv.mkDerivation rec {
+  name = "zkfuse-${version}";
+  inherit (zookeeper) version src;
+
+  sourceRoot = "${zookeeper.name}/src/contrib/zkfuse";
+
+  nativeBuildInputs = [ autoreconfHook ];
+  buildInputs = [ zookeeper_mt log4cxx boost fuse ];
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp -v src/zkfuse $out/bin
+  '';
+
+  meta = with lib; {
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ cstrahan ];
+    license = licenses.asl20;
+  };
+}