Skip to content

Commit e2de1f9

Browse files
committed
feat: add nix packages and dev shell
This commit adds packages for the iroh-dns-server and iroh-relay binaries as well as a rust dev shell for development. To make the packaging work better (less redundant versions in ni flake) I also made the crate versions a workspace property that is inherited.
1 parent 7911255 commit e2de1f9

File tree

10 files changed

+182
-5
lines changed

10 files changed

+182
-5
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2+
/result
23
iroh.config.toml

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"iroh-relay",
88
]
99
resolver = "2"
10+
package.version = "0.35.0"
1011

1112
[profile.release]
1213
debug = true

flake.lock

+112
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
description = "Iroh workspace flake (with crane, workspace build)";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
crane.url = "github:ipetkov/crane";
8+
rust-overlay.url = "github:oxalica/rust-overlay";
9+
};
10+
11+
outputs = { self, nixpkgs, flake-utils, crane, rust-overlay, ... }:
12+
flake-utils.lib.eachDefaultSystem (system:
13+
let
14+
pkgs = import nixpkgs {
15+
inherit system;
16+
overlays = [ (import rust-overlay) ];
17+
};
18+
craneLib = crane.mkLib pkgs;
19+
20+
src = craneLib.cleanCargoSource ./.;
21+
22+
commonArgs = {
23+
inherit src;
24+
strictDeps = true;
25+
cargoExtraArgs = "--features server";
26+
};
27+
28+
workspace-artifacts = craneLib.buildDepsOnly (commonArgs // {
29+
pname = "iroh-workspace";
30+
});
31+
32+
iroh-relay = craneLib.buildPackage (commonArgs // {
33+
pname = "iroh-relay";
34+
cargoArtifacts = workspace-artifacts;
35+
doCheck = false;
36+
cargoBuildCommand = "cargo build --release --bin iroh-relay";
37+
installPhase = ''
38+
mkdir -p $out/bin
39+
cp target/release/iroh-relay $out/bin/
40+
'';
41+
});
42+
43+
iroh-dns-server = craneLib.buildPackage (commonArgs // {
44+
pname = "iroh-dns-server";
45+
cargoArtifacts = workspace-artifacts;
46+
doCheck = false;
47+
cargoBuildCommand = "cargo build --release --bin iroh-dns-server";
48+
installPhase = ''
49+
mkdir -p $out/bin
50+
cp target/release/iroh-dns-server $out/bin/
51+
'';
52+
});
53+
in {
54+
packages.iroh-relay = iroh-relay;
55+
packages.iroh-dns-server = iroh-dns-server;
56+
devShells.default = craneLib.devShell {
57+
checks = { workspace = workspace-artifacts; };
58+
packages = [ pkgs.rust-analyzer pkgs.bashInteractive ];
59+
};
60+
}
61+
);
62+
}

iroh-base/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-base"
3-
version = "0.35.0"
3+
version = { workspace = true }
44
edition = "2021"
55
readme = "README.md"
66
description = "base type and utilities for Iroh"

iroh-dns-server/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-dns-server"
3-
version = "0.35.0"
3+
version = { workspace = true }
44
edition = "2021"
55
description = "A pkarr relay and DNS server"
66
license = "MIT OR Apache-2.0"

iroh-relay/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-relay"
3-
version = "0.35.0"
3+
version = { workspace = true }
44
edition = "2021"
55
readme = "README.md"
66
description = "Iroh's relay server and client"

iroh/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh"
3-
version = "0.35.0"
3+
version = { workspace = true }
44
edition = "2021"
55
readme = "README.md"
66
description = "p2p quic connections dialed by public key"

iroh/bench/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "iroh-bench"
3-
version = "0.35.0"
3+
version = { workspace = true }
44
edition = "2021"
55
license = "MIT OR Apache-2.0"
66
publish = false

0 commit comments

Comments
 (0)