This commit is contained in:
mjallen18
2026-02-23 18:13:56 -06:00
parent 2e0d6aebb5
commit 4c5118c181
5 changed files with 215 additions and 3 deletions

View 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
};
})

View 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
;
};
}

View File

@@ -42,12 +42,20 @@
"rc": {
"sources": {
"linux": {
"version": "6.19-rc8",
"hash": "sha256-oNENklaRhhcEryz9brMCfqgNHN2oYjodtrIbPncazQk="
"version": "7.0-rc1",
"hash": "sha256-bWsr0T/pXqSMSQHKW0Ueu8U2xjAQSdH7cFaNXYdWqts="
},
"zfs": {
"rev": "3bf17cf5387fa5e0044a6321e663aead38b45969",
"hash": "sha256-KaN24a1nXwOoHahglRWSypqxlE5jM1uZVIOVd1CDrqQ="
},
"config": {
"rev": "a66bf7797191c614066a517921246ced3b263434",
"hash": "sha256-GUEG4ZYawtSaN194CO6uPKdTR4e48+3E3dRIaX0K/8s="
},
"patches": {
"rev": "6184689fad8d8933f646025245295d4d50e20eb9",
"hash": "sha256-RBRIhHoqU+L+KDr23mNGR55if28KZ+heNp/BpCZISJ4="
}
}
},

View File

@@ -5,7 +5,7 @@
...
}:
let
kernel = pkgs.${namespace}.linuxPackages_cachyos-lto-znver4;
kernel = pkgs.${namespace}.linuxPackages_cachyos-rc-lto-znver4;
pkgsVersion = pkgs; # .unstable;
in
{
@@ -43,6 +43,8 @@ in
kernelPackages = kernel;
bcachefs.package = pkgs.${namespace}.bcachefs;
kernelParams = [
# needed cause ssd powersaving is broken af I guess
"nvme_core.default_ps_max_latency_us=0"

View File

@@ -88,6 +88,11 @@
# };
specialisation = {
"linux_cachyos-lto".configuration = {
boot = {
kernelPackages = lib.mkOverride 90 pkgs.${namespace}.linuxPackages_cachyos-lto-znver4;
};
};
"cosmic" = {
configuration = {
${namespace} = {