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.lockfile withcargo generate-lockfor the imag workspace - generate a
build.nixfile usingcarnix --standalone --src . --output build.nix Cargo.lock - monkey-patching the generated nix file because
carnixgenerates wrong pathes for thebuild.rsfile 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_0to 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.