sshfs: add darwin build

+106 -49
+6
pkgs/os-specific/darwin/macfuse/default.nix
··· 56 lgpl2Plus # libfuse 57 ]; 58 }; 59 }
··· 56 lgpl2Plus # libfuse 57 ]; 58 }; 59 + 60 + passthru.warning = '' 61 + macFUSE is required for this package to work on macOS. To install macFUSE, 62 + use the installer from the <link xlink:href="https://osxfuse.github.io/"> 63 + project website</link>. 64 + ''; 65 }
+61
pkgs/tools/filesystems/sshfs-fuse/common.nix
···
··· 1 + { version, sha256, platforms, patches ? [ ] }: 2 + 3 + { lib, stdenv, fetchFromGitHub 4 + , meson, pkg-config, ninja, docutils, makeWrapper 5 + , fuse3, macfuse-stubs, glib 6 + , which, python3Packages 7 + , openssh 8 + }: 9 + 10 + let 11 + fuse = if stdenv.isDarwin then macfuse-stubs else fuse3; 12 + in stdenv.mkDerivation rec { 13 + pname = "sshfs-fuse"; 14 + inherit version; 15 + 16 + src = fetchFromGitHub { 17 + owner = "libfuse"; 18 + repo = "sshfs"; 19 + rev = "sshfs-${version}"; 20 + inherit sha256; 21 + }; 22 + 23 + inherit patches; 24 + 25 + nativeBuildInputs = [ meson pkg-config ninja docutils makeWrapper ]; 26 + buildInputs = [ fuse glib ]; 27 + checkInputs = [ which python3Packages.pytest ]; 28 + 29 + NIX_CFLAGS_COMPILE = lib.optionalString 30 + (stdenv.hostPlatform.system == "i686-linux") 31 + "-D_FILE_OFFSET_BITS=64"; 32 + 33 + postInstall = '' 34 + mkdir -p $out/sbin 35 + ln -sf $out/bin/sshfs $out/sbin/mount.sshfs 36 + '' + lib.optionalString (!stdenv.isDarwin) '' 37 + wrapProgram $out/bin/sshfs --prefix PATH : "${openssh}/bin" 38 + ''; 39 + 40 + # doCheck = true; 41 + checkPhase = lib.optionalString (!stdenv.isDarwin) '' 42 + # The tests need fusermount: 43 + mkdir bin 44 + cp ${fuse}/bin/fusermount3 bin/fusermount 45 + export PATH=bin:$PATH 46 + # Can't access /dev/fuse within the sandbox: "FUSE kernel module does not seem to be loaded" 47 + substituteInPlace test/util.py --replace "/dev/fuse" "/dev/null" 48 + # TODO: "fusermount executable not setuid, and we are not root" 49 + # We should probably use a VM test instead 50 + ${python3Packages.python.interpreter} -m pytest test/ 51 + ''; 52 + 53 + meta = with lib; { 54 + inherit platforms; 55 + description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH"; 56 + longDescription = macfuse-stubs.warning; 57 + homepage = "https://github.com/libfuse/sshfs"; 58 + license = licenses.gpl2Plus; 59 + maintainers = with maintainers; [ primeos ]; 60 + }; 61 + }
+25 -49
pkgs/tools/filesystems/sshfs-fuse/default.nix
··· 1 - { lib, stdenv, fetchFromGitHub 2 - , meson, pkg-config, ninja, docutils, makeWrapper 3 - , fuse3, glib 4 - , which, python3Packages 5 - , openssh 6 - }: 7 8 - stdenv.mkDerivation rec { 9 - version = "3.7.1"; 10 - pname = "sshfs-fuse"; 11 12 - src = fetchFromGitHub { 13 - owner = "libfuse"; 14 - repo = "sshfs"; 15 - rev = "sshfs-${version}"; 16 sha256 = "088mgcsqv9f2vly4xn6lvvkmqkgr9jjmjs9qp8938hl7j6rrgd17"; 17 - }; 18 - 19 - nativeBuildInputs = [ meson pkg-config ninja docutils makeWrapper ]; 20 - buildInputs = [ fuse3 glib ]; 21 - checkInputs = [ which python3Packages.pytest ]; 22 - 23 - NIX_CFLAGS_COMPILE = lib.optionalString 24 - (stdenv.hostPlatform.system == "i686-linux") 25 - "-D_FILE_OFFSET_BITS=64"; 26 - 27 - postInstall = '' 28 - mkdir -p $out/sbin 29 - ln -sf $out/bin/sshfs $out/sbin/mount.sshfs 30 - wrapProgram $out/bin/sshfs --prefix PATH : "${openssh}/bin" 31 - ''; 32 - 33 - #doCheck = true; 34 - checkPhase = '' 35 - # The tests need fusermount: 36 - mkdir bin && cp ${fuse3}/bin/fusermount3 bin/fusermount 37 - export PATH=bin:$PATH 38 - # Can't access /dev/fuse within the sandbox: "FUSE kernel module does not seem to be loaded" 39 - substituteInPlace test/util.py --replace "/dev/fuse" "/dev/null" 40 - # TODO: "fusermount executable not setuid, and we are not root" 41 - # We should probably use a VM test instead 42 - python3 -m pytest test/ 43 - ''; 44 - 45 - meta = with lib; { 46 - inherit (src.meta) homepage; 47 - description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH"; 48 - platforms = platforms.linux; 49 - license = licenses.gpl2; 50 - maintainers = with maintainers; [ primeos ]; 51 - }; 52 - }
··· 1 + { lib, stdenv, callPackage, fetchpatch }: 2 3 + let mkSSHFS = args: callPackage (import ./common.nix args) { }; 4 + in if stdenv.isDarwin then 5 + mkSSHFS { 6 + version = "2.10"; # macFUSE isn't yet compatible with libfuse 3.x 7 + sha256 = "1dmw4kx6vyawcywiv8drrajnam0m29mxfswcp4209qafzx3mjlp1"; 8 + patches = [ 9 + # remove reference to fuse_darwin.h which doens't exist on recent macFUSE 10 + ./fix-fuse-darwin-h.patch 11 12 + # From https://github.com/libfuse/sshfs/pull/185: 13 + # > With this patch, setting I/O size to a reasonable large value, will 14 + # > result in much improved performance, e.g.: -o iosize=1048576 15 + (fetchpatch { 16 + name = "fix-configurable-blksize.patch"; 17 + url = "https://github.com/libfuse/sshfs/commit/667cf34622e2e873db776791df275c7a582d6295.patch"; 18 + sha256 = "0d65lawd2g2aisk1rw2vl65dgxywf4vqgv765n9zj9zysyya8a54"; 19 + }) 20 + ]; 21 + platforms = lib.platforms.darwin; 22 + } 23 + else 24 + mkSSHFS { 25 + version = "3.7.1"; 26 sha256 = "088mgcsqv9f2vly4xn6lvvkmqkgr9jjmjs9qp8938hl7j6rrgd17"; 27 + platforms = lib.platforms.linux; 28 + }
+14
pkgs/tools/filesystems/sshfs-fuse/fix-fuse-darwin-h.patch
···
··· 1 + diff --git a/sshfs.c b/sshfs.c 2 + index 97eaf06..d442577 100644 3 + --- a/sshfs.c 4 + +++ b/sshfs.c 5 + @@ -14,9 +14,6 @@ 6 + #if !defined(__CYGWIN__) 7 + #include <fuse_lowlevel.h> 8 + #endif 9 + -#ifdef __APPLE__ 10 + -# include <fuse_darwin.h> 11 + -#endif 12 + #include <assert.h> 13 + #include <stdio.h> 14 + #include <stdlib.h>