Closed AlexSherbinin closed 5 months ago
good catch. thanks.
@AlexSherbinin There is another issue I'm currently investigating. All #include
s which reference files outside of docs
folder are not replaced with the content. So, there is difference in running nix build -o book
and nix develop + mdbook build
. The former runs in chroot it seems which can be observed by changing buildPhase
string (e.g. adding spaces just to invalidate hash, is there a way to force rebuild without this change?) and running nix build -L -o book
.
This seems reasonable as tests/examples should also be treated as inputs to the build so rebuild should be triggered when something in these folder changes. I'm just not sure how to bring this to the inputs and allow for relative paths in include references to work as usual.
One way this might be fixed is moving flake.nix to the root of the project. Maybe even using flake to setup Rust, cargo and everything. But I'm still considering are there any downsides.
One way this might be fixed is moving flake.nix to the root of the project. Maybe even using flake to setup Rust, cargo and everything. But I'm still considering are there any downsides.
Good idea. I recommend to use crane for building with cargo and rust-overlay to setup toolchain. But there is one downside: you cannot access the network while a buildPhase, because Nix's flakes are evaluated in a sandbox. Why is it a downside? For example I was trying to setup cargo-deny to check dependencies of my project for vulnerabilities and it wasn't working because it downloads RustSec DB while building(to fix it I was needed to use cargo-audit instead and download DB as a flake input). And there can be other tools that are using the network while buildPhase.
Also, if you don't want to wrap the entire project with Nix. There's a solution, but It's not really good: add tests/examples directories as flake's inputs(to do this there's a git+file://
path prefix) and every time when updating these directories you we'll needed to commit it and run nix flake update
to update flake.lock
Also, if you don't want to wrap the entire project with Nix. There's a solution, but It's not really good: add tests/examples directories as flake's inputs(to do this there's a
git+file://
path prefix) and every time when updating these directories you we'll needed to commit it and runnix flake update
to updateflake.lock
Ah, thanks. Yeah, not very good solution but good to know. I guess that in #include
I couldn't use relative paths as inputs would come from the Nix store, right? That would be another problem.
I moved flake file to root for now and did a basic Rust config through overlay. When I find some time I'll look into setting up full build/test/CI to use Nix.
I guess that in
#include
I couldn't use relative paths as inputs would come from the Nix store, right?
By default - couldn't. But you can create symlink in buildPhase script from example-flake-input.outPath
to the root of your chroot environment
Noticed this error in Architecture section. The reason was in PlantUML's binary location:
mdbook-plantuml
expects that it placed in/usr/bin
directory while it placed in/nix