Way to get NVM working in CI/CD systems
timor.site
timor.site
That said, rtx is so much simpler for this:
curl https://rtx.pub/rtx-latest-linux-x64 > /usr/bin/rtx
rtx install
rtx x -- npm install
rtx x -- npm run test
it'll automatically use the .nvmrc/.node-version file. If developers want to use nvm locally, they still can.- Go projects are built with https://github.com/nix-community/gomod2nix. We generate a list of internal packages a project depends on using `go list -json` that is then passed to gomod2nix's `buildGoApplication`.
- Rust projects are built with https://github.com/cargo2nix/cargo2nix. We chose cargo2nix to get incremental builds, meaning that dependency builds can be shared between our Rust projects and that not all dependencies have to be rebuilt when adding/updating/removing dependencies from a project.
- Node projects are far trickier if you want them to be able to share dependencies and depend on one another. We have found Yarn 4 (currently release candidate, not stable yet) in combination with https://github.com/madjam002/yarnpnp2nix to work best for this. Unfortunately we have to patch some package hashes of packages that contain platform-specific binaries (such as esbuild).
- Container images are built with https://github.com/nlewo/nix2container instead of Nix's built-in docker tools, because nix2container allows configuration of layers and thus makes it easier to share layers between images and improve layer caching.
As for integrating it into our CI pipeline, this is pretty much CI system agnostic as all you have to do is run `nix build ...` inside the pipeline, generating a `result` directory or file as an artifact that, in the case of nix2container, can be pushed to your container image registry.
That said, I believe there are several ways to handle it depending on how you manage agents (and desired tooling.)
Unless you're running that image in production as well? Thats sort of the point? Production matches the test environment.
It's still early here, it's very possible I'm not really with it at the moment