forked from Deuxfleurs/garage
Alex Auvolat
390a5d97fe
This removes our dependency on cargo2nix, which was causing us some issues. Whereas cargo2nix creates one Nix derivation per crate, Crane uses only two derivations: 1. Build dependencies only 2. Build the final binary This means that during the second step, no caching can be done. For instance, if we do a change in garage_model, we need to recompile all of the Garage crates including those that do not depend on garage_model. On the upside, this allows all of the Garage crates to be built at once using cargo build logic, which is optimized for high parallelism and better pipelining between all of the steps of the build. All in all, this makes most builds faster than cargo2nix. A few other changes have been made to the build scripts and CI: - Unit tests are now run within a Nix derivation. In fact, we have different derivations to run the tests using LMDB and Sqlite as metadata db engines. - For debug builds, most CI steps now run in parallel (with the notable exception of the smoke test that runs after the build, which is inevitable). - We no longer pass the GIT_VERSION argument when building debug builds and running the tests. This means that dev binaries and test binaries don't know the exact version of Garage they are from. That shouldn't be an issue in most cases. - The not-dynamic.sh scripts has been fixed to fail if the file does not exist.
85 lines
2.7 KiB
Nix
85 lines
2.7 KiB
Nix
{
|
|
description =
|
|
"Garage, an S3-compatible distributed object store for self-hosted deployments";
|
|
|
|
# Nixpkgs 24.11 as of 2025-01-12 has rustc v1.82
|
|
inputs.nixpkgs.url =
|
|
"github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815";
|
|
|
|
# Rust overlay as of 2025-01-12
|
|
inputs.rust-overlay.url =
|
|
"github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019";
|
|
inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.crane.url = "github:ipetkov/crane";
|
|
|
|
inputs.flake-compat.url = "github:nix-community/flake-compat";
|
|
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, ... }:
|
|
let
|
|
compile = import ./nix/compile.nix;
|
|
in
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
packageFor = target: release: (compile {
|
|
inherit system target nixpkgs crane rust-overlay release;
|
|
}).garage;
|
|
testWith = extraTestEnv: (compile {
|
|
inherit system nixpkgs crane rust-overlay extraTestEnv;
|
|
release = false;
|
|
}).garage-test;
|
|
in
|
|
{
|
|
packages = {
|
|
# default = native release build
|
|
default = packageFor null true;
|
|
|
|
# <arch> = cross-compiled, statically-linked release builds
|
|
amd64 = packageFor "x86_64-unknown-linux-musl" true;
|
|
i386 = packageFor "i686-unknown-linux-musl" true;
|
|
arm64 = packageFor "aarch64-unknown-linux-musl" true;
|
|
arm = packageFor "armv6l-unknown-linux-musl" true;
|
|
|
|
# dev = native dev build
|
|
dev = packageFor null false;
|
|
|
|
# test = cargo test
|
|
tests = testWith {};
|
|
tests-lmdb = testWith {
|
|
GARAGE_TEST_INTEGRATION_DB_ENGINE = "lmdb";
|
|
};
|
|
tests-sqlite = testWith {
|
|
GARAGE_TEST_INTEGRATION_DB_ENGINE = "sqlite";
|
|
};
|
|
};
|
|
|
|
# ---- developpment shell, for making native builds only ----
|
|
devShells =
|
|
let
|
|
targets = compile {
|
|
inherit system nixpkgs crane rust-overlay;
|
|
};
|
|
in
|
|
{
|
|
default = targets.devShell;
|
|
|
|
# import the full shell using `nix develop .#full`
|
|
full = pkgs.mkShell {
|
|
buildInputs = with pkgs; [
|
|
targets.toolchain
|
|
protobuf
|
|
clang
|
|
mold
|
|
# ---- extra packages for dev tasks ----
|
|
rust-analyzer
|
|
cargo-audit
|
|
cargo-outdated
|
|
cargo-machete
|
|
nixpkgs-fmt
|
|
];
|
|
};
|
|
};
|
|
});
|
|
}
|