Skip to content

Commit 6658edf

Browse files
mkg20001claude
andcommitted
feat: add nix flake with rust-overlay for reproducible builds
- Add flake.nix with oxalica/rust-overlay for consistent Rust toolchain - Add package.nix using cargoLock for dependency management - Add overlay.nix exposing rustToolchain and freenet-shared package - Fix build.rs to remove CARGO_BUILD_TARGET for native tool builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c2db133 commit 6658edf

5 files changed

Lines changed: 162 additions & 0 deletions

File tree

deploy-tool/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ fn main() {
4343
let status = Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
4444
.env("CARGO_TARGET_DIR", &nested_target_dir)
4545
.env_remove("CARGO_ENCODED_RUSTFLAGS")
46+
.env_remove("CARGO_BUILD_TARGET")
4647
.args([
4748
"build",
4849
"--release",

flake.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
description = "Freenet shared tools";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
rust-overlay = {
8+
url = "github:oxalica/rust-overlay";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
};
12+
13+
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
14+
flake-utils.lib.eachDefaultSystem (system:
15+
let
16+
pkgs = import nixpkgs {
17+
inherit system;
18+
overlays = [
19+
rust-overlay.overlays.default
20+
self.overlays.default
21+
];
22+
};
23+
in
24+
{
25+
packages = {
26+
freenet-shared = pkgs.freenet-shared;
27+
default = pkgs.freenet-shared;
28+
};
29+
30+
devShells.default = pkgs.mkShell {
31+
inputsFrom = [ pkgs.freenet-shared ];
32+
packages = [
33+
pkgs.rustToolchain
34+
];
35+
};
36+
}
37+
) // {
38+
overlays.default = import ./overlay.nix;
39+
};
40+
}

overlay.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
final: prev: {
2+
rustToolchain = final.rust-bin.stable.latest.default.override {
3+
extensions = [ "rust-src" "rust-analyzer" ];
4+
targets = [ "wasm32-unknown-unknown" ];
5+
};
6+
7+
freenet-shared = final.callPackage ./package.nix { };
8+
}

package.nix

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
lib,
3+
makeRustPlatform,
4+
rustToolchain,
5+
}:
6+
7+
let
8+
rustPlatform = makeRustPlatform {
9+
cargo = rustToolchain;
10+
rustc = rustToolchain;
11+
};
12+
in
13+
rustPlatform.buildRustPackage {
14+
pname = "freenet-shared";
15+
version = "0.1.0";
16+
17+
src = lib.cleanSource ./.;
18+
19+
cargoLock = {
20+
lockFile = ./Cargo.lock;
21+
};
22+
23+
# Only build the native binary tools, not the WASM contract
24+
cargoBuildFlags = [ "-p" "deploy-tool" "-p" "web-container-tool" ];
25+
26+
meta = with lib; {
27+
description = "Freenet shared tools";
28+
license = licenses.mit;
29+
maintainers = [ ];
30+
};
31+
}

0 commit comments

Comments
 (0)