From 9d8360573622475232cee463291596273c5df1d3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 12 Jan 2025 17:34:04 +0100 Subject: flake: update versions of nixpkgs and rust-overlay --- flake.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index e690aef1..91340245 100644 --- a/flake.nix +++ b/flake.nix @@ -2,9 +2,9 @@ description = "Garage, an S3-compatible distributed object store for self-hosted deployments"; - # Nixpkgs 24.05 as of 2024-08-26 has rustc v1.77 + # Nixpkgs 24.11 as of 2025-01-12 has rustc v1.82 inputs.nixpkgs.url = - "github:NixOS/nixpkgs/0239aeb2f82ea27ccd6b61582b8f7fb8750eeada"; + "github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815"; inputs.flake-compat.url = "github:nix-community/flake-compat"; @@ -17,9 +17,9 @@ # - rustc v1.66 # url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2"; - # Rust overlay as of 2024-08-26 + # Rust overlay as of 2025-01-12 inputs.rust-overlay.url = - "github:oxalica/rust-overlay/19b70f147b9c67a759e35824b241f1ed92e46694"; + "github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-compat.follows = "flake-compat"; -- cgit v1.2.3 From 8ddb0dd485cf8290b7e3462f5614ca6d858ea8c3 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 12 Jan 2025 18:16:23 +0100 Subject: nix build: switch to upstream cargo2nix (branch release-0.11.0) --- flake.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index 91340245..b1cb7dbb 100644 --- a/flake.nix +++ b/flake.nix @@ -10,13 +10,16 @@ inputs.cargo2nix = { # As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection - url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36"; + #url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36"; # As of 2023-04-25: # - my two patches were merged into unstable (one for clippy and one to "fix" feature detection) # - rustc v1.66 # url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2"; + # Mainline cargo2nix as of of 2025-01-12 (branch release-0.11.0) + url = "github:cargo2nix/cargo2nix/ae19a9e1f8f0880c088ea155ab66cee1fa001f59"; + # Rust overlay as of 2025-01-12 inputs.rust-overlay.url = "github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019"; -- cgit v1.2.3 From 390a5d97fece744bcad3c5b7b7d31b2722d0b092 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sat, 1 Feb 2025 21:48:10 +0100 Subject: nix, ci: build with Crane 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. --- flake.nix | 116 +++++++++++++++++++++++++++++--------------------------------- 1 file changed, 54 insertions(+), 62 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index b1cb7dbb..ccaeba29 100644 --- a/flake.nix +++ b/flake.nix @@ -6,88 +6,80 @@ inputs.nixpkgs.url = "github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815"; - inputs.flake-compat.url = "github:nix-community/flake-compat"; - - inputs.cargo2nix = { - # As of 2022-10-18: two small patches over unstable branch, one for clippy and one to fix feature detection - #url = "github:Alexis211/cargo2nix/a7a61179b66054904ef6a195d8da736eaaa06c36"; - - # As of 2023-04-25: - # - my two patches were merged into unstable (one for clippy and one to "fix" feature detection) - # - rustc v1.66 - # url = "github:cargo2nix/cargo2nix/8fb57a670f7993bfc24099c33eb9c5abb51f29a2"; - - # Mainline cargo2nix as of of 2025-01-12 (branch release-0.11.0) - url = "github:cargo2nix/cargo2nix/ae19a9e1f8f0880c088ea155ab66cee1fa001f59"; - - # Rust overlay as of 2025-01-12 - inputs.rust-overlay.url = - "github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019"; + # Rust overlay as of 2025-01-12 + inputs.rust-overlay.url = + "github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019"; + inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; - inputs.nixpkgs.follows = "nixpkgs"; - inputs.flake-compat.follows = "flake-compat"; - }; + inputs.crane.url = "github:ipetkov/crane"; - inputs.flake-utils.follows = "cargo2nix/flake-utils"; + inputs.flake-compat.url = "github:nix-community/flake-compat"; + inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, cargo2nix, flake-utils, ... }: + outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, ... }: let - git_version = self.lastModifiedDate; 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 = - let - packageFor = target: (compile { - inherit system git_version target; - pkgsSrc = nixpkgs; - cargo2nixOverlay = cargo2nix.overlays.default; - release = true; - }).workspace.garage { compileMode = "build"; }; - in - { - # default = native release build - default = packageFor null; - # other = cross-compiled, statically-linked builds - amd64 = packageFor "x86_64-unknown-linux-musl"; - i386 = packageFor "i686-unknown-linux-musl"; - arm64 = packageFor "aarch64-unknown-linux-musl"; - arm = packageFor "armv6l-unknown-linux-musl"; + packages = { + # default = native release build + default = packageFor null true; + + # = 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 - shellWithPackages = (packages: (compile { - inherit system git_version; - pkgsSrc = nixpkgs; - cargo2nixOverlay = cargo2nix.overlays.default; - }).workspaceShell { inherit packages; }); + targets = compile { + inherit system nixpkgs crane rust-overlay; + }; in { - default = shellWithPackages - (with pkgs; [ - rustfmt - clang - mold - ]); + default = targets.devShell; # import the full shell using `nix develop .#full` - full = shellWithPackages (with pkgs; [ - rustfmt - rust-analyzer - clang - mold - # ---- extra packages for dev tasks ---- - cargo-audit - cargo-outdated - cargo-machete - nixpkgs-fmt - ]); + 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 + ]; + }; }; }); } -- cgit v1.2.3 From ec1a4759233875f38f3cc6c56a36a62161334dfe Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 3 Feb 2025 16:55:14 +0100 Subject: build with rust 1.82.0 --- flake.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix index ccaeba29..fc599e0b 100644 --- a/flake.nix +++ b/flake.nix @@ -2,13 +2,13 @@ description = "Garage, an S3-compatible distributed object store for self-hosted deployments"; - # Nixpkgs 24.11 as of 2025-01-12 has rustc v1.82 + # Nixpkgs 24.11 as of 2025-01-12 inputs.nixpkgs.url = "github:NixOS/nixpkgs/7c4869c47090dd7f9f1bdfb49a22aea026996815"; - # Rust overlay as of 2025-01-12 + # Rust overlay as of 2025-02-03 inputs.rust-overlay.url = - "github:oxalica/rust-overlay/162ab0edc2936508470199b2e8e6c444a2535019"; + "github:oxalica/rust-overlay/35c6f8c4352f995ecd53896200769f80a3e8f22d"; inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; inputs.crane.url = "github:ipetkov/crane"; -- cgit v1.2.3