3 { lib, stdenv, fetchFromGitHub, fetchpatch
4 , fusePackages, util-linux, gettext, shadow
5 , meson, ninja, pkg-config
7 , python3Packages, which
11 isFuse3 = lib.hasPrefix "3" version;
12 in stdenv.mkDerivation rec {
16 src = fetchFromGitHub {
19 rev = "${pname}-${version}";
23 preAutoreconf = "touch config.rpath";
27 (!isFuse3 && (stdenv.isAarch64 || stdenv.hostPlatform.isLoongArch64))
29 url = "https://github.com/libfuse/libfuse/commit/914871b20a901e3e1e981c92bc42b1c93b7ab81b.patch";
30 sha256 = "1w4j6f1awjrycycpvmlv0x5v9gprllh4dnbjxl4dyl2jgbkaw6pa";
33 then [ ./fuse3-install.patch ./fuse3-Do-not-set-FUSERMOUNT_DIR.patch ]
35 ./fuse2-Do-not-set-FUSERMOUNT_DIR.patch
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=";
42 nativeBuildInputs = if isFuse3
43 then [ meson ninja pkg-config ]
44 else [ autoreconfHook gettext ];
46 outputs = [ "out" ] ++ lib.optional isFuse3 "common";
48 mesonFlags = lib.optionals isFuse3 [
49 "-Dudevrulesdir=/udev/rules.d"
55 export MOUNT_FUSE_PATH=$out/sbin
56 export INIT_D_PATH=$TMPDIR/etc/init.d
57 export UDEV_RULES_PATH=$out/etc/udev/rules.d
59 # Ensure that FUSE calls the setuid wrapper, not
60 # $out/bin/fusermount. It falls back to calling fusermount in
61 # $PATH, so it should also work on non-NixOS systems.
62 export NIX_CFLAGS_COMPILE="-DFUSERMOUNT_DIR=\"/run/wrappers/bin\""
64 substituteInPlace lib/mount_util.c --replace "/bin/" "${util-linux}/bin/"
65 '' + (if isFuse3 then ''
66 # The configure phase will delete these files (temporary workaround for
67 # ./fuse3-install_man.patch)
68 install -D -m444 doc/fusermount3.1 $out/share/man/man1/fusermount3.1
69 install -D -m444 doc/mount.fuse3.8 $out/share/man/man8/mount.fuse3.8
71 substituteInPlace util/mount.fuse.c --replace '"su"' '"${shadow.su}/bin/su"'
72 sed -e 's@CONFIG_RPATH=/usr/share/gettext/config.rpath@CONFIG_RPATH=${gettext}/share/gettext/config.rpath@' -i makeconf.sh
76 nativeCheckInputs = [ which ] ++ (with python3Packages; [ python pytest ]);
79 python3 -m pytest test/
82 doCheck = false; # v2: no tests, v3: all tests get skipped in a sandbox
84 postFixup = "cd $out\n" + (if isFuse3 then ''
85 install -D -m444 etc/fuse.conf $common/etc/fuse.conf
86 install -D -m444 etc/udev/rules.d/99-fuse3.rules $common/etc/udev/rules.d/99-fuse.rules
88 cp ${fusePackages.fuse_3.common}/etc/fuse.conf etc/fuse.conf
89 cp ${fusePackages.fuse_3.common}/etc/udev/rules.d/99-fuse.rules etc/udev/rules.d/99-fuse.rules
93 description = "Library that allows filesystems to be implemented in user space";
95 FUSE (Filesystem in Userspace) is an interface for userspace programs to
96 export a filesystem to the Linux kernel. The FUSE project consists of two
97 components: The fuse kernel module (maintained in the regular kernel
98 repositories) and the libfuse userspace library (this package). libfuse
99 provides the reference implementation for communicating with the FUSE
102 homepage = "https://github.com/libfuse/libfuse";
103 changelog = "https://github.com/libfuse/libfuse/releases/tag/fuse-${version}";
104 platforms = platforms.linux;
105 license = with licenses; [ gpl2Only lgpl21Only ];
106 maintainers = [ maintainers.primeos ];