-
-
Notifications
You must be signed in to change notification settings - Fork 390
[nix] add a flake.nix
based on flakebox
.
#2212
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for making this happen.
I see a lot of benefit in reproducible builds and supporting more of nix
in general.
However, as I am not using really using it, I think we'd need more support for maintaining it.
- CI also tests the build by calling a new target in the
justfile
- the
justfile
can be used locally as well in case CI breaks for reproduction - one of the markdown files, maybe
DEVELOPMENT.md
should contain notes on how to get going withnix
, maybe just pointing to tutorials for major unix-like platforms.
Thanks a lot.
@@ -0,0 +1,121 @@ | |||
{ | |||
description = "`gitoxide` compiled in a nix shell, using `crane` and `flakebox`."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which binaries does it build specifically?
Closes #2211 (someday) This builds |
Thanks - I set it back to draft so once you undo that I will know it's ready for another review. |
Flakebox Matrix: https://matrix.to/#/#flakebox:matrix.org |
Just for clarity: I won't be joining on matrix in preference for less real-time communication here. Thanks for your understanding. |
fenix = { | ||
url = "github:nix-community/fenix"; | ||
inputs.nixpkgs.follows = "nixpkgs"; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see this input used anywhere. It is not used as an argument in line 19, and I can't find any other changes that indicate it being used. What's going on?
fenix = { | |
url = "github:nix-community/fenix"; | |
inputs.nixpkgs.follows = "nixpkgs"; | |
}; |
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" | ||
|
||
"etc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strangely formatted. Could you use a formatter, like alejandra
or nixpkgs-fmt
?
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" | |
"etc" | |
paths = [ | |
"Cargo.toml" | |
"Cargo.lock" | |
".cargo" | |
"etc" |
"gix-worktree-stream" | ||
"src" | ||
"tests" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
rustSrc = flakeboxLib.filterSubPaths { | ||
root = builtins.path { name = "gitoxide"; path = ./.; }; | ||
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, there is no .cargo
file or directory in this repository. So filtering for it is confusing. Probably remove it?
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" | |
paths = [ "Cargo.toml" "Cargo.lock" |
]; | ||
}; | ||
|
||
legacyPackages = (flakeboxLib.craneMultiBuild { }) (craneLib': let |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you say why you're planning to export legacyPackages
? What's the motivation here for this non-standard output?
|
||
rustSrc = flakeboxLib.filterSubPaths { | ||
root = builtins.path { name = "gitoxide"; path = ./.; }; | ||
paths = [ "Cargo.toml" "Cargo.lock" ".cargo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The list of paths is very long. How would this look like with a standard craneLib
filter and exclusions?
See:
https://github.com/rustshop/flakebox/blob/master/docs/building-new-project.md
I opened an issue on their repo concerning a breaking API change, and had the following discussion on Matrix:
today
c4lliope joined the room
c4lliope
hello - is anyone here? I'm seeing an odd error as I go through the basic guide:
https://github.com/rustshop/flakebox/blob/master/docs/building-new-project.md#extra-dependencies
why would flakebox.lib.x86_64-linux be missing?
dpc ⚡️
Hello. I'm here.
Oh. I think I made backward incompat change on the master and didn't update the docs. Sorry for that!
c4lliope
oh yay.
I copied the full flake here:
rustshop/flakebox#209
oh, sure.
dpc ⚡️
rustshop/flakebox@55f2249
Now the lib contains mkLib which you use to actually create the lib with given pkgs.
If you're short on time, just trying using previous commit.
c4lliope
ah, simple enough. I'll give it a spin.
dpc ⚡️
If you want to make the world a better place you can try to update the docs where it is different. It will be some
flakeboxLib = flakeboxLib.lib pkgs;
kind of thing, though you might use different names.Anyway, I'm not sure how experienced with Nix you are, there might be other adjustments needed. :D
c4lliope
seems to be building now, is a really big codebase though.
dpc ⚡️
I'm using flakebox for some really big codebases indeed.
https://github.com/fedimint/fedimint/blob/master/nix/flakebox.nix
c4lliope
ahhhh, hold up. rustc toolchain version problem?
yeah, gotta go unstable.
dpc ⚡️
The toolchain shipped with flakebox might be a bit out of date. I usually bring it in separately in my projects.
https://github.com/fedimint/fedimint/blob/e135fae7bdb485845dc92b5ba837f014b43e19cb/flake.nix#L17
c4lliope
If I use unstable nixpkgs, is that where it's fetching from?
sorry, my background is 90% nix 0% rust
i'll go fenix
dpc ⚡️
Fenix is good. You can get nightly and arbitrary releases, and even mix nightly rustfmt with stable toolchain etc.
c4lliope
ah, so this gitoxide codebase is a big monorepo with a bunch of sub-folders. One of those is gix-actor, and flakebox is unable to load the Cargo.toml from that pkg.
dpc ⚡️
Did you add it to sources?
https://github.com/rustshop/flakebox/blob/261180f894d74ab95f7afbf14c7418fedb0d3cbf/flake.nix#L78
Flakebox comes with some handy source filtering to avoid rebuilding stuff when no relevant files changed.
BTW. I hope you're aware that flakebox is mostly an opinionated wrapper around https://github.com/ipetkov/crane , mostly adding some stuff I needed and integrating cross-compilation.
c4lliope
yeah, I printed out the crane docs to my tablet so I can read through and see if there's a more minimal option.
but if this can compile before my 3pm meeting, I'm happy throwing the full arsenal at it.
oh, so the main goal is to get a .wasm out of gitoxide. I'm sure I'll need to go through and add wasm_bindgen annotations, but what would the nix build ... command look like?
is there a different system label, so nix can cross-compile? or do I handle that in the Cargo.toml target specification like the official docs say?
dpc ⚡️
https://github.com/fedimint/fedimint/blob/e135fae7bdb485845dc92b5ba837f014b43e19cb/.github/workflows/ci-nix.yml#L286
https://github.com/fedimint/fedimint/blob/e135fae7bdb485845dc92b5ba837f014b43e19cb/.github/workflows/ci-nix.yml#L213
c4lliope
holy heck.
dpc ⚡️
?
c4lliope
build is success
you all are genius. thank you so much, nixos has made getting close to rust a pain until now.
before this my flakes have only been enough for "hello world", the basics from the textbook.