Two people can share the same devenv.lock, get the same tools and approve the same tests, and still run different binaries in production. The problem appears as we cross a border that the development environment doesn’t control: who builds the artifact with what inputs, where it’s stored and what identity ends up deployed.
At el artículo sobre Nix y devenv we saw how to reduce differences between development machines. Here we continue from that point. We will never explain how to install Nix or declare local services again: the goal is to connect code versiones, built, CI, distribution and operation without attributing them guarantees that they have.
The thesis is concrete: a reliable pipeline does not reconstruct the same commitment at every stage while expecting the same result. It builds, identifies, checks and promotes an artifact while keeping explicit what should be resolved at performance time. This improves traceability and resilience. It does not itself prove binary reproducibility.
Four different objects that are often referred to as “environment”
| Subject matter | What does that mean? | What doesn’t necessarily contain |
|---|---|---|
| Development environment | Tools, shells, local services and commands to contribute | Configure and production data |
| Building environment | Visible inputs and conditions during compilation | All non-determinist effects of the compiler or scripts |
| Artefacto | Result to be distributed: Nix, binary or OIC image derivation | Secrets, database, certificates in use |
| Deployment | Selection of the device, services, network and enforcement policies | Ensuring that the actual state always coincides with the declaration |
The nuance determines what can be stated. A built with established inputs resolves best-thought references and an built playable have been independently rebuilt and have produced identical bytes under the evaluated conditions. The Reproducible Builds de NixOS project document why sandbox and derivations do not automatically remove typprints, nondeterminist file order or tool-introduced differences.
The contract starts with the commit and his locks.
For a small Rust service we will use a continuous example: an HTTP API that exposes /health at the internal port 8080. His code lives with api/ and his Repository fixes Nix inputs with devenv.lock and Rust dependencies with Cargo.lock.
service-repository/
├── devenv.nix
├── devenv.yaml
├── devenv.lock
├── api/
│ ├── Cargo.toml
│ ├── Cargo.lock
│ └── src/main.rs
└── .github/workflows/ci.yml
That tree describes the model project, and did not file them from the blog repository. No Cargo.lock, devenv.lock or OCI images have been generated for this article. The locks would be obtained using the actual tools and would be versed with the code. Updating them would be a replaceable maintenance decision, not an automatic action while deploying.
For the stage to have a concrete application, the rate uses a minimum HTTP path. Cargo.toml declares requirements, does not replace the lockfile generated by Loan:
# api/Cargo.toml — ejemplo mínimo, no ejecutado aquí
[package]
name = "edge-api"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net"] }
// api/src/main.rs — API demostrativa, no incluye autenticación ni límites de tráfico
use axum::{routing::get, Router};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Router::new().route("/health", get(|| async { "ok" }));
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
axum::serve(listener, app).await?;
Ok(())
}
This API only serves to examine the pipeline. It does not purport to be a production application and does not provide that integration checks have been tested. In the actual project, cargo generate-lockfile resolves the dependencies and generates api/Cargo.lock and then confirms the file. The following compilation uses frozen resolution with cargo test --locked. The server isn’t exposed here and 8080 port is an example of listening inside the container.
devenv.yaml describes the inputs that are later resolved at devenv.lock. Cargo.lock records the resolution of dependencies of Cargo. flake.lock, when using Nix with flakes, is a related mechanism but doesn’t mean to devenv.lock of a conventional project. The manual de entradas de devenv and modelo de flakes de Nix document both cases.
A commit and two Linkfiles continue to identify all relevant elements: Nix’s system, IQ’s executable, sandbox configuration, cache credentials and access to outside services can change. At Nix a derivation specifies, among other things, the target system. That’s why building for x86_64-linux and for aarch64-linux involves specific results from each architecture, even if they come from the same sources. See el modelo de derivaciones.
Convert a development tool to an installable result
The first step that was necessary for local shell is to define an output of build. cesv exposes outputs; devenv build evaluates and builds these outputs and, from cesv 2.0, reports its JSON-format routes. The documentación oficial de outputs shows integration with Rust using crate2nix.
as a configuration fragment for Rust service:
# devenv.nix — fragmento para un proyecto Rust con api/Cargo.lock
{ config, ... }:
{
languages.rust.enable = true;
outputs.api = config.languages.rust.import ./api {};
# Este test pertenece al proyecto de ejemplo, no al blog.
enterTest = ''
cd api
cargo test --locked
'';
}
The fragment means that api/ is a valid Rust rate, has versioned Cargo.lock and that the production version used implements the documented importer. That combination has not been performed here. It doesn’t equal to delivering an application repository ready for production.
The relevant conduct can be inspected with:
# En el repositorio de ejemplo, después de generar y confirmar los locks:
devenv test
# Construye la salida declarada y devuelve su identidad en JSON:
devenv build outputs.api
A /nix/store/... invented from a tutorial should not be copied. In a real project, the pipeline will read the JSON object that returns devenv build, remove outputs.api’s storage path and preserve that identity in its release metadata. The deviation path does not certify that an independent compilation produces exactly the same bytes and does serve to identify a concrete item of the store that can be distributed.
The cargo test --locked prevents Cargo from modifying the resolution during that performance but it remains necessary to design performance, compatibility and safety tests. The approval of the built by itself does not prove that the service is ready for traffic.
CI: using the statement without floating the rest
A serious IQ should answer six questions before publishing any artifact: what’s been built? What’s been built? What’s been built up? What checks have happened? What exact artifact have been produced and where’s the provenance test?
GitHub Acts can install Nix, run devenv test and devenv build. The integración de devenv con Actions document that sequence. For a real pipeline it’s not enough to copies the example as: the workflow itself, its actions and the installation of the CLI should be monitored.
That block teaches only the internal steps of a job that has already installed a revised version of Nix and cesv and has appropriate permission:
# Fragmento de steps, no workflow completo listo para pegar.
# Requiere checkout del commit correcto e instalación controlada de Nix/devenv.
- name: Probar el entorno y los tests declarados
run: devenv test
- name: Construir el resultado versionado
run: devenv build outputs.api > build-outputs.json
- name: Conservar metadatos de construcción
run: |
git rev-parse HEAD > source-commit.txt
sha256sum devenv.lock api/Cargo.lock > input-locks.sha256
sha256sum is a Linux run command: another system requires an equivalent. Neither YAML nor those file names mean that the job has been executed. The fragment deliberately omits authentication and publication of artifacts to avoid suggesting that an example token is secure.
To set outside actions, GitHub recomienda referenciarlas por SHA de commit. At the verifications of November 16, 2026, cachix/install-nix-action published the series v31 and cachix/cachix-action published v17 and a version label was more legible but not as strong as a revised SHA. The cesv version installed using nix profile add nixpkgs#devenv can also float if the source reference isn’t set. The lista de releases de devenv marked v2.4.0 as the latest revised tagged version, but code and documentation can go ahead of tags.
Buildings in PR: evidence without production credentials
A Fold PR can modify both code and workflow. Giving them a Cachix or a registration write token isn’t an optimization: it’s an ill-defined security border. The documentación de Cachix explain cache permits. A reasonable policy allows PRs to unreliable read public dependencies and run checks in an isolated run, and book published / signed for protected commitments after review.
The same goes for their own runners: built-up hooks and daemon configuration warrant an assessment of privileges and trusted-users should not be expanded without understanding their impact. The minimum work permits and the separation between events (pull_request versus published from a protected branch) are part of the operational reproducibility and are not cosmetic details.
Reducibility audit and distribution
A binary cache allows an already built Nix object to be obtained as long as the client relies on its origin and the requested item is available. When a * cache hit * exists, re-using it prevents a rebuild and that doesn’t prove that another builder would get the same bytes from the source code. With a * cache miss *, the run can move from download to compile, or miss by network or permissions. devenv documenta estas condiciones.
The difference matters in incidents. If two environments consumed the same cache content, you can say that they re-used the same confident device and that two independent compilations were determinist. To prove binary reproducibility we have to repeat built up under controlled conditions and compare results, documenting discrepancies with analysis tools such as diffoscope. That experiment isn’t part of this publication.
An irreversible decision for pipeline: promoting or rebuilding
Imagine the following flow: main approves tests, CI builds an image, stacking runs and production should get the same version. There are two different strategies:
| Strategy | Advantage | Significant risk |
|---|---|---|
| Rebuild from Git in every environment | Less dependence on an artifact registry | A tag, builder, variable or package repository can change between built |
| To promote the same identified device | We know what objects run in each environment | Keep registration, permits, cleanup, metadata and rollback |
For the proposed flow, I would choose to build once and promote by immutable identity. On an OCI route, the display identity is the DIDIDIest sha256 of the published image; a label as latest is a mutitable pointer. The registered digest should come from actual publication in the destination register, and not from an assumed Dockerfile hash.
Issuan route: cesv, registration and implementation platform
devenv puede construir contenedores OCI but that functionality requires additional inputs such as nix2container and mk-shell-bin. languages.rust cannot be enabled. There’s also a difference between put the complete shell into a container and pack only the application and the runtime dependencies. For production it’s interested to minimize surface and not include development tools or CI credentials.
The conceptual path is as follows: first, the commitment and its lockfiles are set, and CI runs the tests and builds outputs.api. A Linux builder generates the ICO image. The registry returns its digest and promotes that same digest to the following environments. Finally, each destination adds its own configuration, secrets, network and data. No diagram of that flow has been drawn or generated.
That’s an explanatory sequence, but that’s a command’s output. If the computer decides to implement containers.prod you will have to check his API and his startupCommand in the set version, design the Runtime image, add secure authentication and register the result digest. The cesv documentation also indicates that creating Linux images from macOS requires a Linux builder, remote or equivalent local. A single digest for linux/amd64 does not automatically replace a multiarchitecture strategy.
When you get to the register, operation tools such as Coolify can directly consume an existing digest image without re-compiling from Git. That’s the editorial border between both articles: this pipeline decides what’s built and the display platform decides where, how and with what status it’s run.
Native Nix path: distribute a closure
If the destination runs Nix and has a managed activation model, an alternative option is to copies the passing closure of the output without reconstructing it onto the server. The syntax is documented in Nix copy:
# Fragmento ilustrativo: STORE_PATH es una ruta real obtenida del JSON del build.
nix copy --to ssh-ng://deploy.example.com "$STORE_PATH"
Here’s an additional requirement that tutorials usually omits: copying the closure does not start service. The destination host needs its system unit, NixOS profile or configuration, permissions, activation policy and rollback. The native Nix and OCI routes are alternatives and should not be mixed with a single example claiming that they have the same runtime operations.
Provenance isn’t an absence of vulnerabilities
GitHub allows to generate attestations that link artifacts - including digest images - with information about the workflow that created them. They serve to answer * who built what and from what process *. The verification should check that the expected issuer and repository coincide with the policy of deployment.
A valid attestation does not prove that the code is secure, that it does not have vulnerable dependencies or that the build is bit to bit reproducible. It’s a provenance piece. It’s complemented with access controls, change review, Unit analysis, SBOM as warranted and performance tests. The registration of digest without a policy of verification reduces traceability but does not turn that traceability into a barrier of promotion itself.
Configure, secrets and data: what should not travel inside an artifact
There are things that have to stay out of the built inputs. An application may declare that it requires DATABASE_URL and LOG_LEVEL but the actual password and production service address should not end up baked in an image. SecretSpec distinguishes a statement of secrets and provision at run time and an equivalent system of a cloud supplier can solve the same separation.
| Appeal | It should be versed or fixed | To be resolved while deploying |
|---|---|---|
| Source, manifest and dependencies | Compact + revised Linkfiles | — |
| Building output | Store path and / or image digest | Record and download permits |
| Configure contract | Name, type and validation | Value by environment |
| Secrets | Names, policies and rotation | Value from secret warehouse |
| Database | Migration and compatible contracts | Data, replication and backups |
| Network and host | Definition of services, intended ports | DNS real, certificates, kernel, supplier |
That separation has consequences as we turn back. A previous image could run against an already migrated database scheme. A secure revamp requires back and forth supported migration, an extension / contract strategy as appropriate and restoration tests. ** To change the digest does not return the database to its previous status. ♪ ♪
Test the display contract, not just the compiler
The pipeline should accumulate evidence according to its cost and its closeness to production. I propose this order, which does not mean measures already performed:
- Before construction: validate Linkfiles, Unit Review, Unit Test and Workflow Policies.
- During the building: control architecture, register inputs digests, generate the device once and store its metadata.
- Before promoting: run smoke tests about that artifact, check the digest / provenance and test required configuration without exposing secrets.
- After you have deployed: review real readiness and a functional flow of the application and preserve access to the earlier device.
- Before a malfunction: to be able to recover the previous digest, study compatibility of the scheme and run the separate data recovery plan.
Health checks are not equivalent to a business test and the success of a workflow does not observe production network. In particular, any validation dependent on databases, watches, external services and messages should record their terms and conditions. The IQ we describe here has not been run for this article: are decisions and commands supported by document and have been not experimental results.
The cost of monitoring more variables
Milling actions by commit requires keeping references; building images by platform consumes time and cache; signing and verifying provenance requires permissions and policies; old artifacts require retention; secrets require rotation. In a small application these costs can exceed the initial gain. For a single-platform service and few dependencies, a well revised Dockerfile and a registry can be sufficient. Nix / cesv contributes more with the common text of toolchains and built.
The final statement isn’t that “production is equal to development.” It’s more precise: we know about what commit and locks the device that’s been run come from. CI and the endowment environment share their identity, and they don’t necessarily share their status. If a difference arises, it’s clear whether to search the building, configuration or operating system and data. That’s the starting point of an enforceable pipeline.
To complete an operation of an OCI image by digest - proxy, secrets, volumes, backups and reversion - continues with el análisis de Coolify.