edgedb-cli
edgedb-cli copied to clipboard
chore(nix): initial flake
I was struggling to update nixpkgs's edgedb package, so I decied to nixify this repo instead. Why you could consider to use Nix:
- Declarative configuration of build system and dev shell
- Repoducable packages from any machine
- Same developer environment for every contributor. For example, share same edgedb version(s), rust toolchain etc.
- Make onboarding easier for new contributors, as they will not have problems with setup. All will run with few commands
- Attract users from Nix community
- Simplify CI setup, as it can use or share configuration from your dev shell: https://determinate.systems/posts/nix-github-actions
Right now it's already possible to build edgedb-cli package via nix build .?submodules=1. Result binary will be located in ./result/bin/edgedb
Current limitations:
- There is a little inconvinience because of using git submodules. Nix requires to pass
?submodules=1to handle this. For using in consumer flake.nix, following syntax is required:
edgedb-cli = {
type = "git";
url = "https://github.com/mrfoxpro/edgedb-cli.git";
submodules = true;
ref = "nix";
};
Related PR: https://github.com/NixOS/nix/pull/7862
- Tests should be adjusted to run in isolated environment. I disabled tests for now (https://github.com/MrFoxPro/edgedb-cli/blob/9e793dbba528a61612a72780c5a048796d3c162d/flake.nix#L55)
I also created draft PR with developer environment setup with edgedb-server (https://github.com/edgedb/edgedb-cli/pull/1160). Related: https://github.com/NixOS/nixpkgs/issues/179635#issuecomment-1667764435
Current used Nix libs:
flake-parts: framework for convinient cross-platform flake shape: https://flake.parts. Allows splitting flake to modules, also provides opportunity to confiure some usefull tools declaratively
fenix: convinient rust toolchain managment: https://github.com/nix-community/fenix. Allows creating single package from multiple toolchains (cargo, rustc, rustc-src, rustfmt, rust-analyzer, clippy and so on)
crane: https://crane.dev. Usefull tool for effecient building of Rust project. Caches cargo artifacts.
I think it would be nice to configure integration with cachix later, so users will download cached result instead of rebuilding themselfs
Not sure what happened, but now I can only build it via nix build "git+file://$(pwd)?submodules=1" and nix build .?submodules=1 stopped working for me on Nix 2.19.1
@MrFoxPro this looks promising. Can I take over this effort (including #1160), as I also need a dev shell with appropriate tooling?
In my opinion, this PR is good as it is, I would only split the crane modules up a bit, so downstream flakes don't need to run all of the tests (and thus don't need the git submodule).
@MrFoxPro this looks promising. Can I take over this effort (including #1160), as I also need a dev shell with appropriate tooling?
In my opinion, this PR is good as it is, I would only split the crane modules up a bit, so downstream flakes don't need to run all of the tests (and thus don't need the git submodule).
for sure, you can push your changes if you're maintainer
I think this has been superceded by #1160 . Going to close.
This flake also contains derivations for building edgedb-cli itself, not just a shell for development.
Although, I'm planning to adapt PR to edgedb/nix-packages, so it can remain closed.