mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-22 00:00:03 +03:00
nix fix up! Rust now integrated into bcachefs binary
Heavily simplified to just call make with the required rust dependencies. Signed-off-by: Daniel Hill <daniel@gluo.nz>
This commit is contained in:
parent
203e40fcf5
commit
bf359ac1ad
59
base.nix
59
base.nix
@ -1,59 +0,0 @@
|
|||||||
{ lib
|
|
||||||
, stdenvNoCC
|
|
||||||
, callPackage
|
|
||||||
, nixosTests
|
|
||||||
, autoPatchelfHook
|
|
||||||
, binary
|
|
||||||
, mount
|
|
||||||
, versionString ? "0.1"
|
|
||||||
}:
|
|
||||||
|
|
||||||
stdenvNoCC.mkDerivation {
|
|
||||||
pname = "bcachefs-tools";
|
|
||||||
|
|
||||||
version = "v0.1-flake-${versionString}";
|
|
||||||
|
|
||||||
nativeBuildInputs = [
|
|
||||||
binary
|
|
||||||
mount
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = mount.propagatedBuildInputs;
|
|
||||||
|
|
||||||
phases = [ "installPhase" ];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir $out
|
|
||||||
mkdir $out/bin
|
|
||||||
mkdir $out/lib
|
|
||||||
mkdir $out/share
|
|
||||||
mkdir $out/etc
|
|
||||||
cp -pr "${binary}/bin/"* $out/bin
|
|
||||||
cp -pr "${binary}/lib/"* $out/lib
|
|
||||||
cp -pr "${binary}/share/"* $out/share
|
|
||||||
cp -pr "${binary}/etc/"* $out/etc
|
|
||||||
cp -pr "${mount}/bin/"* $out/bin/
|
|
||||||
chmod u+w $out/bin/*
|
|
||||||
patchelf --add-rpath $out/lib $out/bin/bcachefs-mount
|
|
||||||
ln -s "$out/bin/bcachefs-mount" "$out/bin/mount.bcachefs"
|
|
||||||
ln -s "$out/bin" "$out/sbin"
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
tests = {
|
|
||||||
smoke-test = nixosTests.bcachefs;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
meta = with lib; {
|
|
||||||
description = "Userspace tools for bcachefs";
|
|
||||||
homepage = http://bcachefs.org;
|
|
||||||
license = licenses.gpl2;
|
|
||||||
platforms = platforms.linux;
|
|
||||||
maintainers =
|
|
||||||
[ "Kent Overstreet <kent.overstreet@gmail.com>"
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
129
binary.nix
129
binary.nix
@ -1,129 +0,0 @@
|
|||||||
{ lib
|
|
||||||
, stdenv
|
|
||||||
, pkg-config
|
|
||||||
, attr
|
|
||||||
, libuuid
|
|
||||||
, libsodium
|
|
||||||
, keyutils
|
|
||||||
|
|
||||||
, liburcu
|
|
||||||
, zlib
|
|
||||||
, libaio
|
|
||||||
, udev
|
|
||||||
, zstd
|
|
||||||
, lz4
|
|
||||||
|
|
||||||
, python39
|
|
||||||
, python39Packages
|
|
||||||
, docutils
|
|
||||||
, nixosTests
|
|
||||||
|
|
||||||
, versionString ? "0.1"
|
|
||||||
, doCheck ? true
|
|
||||||
, inShell ? false
|
|
||||||
, debugMode ? inShell
|
|
||||||
|
|
||||||
, testWithValgrind ? true
|
|
||||||
, valgrind
|
|
||||||
|
|
||||||
, fuseSupport ? false
|
|
||||||
, fuse3 ? null }:
|
|
||||||
|
|
||||||
assert fuseSupport -> fuse3 != null;
|
|
||||||
assert testWithValgrind -> valgrind != null;
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
pname = "bcachefs-bin";
|
|
||||||
|
|
||||||
version = "v0.1-flake-${versionString}";
|
|
||||||
VERSION = "v0.1-flake-${versionString}";
|
|
||||||
|
|
||||||
src = (lib.cleanSource (builtins.path { name = "bcachefs-tools-src"; path = ./. ;} ));
|
|
||||||
|
|
||||||
postPatch = "patchShebangs --build doc/macro2rst.py";
|
|
||||||
|
|
||||||
propagatedNativeBuildInputs = [
|
|
||||||
# used to find dependencies
|
|
||||||
## see ./INSTALL
|
|
||||||
pkg-config
|
|
||||||
];
|
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
|
||||||
# bcachefs explicit dependencies
|
|
||||||
## see ./INSTALL
|
|
||||||
libaio
|
|
||||||
|
|
||||||
# libblkid
|
|
||||||
keyutils # libkeyutils
|
|
||||||
lz4 # liblz4
|
|
||||||
|
|
||||||
libsodium
|
|
||||||
liburcu
|
|
||||||
libuuid
|
|
||||||
zstd # libzstd
|
|
||||||
zlib # zlib1g
|
|
||||||
|
|
||||||
# unspecified dependencies
|
|
||||||
attr
|
|
||||||
udev
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
# documentation depenedencies
|
|
||||||
docutils
|
|
||||||
python39Packages.pygments
|
|
||||||
] ++ (lib.optional fuseSupport fuse3)
|
|
||||||
++ (lib.optional testWithValgrind valgrind);
|
|
||||||
|
|
||||||
makeFlags = [
|
|
||||||
"PREFIX=${placeholder "out"}"
|
|
||||||
] ++ lib.optional debugMode "EXTRA_CFLAGS=-ggdb";
|
|
||||||
|
|
||||||
installFlags = [
|
|
||||||
"INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools"
|
|
||||||
];
|
|
||||||
|
|
||||||
doCheck = doCheck; # needs bcachefs module loaded on builder
|
|
||||||
|
|
||||||
checkInputs = [
|
|
||||||
python39Packages.pytest
|
|
||||||
python39Packages.pytest-xdist
|
|
||||||
] ++ lib.optional testWithValgrind valgrind;
|
|
||||||
|
|
||||||
checkFlags = [
|
|
||||||
"BCACHEFS_TEST_USE_VALGRIND=${if testWithValgrind then "yes" else "no"}"
|
|
||||||
# cannot escape spaces within make flags, quotes are stripped
|
|
||||||
"PYTEST_CMD=pytest" # "PYTEST_ARGS='-n4 --version'"
|
|
||||||
];
|
|
||||||
|
|
||||||
preCheck =
|
|
||||||
''
|
|
||||||
makeFlagsArray+=(PYTEST_ARGS="--verbose -n2")
|
|
||||||
'' +
|
|
||||||
lib.optionalString fuseSupport ''
|
|
||||||
rm tests/test_fuse.py
|
|
||||||
'';
|
|
||||||
|
|
||||||
dontStrip = debugMode;
|
|
||||||
passthru = {
|
|
||||||
bcachefs_revision = let
|
|
||||||
file = builtins.readFile ./.bcachefs_revision;
|
|
||||||
removeLineFeeds = str: lib.lists.foldr (lib.strings.removeSuffix) str ["\r" "\n"];
|
|
||||||
in removeLineFeeds file;
|
|
||||||
|
|
||||||
tests = {
|
|
||||||
smoke-test = nixosTests.bcachefs;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
|
||||||
meta = with lib; {
|
|
||||||
description = "Userspace tools for bcachefs";
|
|
||||||
homepage = http://bcachefs.org;
|
|
||||||
license = licenses.gpl2;
|
|
||||||
platforms = platforms.linux;
|
|
||||||
maintainers =
|
|
||||||
[ "Kent Overstreet <kent.overstreet@gmail.com>"
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
64
build.nix
Normal file
64
build.nix
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, pkg-config
|
||||||
|
, attr
|
||||||
|
, libuuid
|
||||||
|
, libsodium
|
||||||
|
, keyutils
|
||||||
|
, liburcu
|
||||||
|
, zlib
|
||||||
|
, libaio
|
||||||
|
, udev
|
||||||
|
, zstd
|
||||||
|
, lz4
|
||||||
|
, nix-gitignore
|
||||||
|
, rustPlatform
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
src = nix-gitignore.gitignoreSource [] ./. ;
|
||||||
|
|
||||||
|
commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision);
|
||||||
|
version = "git-${commit}";
|
||||||
|
|
||||||
|
in stdenv.mkDerivation {
|
||||||
|
inherit src version;
|
||||||
|
|
||||||
|
pname = "bcachefs-tools";
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
pkg-config
|
||||||
|
rustPlatform.cargoSetupHook
|
||||||
|
rustPlatform.rust.cargo
|
||||||
|
rustPlatform.rust.rustc
|
||||||
|
rustPlatform.bindgenHook
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
libaio
|
||||||
|
keyutils # libkeyutils
|
||||||
|
lz4 # liblz4
|
||||||
|
|
||||||
|
libsodium
|
||||||
|
liburcu
|
||||||
|
libuuid
|
||||||
|
zstd # libzstd
|
||||||
|
zlib # zlib1g
|
||||||
|
attr
|
||||||
|
udev
|
||||||
|
];
|
||||||
|
|
||||||
|
cargoRoot = "rust-src";
|
||||||
|
cargoDeps = rustPlatform.importCargoLock {
|
||||||
|
lockFile = "${src}/rust-src/Cargo.lock";
|
||||||
|
};
|
||||||
|
|
||||||
|
makeFlags = [
|
||||||
|
"PREFIX=${placeholder "out"}"
|
||||||
|
"VERSION=${commit}"
|
||||||
|
];
|
||||||
|
|
||||||
|
dontStrip = true;
|
||||||
|
checkPhase = "./bcachefs version";
|
||||||
|
doCheck = true;
|
||||||
|
}
|
18
flake.lock
18
flake.lock
@ -3,11 +3,11 @@
|
|||||||
"flake-compat": {
|
"flake-compat": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1668681692,
|
"lastModified": 1673956053,
|
||||||
"narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
|
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||||
"owner": "edolstra",
|
"owner": "edolstra",
|
||||||
"repo": "flake-compat",
|
"repo": "flake-compat",
|
||||||
"rev": "009399224d5e398d03b22badca40a37ac85412a1",
|
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -18,11 +18,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675183161,
|
"lastModified": 1677342105,
|
||||||
"narHash": "sha256-Zq8sNgAxDckpn7tJo7V1afRSk2eoVbu3OjI1QklGLNg=",
|
"narHash": "sha256-kv1fpkfCJGb0M+LZaCHFUuIS9kRIwyVgupHu86Y28nc=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "e1e1b192c1a5aab2960bf0a0bd53a2e8124fa18e",
|
"rev": "b1f87ca164a9684404c8829b851c3586c4d9f089",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -41,11 +41,11 @@
|
|||||||
},
|
},
|
||||||
"utils": {
|
"utils": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1667395993,
|
"lastModified": 1676283394,
|
||||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -13,16 +13,9 @@
|
|||||||
utils.lib.eachDefaultSystem (system:
|
utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
binary = pkgs.callPackage ./binary.nix {
|
bcachefs = pkgs.callPackage ./build.nix {};
|
||||||
testWithValgrind = false;
|
|
||||||
};
|
|
||||||
mount = pkgs.callPackage ./rust-src/default.nix { inherit binary; };
|
|
||||||
bcachefs = pkgs.callPackage ./base.nix {
|
|
||||||
inherit binary mount;
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
packages = {
|
packages = {
|
||||||
inherit binary mount;
|
|
||||||
default = bcachefs;
|
default = bcachefs;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
{ lib
|
|
||||||
, stdenv
|
|
||||||
, rustPlatform
|
|
||||||
, llvmPackages
|
|
||||||
, bcachefs
|
|
||||||
, pkg-config
|
|
||||||
, udev
|
|
||||||
, liburcu
|
|
||||||
, zstd
|
|
||||||
, keyutils
|
|
||||||
, libaio
|
|
||||||
, lz4 # liblz4
|
|
||||||
, libsodium
|
|
||||||
, libuuid
|
|
||||||
, zlib # zlib1g
|
|
||||||
, libscrypt
|
|
||||||
, rustfmt
|
|
||||||
, glibc
|
|
||||||
, ...
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
|
||||||
in
|
|
||||||
rustPlatform.buildRustPackage {
|
|
||||||
pname = cargo.package.name;
|
|
||||||
version = cargo.package.version;
|
|
||||||
|
|
||||||
src = builtins.path {
|
|
||||||
path = ./.;
|
|
||||||
name = "bch_bindgen";
|
|
||||||
};
|
|
||||||
|
|
||||||
cargoLock = { lockFile = ./Cargo.lock; };
|
|
||||||
|
|
||||||
propagatedNativeBuildInputs = [ rustPlatform.bindgenHook ];
|
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
|
||||||
bcachefs.tools
|
|
||||||
];
|
|
||||||
|
|
||||||
LIBBCACHEFS_LIB ="${bcachefs.tools}/lib";
|
|
||||||
LIBBCACHEFS_INCLUDE = bcachefs.tools.src;
|
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
cp ${./Cargo.lock} Cargo.lock
|
|
||||||
'';
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
{ lib
|
|
||||||
, stdenv
|
|
||||||
, glibc
|
|
||||||
, udev
|
|
||||||
, llvmPackages
|
|
||||||
, rustPlatform
|
|
||||||
, binary
|
|
||||||
, ...
|
|
||||||
}: rustPlatform.buildRustPackage ( let
|
|
||||||
cargo = lib.trivial.importTOML ./Cargo.toml;
|
|
||||||
in {
|
|
||||||
pname = "mount.bcachefs";
|
|
||||||
version = cargo.package.version;
|
|
||||||
|
|
||||||
src = builtins.path { path = ../.; name = "rust-src"; };
|
|
||||||
sourceRoot = "rust-src/mount";
|
|
||||||
|
|
||||||
cargoLock = { lockFile = ./Cargo.lock; };
|
|
||||||
|
|
||||||
nativeBuildInputs = [ binary rustPlatform.bindgenHook ];
|
|
||||||
buildInputs = [ binary ];
|
|
||||||
|
|
||||||
LIBBCACHEFS_LIB ="${binary}/lib";
|
|
||||||
LIBBCACHEFS_INCLUDE = binary.src;
|
|
||||||
|
|
||||||
doCheck = false;
|
|
||||||
})
|
|
@ -1,54 +0,0 @@
|
|||||||
## Mirrors: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/tasks/filesystems/bcachefs.nix
|
|
||||||
## with changes to use flakes and import mount.bcachefs
|
|
||||||
{ config, lib, pkgs, utils, ... }:
|
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems;
|
|
||||||
cfg = config.filesystems.bcachefs;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
|
||||||
options.filesystems.bcachefs.packages.tools = lib.mkOption {
|
|
||||||
description = "Which package to use to link in the bcachefs tools package";
|
|
||||||
default = pkgs.bcachefs.tools;
|
|
||||||
type = lib.types.package;
|
|
||||||
};
|
|
||||||
options.filesystems.bcachefs.packages.mount = lib.mkOption {
|
|
||||||
description = "Which package to use to link in the bcachefs mount package";
|
|
||||||
default = pkgs.bcachefs.mount;
|
|
||||||
type = lib.types.package;
|
|
||||||
};
|
|
||||||
options.filesystems.bcachefs.packages.kernelPackages = lib.mkOption {
|
|
||||||
description = "Which package to use to link in the kernel package to use";
|
|
||||||
default = pkgs.bcachefs.kernelPackages;
|
|
||||||
type = lib.types.attrs;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [
|
|
||||||
{
|
|
||||||
system.fsPackages = [ cfg.packages.tools cfg.packages.mount ];
|
|
||||||
|
|
||||||
# use kernel package with bcachefs support until it's in mainline
|
|
||||||
boot.kernelPackages = cfg.packages.kernelPackages;
|
|
||||||
}
|
|
||||||
|
|
||||||
(mkIf ((elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) {
|
|
||||||
# chacha20 and poly1305 are required only for decryption attempts
|
|
||||||
boot.initrd.availableKernelModules = [ "sha256" "chacha20" "poly1305" ];
|
|
||||||
boot.initrd.kernelModules = [ "bcachefs" ];
|
|
||||||
|
|
||||||
boot.initrd.extraUtilsCommands = ''
|
|
||||||
copy_bin_and_libs ${cfg.packages.tools}/bin/bcachefs
|
|
||||||
copy_bin_and_libs ${cfg.packages.mount}/bin/mount.bcachefs
|
|
||||||
'';
|
|
||||||
boot.initrd.extraUtilsCommandsTest = ''
|
|
||||||
$out/bin/bcachefs version
|
|
||||||
$out/bin/mount.bcachefs --version
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
|
21
shell.nix
21
shell.nix
@ -1,21 +0,0 @@
|
|||||||
{ kversion ? "linux_5_15"
|
|
||||||
, pkgs ? import <nixpkgs> {} }:
|
|
||||||
|
|
||||||
with pkgs;
|
|
||||||
|
|
||||||
let
|
|
||||||
tools = pkgs.callPackage ./default.nix { doCheck = false ;} ;
|
|
||||||
in
|
|
||||||
mkShell {
|
|
||||||
buildInputs = [
|
|
||||||
linuxKernel.packages.${kversion}.perf
|
|
||||||
gdb
|
|
||||||
# lsp code completion in neovim/emacs
|
|
||||||
clangd
|
|
||||||
rust-analyzer
|
|
||||||
rnix-lsp
|
|
||||||
];
|
|
||||||
inputsFrom = [
|
|
||||||
tools
|
|
||||||
];
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user