29 stdenv.mkDerivation (finalAttrs: {
30 pname = "bcachefs-tools";
33 src = fetchFromGitHub {
34 owner = "koverstreet";
35 repo = "bcachefs-tools";
36 rev = "refs/tags/v${finalAttrs.version}";
37 hash = "sha256-L2eIYdQnnmKNI8QWSy8nk4GzJ8jv+qt98gqdzcJH31Q=";
44 rustPlatform.cargoSetupHook
45 rustPlatform.bindgenHook
62 ] ++ lib.optional fuseSupport fuse3;
64 cargoDeps = rustPlatform.fetchCargoTarball {
66 hash = "sha256-Ol3wKdxKYJWDC/JREOfVSQRNnWVano7qilMRvqrLsgA==";
70 "PREFIX=${placeholder "out"}"
71 "VERSION=${finalAttrs.version}"
72 "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
73 ] ++ lib.optional fuseSupport "BCACHEFS_FUSE=1";
76 CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
77 "CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc";
80 # FIXME: Try enabling this once the default linux kernel is at least 6.7
81 doCheck = false; # needs bcachefs module loaded on builder
84 substituteInPlace Makefile \
85 --replace-fail "target/release/bcachefs" "target/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/bcachefs"
88 preCheck = lib.optionalString (!fuseSupport) ''
91 checkFlags = [ "BCACHEFS_TEST_USE_VALGRIND=no" ];
93 # Tries to install to the 'systemd-minimal' and 'udev' nix installation paths
95 "PKGCONFIG_SERVICEDIR=$(out)/lib/systemd/system"
96 "PKGCONFIG_UDEVDIR=$(out)/lib/udev"
101 substituteInPlace $out/libexec/bcachefsck_all \
102 --replace-fail "/usr/bin/python3" "${python3.interpreter}"
104 + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
105 installShellCompletion --cmd bcachefs \
106 --bash <($out/sbin/bcachefs completions bash) \
107 --zsh <($out/sbin/bcachefs completions zsh) \
108 --fish <($out/sbin/bcachefs completions fish)
113 version = testers.testVersion {
114 package = finalAttrs.finalPackage;
115 command = "${finalAttrs.meta.mainProgram} version";
116 version = "${finalAttrs.version}";
118 smoke-test = nixosTests.bcachefs;
119 inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
122 updateScript = nix-update-script { };
125 enableParallelBuilding = true;
128 description = "Tool for managing bcachefs filesystems";
129 homepage = "https://bcachefs.org/";
130 license = lib.licenses.gpl2Only;
131 maintainers = with lib.maintainers; [
135 platforms = lib.platforms.linux;
136 mainProgram = "bcachefs";