Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Nix flake and Nix dev shell using flakebox #88

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Oct 17, 2024

For Nix users like me, this allows bunch of interesting things:

nix develop will give a dev shell with Rust toolchain, ready to hack on the project.

Easy cross-compilation:

nix build .#aarch64-android.dev.pkarr-server && file result/bin/pkarr-server
result/bin/pkarr-server: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
> nix build .#riscv64-linux.dev.pkarr-server && file result/bin/pkarr-server
result/bin/pkarr-server: ELF 64-bit LSB pie executable, UCB RISC-V, RVC, double-float ABI, version 1 (SYSV), dynamically linked, interpreter /nix/store/7ac9zpgfw70544ca66dg1lsd4w8nyp0k-glibc-riscv64-unknown-linux-gnu-2.39-52/lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped

After this lands any Nix user can seamlessly start pkarr-server with nix run github:pubky/pkarr#pkarr-server. Can be tested before that with:

> nix run github:dpc/pkarr/24-10-17-nixify#pkarr-server
2024-10-17T18:05:57.836178Z  INFO pkarr_server: Running as a resolver on UDP socket 0.0.0.0:6881
2024-10-17T18:05:57.836253Z  INFO pkarr_server::http_server: HTTP server listening on 0.0.0.0:6881

@dpc dpc force-pushed the 24-10-17-nixify branch from 5c5519a to a2666b2 Compare October 17, 2024 18:07
@dpc
Copy link
Contributor Author

dpc commented Oct 17, 2024

BTW. Are you sure you don't want pkarr-server to be named pkarrd? :D

@Nuhvi
Copy link
Collaborator

Nuhvi commented Oct 18, 2024

BTW. Are you sure you don't want pkarr-server to be named pkarrd? :D

Pkarr server is a combination of a Relay (for browsers support) and a Resolver (Dht super node) to help lower latency on the native side.

They are not meant to be daemons, instead they are meant to be super nodes / gateways more like DNS resolvers than anything else.

You don't need them in native environment, and in browser, you are better off using globally popular relays (because they have better caches).

Of course, the Relay can still be used as local daemon for browser based applications like Electron, but that isn't what it is intended for.

@Nuhvi
Copy link
Collaborator

Nuhvi commented Oct 18, 2024

@dpc would arguments pass naturally? so if I want to pass a path to config file would that work?

Also, I know almost nothing about Nix, so unless you want to add more things I can merge.

Finally, note that I am doing a lot of work on the V3 branch, and I wonder if merging that to main will eventually affect you (I will pump the Cargo.toml version of course).

@dpc
Copy link
Contributor Author

dpc commented Oct 18, 2024

@dpc would arguments pass naturally? so if I want to pass a path to config file would that work?

An extra -- might be needd so that nix run ... knows when the arguments to itself ended, but yeah, everything should work as expected.

> nix run github:dpc/pkarr/24-10-17-nixify#pkarr-server -- --help
Usage: pkarr-server [OPTIONS]

Options:
  -c, --config <CONFIG>                          Path to config file
  -t, --tracing-env-filter <TRACING_ENV_FILTER>  [tracing_subscriber::EnvFilter]
  -h, --help                                     Print help

Finally, note that I am doing a lot of work on the V3 branch, and I wonder if merging that to main will eventually affect you (I will pump the Cargo.toml version of course).

Do you plan to merge V3 into main? Anyway, it's all easily fixable, and from my PoV it's mostly about being able to bring dev version of Pkarr into a Nix config easily. The nixpkgs PR hopefully lands as well, so that would allow easily bringing the official releases.

@Nuhvi
Copy link
Collaborator

Nuhvi commented Oct 19, 2024

Yes, I plant to merge V3, but not sure when, there is still couple of big features I need to add, and I don't want to merge what exists now without making sure these features won't require another breaking change.

@Nuhvi Nuhvi merged commit 2ef810b into pubky:main Oct 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants