cachy
This commit is contained in:
150
packages/bcachefs/default.nix
Normal file
150
packages/bcachefs/default.nix
Normal file
@@ -0,0 +1,150 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
pkg-config,
|
||||
libuuid,
|
||||
libsodium,
|
||||
keyutils,
|
||||
liburcu,
|
||||
zlib,
|
||||
libaio,
|
||||
zstd,
|
||||
lz4,
|
||||
attr,
|
||||
udev,
|
||||
fuse3,
|
||||
cargo,
|
||||
rustc,
|
||||
rustPlatform,
|
||||
makeWrapper,
|
||||
nix-update-script,
|
||||
versionCheckHook,
|
||||
nixosTests,
|
||||
installShellFiles,
|
||||
fuseSupport ? false,
|
||||
udevCheckHook,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "bcachefs-tools";
|
||||
version = "1.35.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "koverstreet";
|
||||
repo = "bcachefs-tools";
|
||||
tag = "v${finalAttrs.version}";
|
||||
hash = "sha256-1p2zbzQLza8w+hu+5OjPr+Lh6q6Kh9HdVxFkuCl2x8o=";
|
||||
};
|
||||
|
||||
cargoDeps = rustPlatform.fetchCargoVendor {
|
||||
inherit (finalAttrs) src;
|
||||
hash = "sha256-OlXkshfEXtY6fDBqhEJQhWhPjwQ5ofDIZ9IuchchKxk=";
|
||||
};
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace Makefile \
|
||||
--replace-fail "target/release/bcachefs" "target/${stdenv.hostPlatform.rust.rustcTargetSpec}/release/bcachefs"
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
cargo
|
||||
rustc
|
||||
rustPlatform.cargoSetupHook
|
||||
rustPlatform.bindgenHook
|
||||
makeWrapper
|
||||
installShellFiles
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
libaio
|
||||
keyutils
|
||||
lz4
|
||||
libsodium
|
||||
liburcu
|
||||
libuuid
|
||||
zstd
|
||||
zlib
|
||||
attr
|
||||
udev
|
||||
]
|
||||
++ lib.optional fuseSupport fuse3;
|
||||
|
||||
makeFlags = [
|
||||
"PREFIX=${placeholder "out"}"
|
||||
"VERSION=${finalAttrs.version}"
|
||||
"INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
|
||||
"DKMSDIR=${placeholder "dkms"}"
|
||||
|
||||
# Tries to install to the 'systemd-minimal' and 'udev' nix installation paths
|
||||
"PKGCONFIG_SERVICEDIR=$(out)/lib/systemd/system"
|
||||
"PKGCONFIG_UDEVDIR=$(out)/lib/udev"
|
||||
]
|
||||
++ lib.optional fuseSupport "BCACHEFS_FUSE=1";
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
installFlags = [
|
||||
"install"
|
||||
"install_dkms"
|
||||
];
|
||||
|
||||
env = {
|
||||
CARGO_BUILD_TARGET = stdenv.hostPlatform.rust.rustcTargetSpec;
|
||||
"CARGO_TARGET_${stdenv.hostPlatform.rust.cargoEnvVarTarget}_LINKER" = "${stdenv.cc.targetPrefix}cc";
|
||||
};
|
||||
|
||||
# FIXME: Try enabling this once the default linux kernel is at least 6.7
|
||||
doCheck = false; # needs bcachefs module loaded on builder
|
||||
|
||||
preCheck = lib.optionalString (!fuseSupport) ''
|
||||
rm tests/test_fuse.py
|
||||
'';
|
||||
checkFlags = [ "BCACHEFS_TEST_USE_VALGRIND=no" ];
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [
|
||||
udevCheckHook
|
||||
versionCheckHook
|
||||
];
|
||||
versionCheckProgramArg = "version";
|
||||
|
||||
postInstall = 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)
|
||||
'';
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"dkms"
|
||||
];
|
||||
|
||||
passthru = {
|
||||
# See NOTE in linux-kernels.nix
|
||||
kernelModule = import ./kernel-module.nix finalAttrs.finalPackage;
|
||||
|
||||
tests = {
|
||||
smoke-test = nixosTests.bcachefs;
|
||||
inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
|
||||
};
|
||||
|
||||
updateScript = nix-update-script { };
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Tool for managing bcachefs filesystems";
|
||||
homepage = "https://bcachefs.org/";
|
||||
downloadPage = "https://github.com/koverstreet/bcachefs-tools";
|
||||
license = lib.licenses.gpl2Only;
|
||||
maintainers = with lib.maintainers; [
|
||||
davidak
|
||||
johnrtitor
|
||||
];
|
||||
platforms = lib.platforms.linux;
|
||||
mainProgram = "bcachefs";
|
||||
broken = stdenv.hostPlatform.isi686; # error: stack smashing detected
|
||||
};
|
||||
})
|
||||
47
packages/bcachefs/kernel-module.nix
Normal file
47
packages/bcachefs/kernel-module.nix
Normal file
@@ -0,0 +1,47 @@
|
||||
bcachefs-tools:
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
kernelModuleMakeFlags,
|
||||
kernel,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "bcachefs";
|
||||
version = "${kernel.version}-${bcachefs-tools.version}";
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
src = bcachefs-tools.dkms;
|
||||
|
||||
nativeBuildInputs = kernel.moduleBuildDependencies;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
makeFlags = kernelModuleMakeFlags ++ [
|
||||
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
||||
"INSTALL_MOD_PATH=${placeholder "out"}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$(pwd) modules_install "''${makeFlags[@]}" "''${installFlags[@]}"
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit (bcachefs-tools.passthru) tests;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "out-of-tree bcachefs kernel module";
|
||||
|
||||
inherit (bcachefs-tools.meta)
|
||||
homepage
|
||||
downloadPage
|
||||
license
|
||||
maintainers
|
||||
platforms
|
||||
;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user