summary refs log tree commit diff
diff options
context:
space:
mode:
authormidchildan <git@midchildan.org>2021-03-22 21:06:50 +0900
committermidchildan <git@midchildan.org>2021-04-06 10:37:53 +0900
commit87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90 (patch)
tree59fd9ff4475f513fb70a0ff8f22d25742f18ea38
parent239d8e251763b666e6c9d54162b0ac1341ab8533 (diff)
downloadnixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar.gz
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar.bz2
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar.lz
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar.xz
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.tar.zst
nixpkgs-87f578a36fb3bcb2e9b9533dd360b5aa16ebfc90.zip
sshfs: add darwin build
-rw-r--r--pkgs/os-specific/darwin/macfuse/default.nix6
-rw-r--r--pkgs/tools/filesystems/sshfs-fuse/common.nix61
-rw-r--r--pkgs/tools/filesystems/sshfs-fuse/default.nix74
-rw-r--r--pkgs/tools/filesystems/sshfs-fuse/fix-fuse-darwin-h.patch14
4 files changed, 106 insertions, 49 deletions
diff --git a/pkgs/os-specific/darwin/macfuse/default.nix b/pkgs/os-specific/darwin/macfuse/default.nix
index 7e1b4ed7763..4fd92a15562 100644
--- a/pkgs/os-specific/darwin/macfuse/default.nix
+++ b/pkgs/os-specific/darwin/macfuse/default.nix
@@ -56,4 +56,10 @@ stdenv.mkDerivation rec {
       lgpl2Plus # libfuse
     ];
   };
+
+  passthru.warning = ''
+    macFUSE is required for this package to work on macOS. To install macFUSE,
+    use the installer from the <link xlink:href="https://osxfuse.github.io/">
+    project website</link>.
+  '';
 }
diff --git a/pkgs/tools/filesystems/sshfs-fuse/common.nix b/pkgs/tools/filesystems/sshfs-fuse/common.nix
new file mode 100644
index 00000000000..f85faa712dd
--- /dev/null
+++ b/pkgs/tools/filesystems/sshfs-fuse/common.nix
@@ -0,0 +1,61 @@
+{ version, sha256, platforms, patches ? [ ] }:
+
+{ lib, stdenv, fetchFromGitHub
+, meson, pkg-config, ninja, docutils, makeWrapper
+, fuse3, macfuse-stubs, glib
+, which, python3Packages
+, openssh
+}:
+
+let
+  fuse = if stdenv.isDarwin then macfuse-stubs else fuse3;
+in stdenv.mkDerivation rec {
+  pname = "sshfs-fuse";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "libfuse";
+    repo = "sshfs";
+    rev = "sshfs-${version}";
+    inherit sha256;
+  };
+
+  inherit patches;
+
+  nativeBuildInputs = [ meson pkg-config ninja docutils makeWrapper ];
+  buildInputs = [ fuse glib ];
+  checkInputs = [ which python3Packages.pytest ];
+
+  NIX_CFLAGS_COMPILE = lib.optionalString
+    (stdenv.hostPlatform.system == "i686-linux")
+    "-D_FILE_OFFSET_BITS=64";
+
+  postInstall = ''
+    mkdir -p $out/sbin
+    ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
+  '' + lib.optionalString (!stdenv.isDarwin) ''
+    wrapProgram $out/bin/sshfs --prefix PATH : "${openssh}/bin"
+  '';
+
+  # doCheck = true;
+  checkPhase = lib.optionalString (!stdenv.isDarwin) ''
+    # The tests need fusermount:
+    mkdir bin
+    cp ${fuse}/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
+    ${python3Packages.python.interpreter} -m pytest test/
+  '';
+
+  meta = with lib; {
+    inherit platforms;
+    description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH";
+    longDescription = macfuse-stubs.warning;
+    homepage = "https://github.com/libfuse/sshfs";
+    license = licenses.gpl2Plus;
+    maintainers = with maintainers; [ primeos ];
+  };
+}
diff --git a/pkgs/tools/filesystems/sshfs-fuse/default.nix b/pkgs/tools/filesystems/sshfs-fuse/default.nix
index 69826941d00..e575bd3e138 100644
--- a/pkgs/tools/filesystems/sshfs-fuse/default.nix
+++ b/pkgs/tools/filesystems/sshfs-fuse/default.nix
@@ -1,52 +1,28 @@
-{ lib, stdenv, fetchFromGitHub
-, meson, pkg-config, ninja, docutils, makeWrapper
-, fuse3, glib
-, which, python3Packages
-, openssh
-}:
+{ lib, stdenv, callPackage, fetchpatch }:
 
-stdenv.mkDerivation rec {
-  version = "3.7.1";
-  pname = "sshfs-fuse";
+let mkSSHFS = args: callPackage (import ./common.nix args) { };
+in if stdenv.isDarwin then
+  mkSSHFS {
+    version = "2.10"; # macFUSE isn't yet compatible with libfuse 3.x
+    sha256 = "1dmw4kx6vyawcywiv8drrajnam0m29mxfswcp4209qafzx3mjlp1";
+    patches = [
+      # remove reference to fuse_darwin.h which doens't exist on recent macFUSE
+      ./fix-fuse-darwin-h.patch
 
-  src = fetchFromGitHub {
-    owner = "libfuse";
-    repo = "sshfs";
-    rev = "sshfs-${version}";
+      # From https://github.com/libfuse/sshfs/pull/185:
+      # > With this patch, setting I/O size to a reasonable large value, will
+      # > result in much improved performance, e.g.: -o iosize=1048576
+      (fetchpatch {
+        name = "fix-configurable-blksize.patch";
+        url = "https://github.com/libfuse/sshfs/commit/667cf34622e2e873db776791df275c7a582d6295.patch";
+        sha256 = "0d65lawd2g2aisk1rw2vl65dgxywf4vqgv765n9zj9zysyya8a54";
+      })
+    ];
+    platforms = lib.platforms.darwin;
+  }
+else
+  mkSSHFS {
+    version = "3.7.1";
     sha256 = "088mgcsqv9f2vly4xn6lvvkmqkgr9jjmjs9qp8938hl7j6rrgd17";
-  };
-
-  nativeBuildInputs = [ meson pkg-config ninja docutils makeWrapper ];
-  buildInputs = [ fuse3 glib ];
-  checkInputs = [ which python3Packages.pytest ];
-
-  NIX_CFLAGS_COMPILE = lib.optionalString
-    (stdenv.hostPlatform.system == "i686-linux")
-    "-D_FILE_OFFSET_BITS=64";
-
-  postInstall = ''
-    mkdir -p $out/sbin
-    ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
-    wrapProgram $out/bin/sshfs --prefix PATH : "${openssh}/bin"
-  '';
-
-  #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 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 ];
-  };
-}
+    platforms = lib.platforms.linux;
+  }
diff --git a/pkgs/tools/filesystems/sshfs-fuse/fix-fuse-darwin-h.patch b/pkgs/tools/filesystems/sshfs-fuse/fix-fuse-darwin-h.patch
new file mode 100644
index 00000000000..045cc0e61f3
--- /dev/null
+++ b/pkgs/tools/filesystems/sshfs-fuse/fix-fuse-darwin-h.patch
@@ -0,0 +1,14 @@
+diff --git a/sshfs.c b/sshfs.c
+index 97eaf06..d442577 100644
+--- a/sshfs.c
++++ b/sshfs.c
+@@ -14,9 +14,6 @@
+ #if !defined(__CYGWIN__)
+ #include <fuse_lowlevel.h>
+ #endif
+-#ifdef __APPLE__
+-#  include <fuse_darwin.h>
+-#endif
+ #include <assert.h>
+ #include <stdio.h>
+ #include <stdlib.h>