Building imag with nix remote builds
This is mostly a reminder for myself how to do it, because the documentation non the nix side is pretty sparse.
What I want to do is to build imag on a remote server using nix 2.0 features - nix remote builds.
Here are the steps I did for achieving that goal:
- build the
Cargo.lock
file withcargo generate-lock
for the imag workspace - generate a
build.nix
file usingcarnix --standalone --src . --output build.nix Cargo.lock
- monkey-patching the generated nix file because
carnix
generates wrong pathes for thebuild.rs
file in the nix expressions. I did that with a simple substitude pattern in vim:%s/"\.\.\/\.\.\/\.\.\/build\.rs"/.\/build.rs/
- ensure the remote machine has nix 2.0
- use
NIX_REMOTE=ssh-ng://user@host nix build -f ./build.nix imag_0_7_0
to build imag on the remote machine.
Unfortunately, because the generated expressions do not use cargo
but
execute the rustc
compiler directly, the build fails because I need the
CARGO_BUILD_VERSION
and CARGO_PKG_VERSION
environment variables which are
set by cargo during the build.
I hope carnix
gets support for automatically adding those variables to the
build soonish, so I can build imag completely remote.