at 23.11-beta 108 lines 3.9 kB view raw
1{ version, hash }: 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 inherit hash; 21 }; 22 23 preAutoreconf = "touch config.rpath"; 24 25 patches = 26 lib.optional 27 (!isFuse3 && (stdenv.isAarch64 || stdenv.hostPlatform.isLoongArch64)) 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 "-Dinitscriptdir=" 52 ]; 53 54 preConfigure = '' 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 58 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\"" 63 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 70 '' else '' 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 73 ./makeconf.sh 74 ''); 75 76 nativeCheckInputs = [ which ] ++ (with python3Packages; [ python pytest ]); 77 78 checkPhase = '' 79 python3 -m pytest test/ 80 ''; 81 82 doCheck = false; # v2: no tests, v3: all tests get skipped in a sandbox 83 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 87 '' else '' 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 90 ''); 91 92 meta = with lib; { 93 description = "Library that allows filesystems to be implemented in user space"; 94 longDescription = '' 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 100 kernel module. 101 ''; 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 ]; 107 }; 108}