mirror of
https://github.com/koverstreet/bcachefs-tools.git
synced 2025-02-23 00:00:02 +03:00
Merge pull request #278 from tmuehlbacher/add-more-flake-checks
Add more flake checks
This commit is contained in:
commit
c36b96d4dc
@ -17,8 +17,9 @@ Build dependencies:
|
|||||||
* zlib1g
|
* zlib1g
|
||||||
|
|
||||||
In addition a recent Rust toolchain is required (rustc, cargo), either by using
|
In addition a recent Rust toolchain is required (rustc, cargo), either by using
|
||||||
[rustup](https://rustup.rs/) or make sure to use a distribution where rustc (>=1.65)
|
[rustup](https://rustup.rs/) or make sure to use a distribution where a recent
|
||||||
is available.
|
enough rustc is available. Please check `rust-version` in `Cargo.toml` to see
|
||||||
|
the minimum supported Rust version (MSRV).
|
||||||
|
|
||||||
``` shell
|
``` shell
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
|
||||||
|
77
build.nix
77
build.nix
@ -1,77 +0,0 @@
|
|||||||
{
|
|
||||||
lib,
|
|
||||||
stdenv,
|
|
||||||
pkg-config,
|
|
||||||
attr,
|
|
||||||
libuuid,
|
|
||||||
libsodium,
|
|
||||||
keyutils,
|
|
||||||
liburcu,
|
|
||||||
zlib,
|
|
||||||
libaio,
|
|
||||||
udev,
|
|
||||||
zstd,
|
|
||||||
lz4,
|
|
||||||
nix-gitignore,
|
|
||||||
rustPlatform,
|
|
||||||
rustc,
|
|
||||||
cargo,
|
|
||||||
fuse3,
|
|
||||||
fuseSupport ? false,
|
|
||||||
}:
|
|
||||||
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
|
|
||||||
cargo
|
|
||||||
rustc
|
|
||||||
rustPlatform.cargoSetupHook
|
|
||||||
rustPlatform.bindgenHook
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
libaio
|
|
||||||
keyutils # libkeyutils
|
|
||||||
lz4 # liblz4
|
|
||||||
|
|
||||||
libsodium
|
|
||||||
liburcu
|
|
||||||
libuuid
|
|
||||||
zstd # libzstd
|
|
||||||
zlib # zlib1g
|
|
||||||
attr
|
|
||||||
udev
|
|
||||||
] ++ lib.optional fuseSupport fuse3;
|
|
||||||
|
|
||||||
${if fuseSupport then "BCACHEFS_FUSE" else null} = "1";
|
|
||||||
|
|
||||||
cargoRoot = ".";
|
|
||||||
# when git-based crates are updated, run:
|
|
||||||
# nix run github:Mic92/nix-update -- --version=skip --flake default
|
|
||||||
# to update the hashes
|
|
||||||
cargoDeps = rustPlatform.importCargoLock { lockFile = "${src}/Cargo.lock"; };
|
|
||||||
|
|
||||||
makeFlags = [
|
|
||||||
"DESTDIR=${placeholder "out"}"
|
|
||||||
"PREFIX="
|
|
||||||
"VERSION=${commit}"
|
|
||||||
];
|
|
||||||
|
|
||||||
dontStrip = true;
|
|
||||||
checkPhase = "./target/release/bcachefs version";
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
mainProgram = "bcachefs";
|
|
||||||
license = lib.licenses.gpl2Only;
|
|
||||||
};
|
|
||||||
}
|
|
21
flake.lock
21
flake.lock
@ -1,5 +1,25 @@
|
|||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1716745752,
|
||||||
|
"narHash": "sha256-8K1R9Yg4r08rYk86Yq+lu3E9L3uRUb4xMqYHgl0VGS0=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "19ca94ec2d288de334ae932107816b4a97736cd8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"fenix": {
|
"fenix": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
@ -85,6 +105,7 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"flake-compat": "flake-compat",
|
"flake-compat": "flake-compat",
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
|
106
flake.nix
106
flake.nix
@ -11,6 +11,11 @@
|
|||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
crane = {
|
||||||
|
url = "github:ipetkov/crane";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
fenix = {
|
fenix = {
|
||||||
url = "github:nix-community/fenix";
|
url = "github:nix-community/fenix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
@ -29,7 +34,7 @@
|
|||||||
flake-parts,
|
flake-parts,
|
||||||
treefmt-nix,
|
treefmt-nix,
|
||||||
fenix,
|
fenix,
|
||||||
flake-compat,
|
crane,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
@ -46,18 +51,110 @@
|
|||||||
{
|
{
|
||||||
self',
|
self',
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
|
rustfmtToml = builtins.fromTOML (builtins.readFile ./rustfmt.toml);
|
||||||
|
|
||||||
|
craneLib = crane.mkLib pkgs;
|
||||||
|
|
||||||
|
commit = lib.strings.substring 0 7 (builtins.readFile ./.bcachefs_revision);
|
||||||
|
|
||||||
|
commonArgs = {
|
||||||
|
version = "git-${commit}";
|
||||||
|
src = self;
|
||||||
|
|
||||||
|
makeFlags = [
|
||||||
|
"DESTDIR=${placeholder "out"}"
|
||||||
|
"PREFIX="
|
||||||
|
"VERSION=${commit}"
|
||||||
|
];
|
||||||
|
|
||||||
|
dontStrip = true;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
rustPlatform.bindgenHook
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
attr
|
||||||
|
keyutils
|
||||||
|
libaio
|
||||||
|
libsodium
|
||||||
|
liburcu
|
||||||
|
libuuid
|
||||||
|
lz4
|
||||||
|
udev
|
||||||
|
zlib
|
||||||
|
zstd
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // { pname = cargoToml.package.name; });
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.default = config.packages.bcachefs-tools;
|
packages.default = config.packages.bcachefs-tools;
|
||||||
packages.bcachefs-tools = pkgs.callPackage ./build.nix { };
|
packages.bcachefs-tools = craneLib.buildPackage (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
|
||||||
packages.bcachefs-tools-fuse = config.packages.bcachefs-tools.override { fuseSupport = true; };
|
enableParallelBuilding = true;
|
||||||
|
buildPhaseCargoCommand = ''
|
||||||
|
make ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES}} $makeFlags
|
||||||
|
'';
|
||||||
|
installPhaseCommand = ''
|
||||||
|
make ''${enableParallelBuilding:+-j''${NIX_BUILD_CORES}} $makeFlags install
|
||||||
|
'';
|
||||||
|
|
||||||
|
doInstallCheck = true;
|
||||||
|
installCheckPhase = ''
|
||||||
|
runHook preInstallCheck
|
||||||
|
|
||||||
|
test "$($out/bin/bcachefs version)" = "${commit}"
|
||||||
|
|
||||||
|
runHook postInstallCheck
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
packages.bcachefs-tools-fuse = config.packages.bcachefs-tools.overrideAttrs (
|
||||||
|
final: prev: {
|
||||||
|
makeFlags = prev.makeFlags ++ [ "BCACHEFS_FUSE=1" ];
|
||||||
|
buildInputs = prev.buildInputs ++ [ pkgs.fuse3 ];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
checks.cargo-clippy = craneLib.cargoClippy (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# we have to build our own `craneLib.cargoTest`
|
||||||
|
checks.cargo-test = craneLib.mkCargoDerivation (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
|
enableParallelChecking = true;
|
||||||
|
|
||||||
|
pnameSuffix = "-test";
|
||||||
|
buildPhaseCargoCommand = "";
|
||||||
|
checkPhaseCargoCommand = ''
|
||||||
|
make ''${enableParallelChecking:+-j''${NIX_BUILD_CORES}} $makeFlags libbcachefs.a
|
||||||
|
cargo test --profile release -- --nocapture
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
inputsFrom = [
|
inputsFrom = [
|
||||||
@ -65,8 +162,6 @@
|
|||||||
config.treefmt.build.devShell
|
config.treefmt.build.devShell
|
||||||
];
|
];
|
||||||
|
|
||||||
LIBCLANG_PATH = "${pkgs.clang.cc.lib}/lib";
|
|
||||||
|
|
||||||
# here go packages that aren't required for builds but are used for
|
# here go packages that aren't required for builds but are used for
|
||||||
# development, and might need to be version matched with build
|
# development, and might need to be version matched with build
|
||||||
# dependencies (e.g. clippy or rust-analyzer).
|
# dependencies (e.g. clippy or rust-analyzer).
|
||||||
@ -76,6 +171,7 @@
|
|||||||
clang-tools
|
clang-tools
|
||||||
clippy
|
clippy
|
||||||
rust-analyzer
|
rust-analyzer
|
||||||
|
rustc
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user