2024-05-15 15:35:15 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
fetchFromGitHub,
|
|
|
|
pkg-config,
|
|
|
|
libuuid,
|
|
|
|
libsodium,
|
|
|
|
keyutils,
|
|
|
|
liburcu,
|
|
|
|
zlib,
|
|
|
|
libaio,
|
|
|
|
zstd,
|
|
|
|
lz4,
|
|
|
|
attr,
|
|
|
|
udev,
|
|
|
|
fuse3,
|
|
|
|
cargo,
|
|
|
|
rustc,
|
|
|
|
rustPlatform,
|
|
|
|
makeWrapper,
|
|
|
|
nix-update-script,
|
|
|
|
python3,
|
2024-07-27 06:49:29 +00:00
|
|
|
testers,
|
|
|
|
nixosTests,
|
|
|
|
installShellFiles,
|
2024-05-15 15:35:15 +00:00
|
|
|
fuseSupport ? false,
|
2021-07-14 22:03:04 +00:00
|
|
|
}:
|
2024-01-02 11:29:13 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "bcachefs-tools";
|
2024-07-27 06:49:29 +00:00
|
|
|
version = "1.9.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "koverstreet";
|
|
|
|
repo = "bcachefs-tools";
|
2024-07-27 06:49:29 +00:00
|
|
|
rev = "refs/tags/v${finalAttrs.version}";
|
|
|
|
hash = "sha256-qPnlSl1s9QWkODqbrfzIVFLXtDVEmTOihBlDmvHoknY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
nativeBuildInputs = [
|
2023-07-15 17:15:38 +00:00
|
|
|
pkg-config
|
|
|
|
cargo
|
|
|
|
rustc
|
|
|
|
rustPlatform.cargoSetupHook
|
|
|
|
rustPlatform.bindgenHook
|
|
|
|
makeWrapper
|
2024-07-27 06:49:29 +00:00
|
|
|
installShellFiles
|
2023-01-11 07:51:40 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildInputs = [
|
2023-07-15 17:15:38 +00:00
|
|
|
libaio
|
|
|
|
keyutils
|
|
|
|
lz4
|
|
|
|
|
|
|
|
libsodium
|
|
|
|
liburcu
|
|
|
|
libuuid
|
|
|
|
zstd
|
|
|
|
zlib
|
|
|
|
attr
|
|
|
|
udev
|
2021-01-15 22:18:51 +00:00
|
|
|
] ++ lib.optional fuseSupport fuse3;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
cargoDeps = rustPlatform.fetchCargoTarball {
|
|
|
|
src = finalAttrs.src;
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-ufzxFEgeOaOcZKEPx7kT64Pj2oz6m35exqXQlKxXGb4=";
|
2024-05-15 15:35:15 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=${placeholder "out"}"
|
2024-01-02 11:29:13 +00:00
|
|
|
"VERSION=${finalAttrs.version}"
|
2023-07-15 17:15:38 +00:00
|
|
|
"INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
|
2024-05-15 15:35:15 +00:00
|
|
|
] ++ lib.optional fuseSupport "BCACHEFS_FUSE=1";
|
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
env = {
|
|
|
|
CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
|
|
|
|
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc";
|
|
|
|
};
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
# FIXME: Try enabling this once the default linux kernel is at least 6.7
|
|
|
|
doCheck = false; # needs bcachefs module loaded on builder
|
|
|
|
|
2024-07-01 15:47:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace-fail "target/release/bcachefs" "target/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/bcachefs"
|
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
preCheck = lib.optionalString (!fuseSupport) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
rm tests/test_fuse.py
|
|
|
|
'';
|
2024-05-15 15:35:15 +00:00
|
|
|
checkFlags = [ "BCACHEFS_TEST_USE_VALGRIND=no" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
# Tries to install to the 'systemd-minimal' and 'udev' nix installation paths
|
|
|
|
installFlags = [
|
|
|
|
"PKGCONFIG_SERVICEDIR=$(out)/lib/systemd/system"
|
|
|
|
"PKGCONFIG_UDEVDIR=$(out)/lib/udev"
|
|
|
|
];
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
postInstall =
|
|
|
|
''
|
|
|
|
substituteInPlace $out/libexec/bcachefsck_all \
|
|
|
|
--replace-fail "/usr/bin/python3" "${python3.interpreter}"
|
|
|
|
''
|
|
|
|
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
installShellCompletion --cmd bcachefs \
|
|
|
|
--bash <($out/sbin/bcachefs completions bash) \
|
|
|
|
--zsh <($out/sbin/bcachefs completions zsh) \
|
|
|
|
--fish <($out/sbin/bcachefs completions fish)
|
|
|
|
'';
|
2024-01-25 14:12:00 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
passthru = {
|
|
|
|
tests = {
|
2024-07-27 06:49:29 +00:00
|
|
|
version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
command = "${finalAttrs.meta.mainProgram} version";
|
|
|
|
version = "${finalAttrs.version}";
|
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
smoke-test = nixosTests.bcachefs;
|
2024-01-13 08:15:51 +00:00
|
|
|
inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
|
2024-01-02 11:29:13 +00:00
|
|
|
};
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
updateScript = nix-update-script { };
|
2021-05-20 23:08:51 +00:00
|
|
|
};
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2024-05-15 15:35:15 +00:00
|
|
|
meta = {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Tool for managing bcachefs filesystems";
|
|
|
|
homepage = "https://bcachefs.org/";
|
2024-05-15 15:35:15 +00:00
|
|
|
license = lib.licenses.gpl2Only;
|
|
|
|
maintainers = with lib.maintainers; [
|
|
|
|
davidak
|
|
|
|
johnrtitor
|
|
|
|
Madouura
|
|
|
|
];
|
|
|
|
platforms = lib.platforms.linux;
|
2024-07-27 06:49:29 +00:00
|
|
|
mainProgram = "bcachefs";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2024-01-02 11:29:13 +00:00
|
|
|
})
|