at 23.05-pre 107 lines 3.9 kB view raw
1{ version, sha256Hash }: 2 3{ lib, stdenv, fetchFromGitHub, fetchpatch 4, fusePackages, util-linux, gettext, shadow 5, meson, ninja, pkg-config 6, autoreconfHook 7, python3Packages, which 8}: 9 10let 11 isFuse3 = lib.hasPrefix "3" version; 12in stdenv.mkDerivation rec { 13 pname = "fuse"; 14 inherit version; 15 16 src = fetchFromGitHub { 17 owner = "libfuse"; 18 repo = "libfuse"; 19 rev = "${pname}-${version}"; 20 sha256 = sha256Hash; 21 }; 22 23 preAutoreconf = "touch config.rpath"; 24 25 patches = 26 lib.optional 27 (!isFuse3 && stdenv.isAarch64) 28 (fetchpatch { 29 url = "https://github.com/libfuse/libfuse/commit/914871b20a901e3e1e981c92bc42b1c93b7ab81b.patch"; 30 sha256 = "1w4j6f1awjrycycpvmlv0x5v9gprllh4dnbjxl4dyl2jgbkaw6pa"; 31 }) 32 ++ (if isFuse3 33 then [ ./fuse3-install.patch ./fuse3-Do-not-set-FUSERMOUNT_DIR.patch ] 34 else [ 35 ./fuse2-Do-not-set-FUSERMOUNT_DIR.patch 36 (fetchpatch { 37 url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-fs/fuse/files/fuse-2.9.9-closefrom-glibc-2-34.patch?id=8a970396fca7aca2d5a761b8e7a8242f1eef14c9"; 38 sha256 = "sha256-ELYBW/wxRcSMssv7ejCObrpsJHtOPJcGq33B9yHQII4="; 39 }) 40 ]); 41 42 nativeBuildInputs = if isFuse3 43 then [ meson ninja pkg-config ] 44 else [ autoreconfHook gettext ]; 45 46 outputs = [ "out" ] ++ lib.optional isFuse3 "common"; 47 48 mesonFlags = lib.optionals isFuse3 [ 49 "-Dudevrulesdir=/udev/rules.d" 50 "-Duseroot=false" 51 ]; 52 53 preConfigure = '' 54 export MOUNT_FUSE_PATH=$out/sbin 55 export INIT_D_PATH=$TMPDIR/etc/init.d 56 export UDEV_RULES_PATH=$out/etc/udev/rules.d 57 58 # Ensure that FUSE calls the setuid wrapper, not 59 # $out/bin/fusermount. It falls back to calling fusermount in 60 # $PATH, so it should also work on non-NixOS systems. 61 export NIX_CFLAGS_COMPILE="-DFUSERMOUNT_DIR=\"/run/wrappers/bin\"" 62 63 substituteInPlace lib/mount_util.c --replace "/bin/" "${util-linux}/bin/" 64 '' + (if isFuse3 then '' 65 # The configure phase will delete these files (temporary workaround for 66 # ./fuse3-install_man.patch) 67 install -D -m444 doc/fusermount3.1 $out/share/man/man1/fusermount3.1 68 install -D -m444 doc/mount.fuse3.8 $out/share/man/man8/mount.fuse3.8 69 '' else '' 70 substituteInPlace util/mount.fuse.c --replace '"su"' '"${shadow.su}/bin/su"' 71 sed -e 's@CONFIG_RPATH=/usr/share/gettext/config.rpath@CONFIG_RPATH=${gettext}/share/gettext/config.rpath@' -i makeconf.sh 72 ./makeconf.sh 73 ''); 74 75 checkInputs = [ which ] ++ (with python3Packages; [ python pytest ]); 76 77 checkPhase = '' 78 python3 -m pytest test/ 79 ''; 80 81 doCheck = false; # v2: no tests, v3: all tests get skipped in a sandbox 82 83 postFixup = "cd $out\n" + (if isFuse3 then '' 84 install -D -m444 etc/fuse.conf $common/etc/fuse.conf 85 install -D -m444 etc/udev/rules.d/99-fuse3.rules $common/etc/udev/rules.d/99-fuse.rules 86 '' else '' 87 cp ${fusePackages.fuse_3.common}/etc/fuse.conf etc/fuse.conf 88 cp ${fusePackages.fuse_3.common}/etc/udev/rules.d/99-fuse.rules etc/udev/rules.d/99-fuse.rules 89 ''); 90 91 meta = with lib; { 92 description = "Library that allows filesystems to be implemented in user space"; 93 longDescription = '' 94 FUSE (Filesystem in Userspace) is an interface for userspace programs to 95 export a filesystem to the Linux kernel. The FUSE project consists of two 96 components: The fuse kernel module (maintained in the regular kernel 97 repositories) and the libfuse userspace library (this package). libfuse 98 provides the reference implementation for communicating with the FUSE 99 kernel module. 100 ''; 101 homepage = "https://github.com/libfuse/libfuse"; 102 changelog = "https://github.com/libfuse/libfuse/releases/tag/fuse-${version}"; 103 platforms = platforms.linux; 104 license = with licenses; [ gpl2Only lgpl21Only ]; 105 maintainers = [ maintainers.primeos ]; 106 }; 107}