Skip to content
Oeiuwq Faith Blog OpenSource Porfolio

aanderse/trix

trick yourself into flakes

aanderse/trix.json
{
"createdAt": "2025-12-19T15:48:28Z",
"defaultBranch": "main",
"description": "trick yourself into flakes",
"fullName": "aanderse/trix",
"homepage": null,
"language": "Rust",
"name": "trix",
"pushedAt": "2026-01-08T01:44:46Z",
"stargazersCount": 13,
"topics": [],
"updatedAt": "2026-01-07T11:47:09Z",
"url": "https://github.com/aanderse/trix"
}

trix - trick yourself into flakes

trix is an alternative userland implementation of Nix flakes. It reads flake.nix and flake.lock files, resolves inputs, and evaluates outputs — all without requiring you to enable the experimental flakes or nix-command features. Under the hood, trix delegates to the stable “legacy” Nix commands (nix-build, nix-shell, nix-instantiate), giving you a modern flake workflow built on proven foundations.

While flake.nix has reached critical mass and there is no going back at this point, this doesn’t mean we are stuck with the current implementation of Flakes.

The primary motivation for trix is to address the stagnation of these “experimental” features. Despite being broadly adopted, flakes and nix-command have remained in experimental status for a significant time. This uncertainty creates a barrier to adoption (where using “experimental” features is often seen as a liability) and maintains ambiguity regarding their future. trix tries to bridges this gap, treating the Flake format as the standard while relying on the proven stability of traditional Nix internals.

trix allows using Nix as if the experimental feature flags nix-command and flakes were enabled, without modifying your global configuration. It works by delegating to stable “legacy” Nix commands (nix-build, nix-shell, nix-instantiate) whenever possible, rewriting each command to optionally inject --extra-experimental-features "flakes nix-command" when necessary.

This approach offers these benefits:

  • No Global Configuration: You can keep your nix.conf clean of experimental-features = nix-command flakes.
  • Efficiency: trix evaluates flakes in-place without copying them to the Nix store, referencing your working directory directly.
  • Stability: It leverages the battle-tested legacy Nix tools under the hood.
Featurenix flaketrix
StabilityExperimentalStable (uses nix-build, etc.)
PurityEnforcedOptional (allows impure evaluation)
PerformanceCopies entire flake to storeEfficient (evaluates in-place, no store copy)
SpecificationFullPractical subset
FeaturePlain Nixtrix
flake.nix support
Reproducible lockingManual✅ (native flake.lock)
Structured inputs
CLI familiarityLegacyModern (flake-like)

trix is a small rust tool, written initially in python by claude and converted to rust with Antigravity later on, that provides a flake-like experience using stable Nix commands. It operates as follows:

  1. Introspection: Parses flake.nix to extract input requirements (via nix-instantiate).
  2. Locking: Fetches and locks inputs using nix flake prefetch. (For remote flakes and certain operations like trix copy, trix delegates to nix commands directly.)
  3. Generation: Produces a standard flake.lock file.
  4. Evaluation: Constructs the inputs attrset and evaluates the flake’s outputs.
  5. Execution: Delegates the final build or shell action to nix-build or nix-shell.

The resulting lock file is fully compatible with using nix flake experimental features. You can even switch between trix and official Flakes at any time without issues.

trix translates high-level flake intents into low-level Nix operations. When running a trix command, it actually invokes multiple Nix commands under the hood to build the desired output. These commands includes the experimental features flags for you (some required functions requires flakes to be enabled, like NixOS/nix#5541).

The recommended way to install trix is by using the provided overlay (inputs.trix.overlays.default). This ensures you get the correct version and dependencies integrated into your package set. Once added, you can install trix using your preferred method.

You can also run it with nix run directly from the flake:

Terminal window
nix run github:aanderse/trix

trix includes a direnv library for seamless environment activation.

  1. Add to your ~/.config/direnv/direnvrc:

    Terminal window
    # If installed via nix profile:
    source ~/.nix-profile/share/trix/direnvrc
    # Or with a direct store path:
    source /nix/store/...-trix-0.1.0/share/trix/direnvrc
  2. In your project’s .envrc:

    Terminal window
    use trix
    # or for a specific devShell:
    use trix .#myshell

trix uses structured logging via the tracing crate. Diagnostic information is printed to stderr to avoid interfering with command output.

Use the -v / --verbose flag to enable debug output:

Terminal window
trix -v build .#default

You can filter log output granularly using the RUST_LOG environment variable. The default level is INFO (or DEBUG when -v is used).

Examples:

Terminal window
# different modules at different levels
RUST_LOG=trix=debug,nix=error trix build
# trace everything
RUST_LOG=trace trix build
  • Nix Flakes: The experimental feature trix provides an alternative for.
  • flake-compat: Makes flake-based projects compatible with legacy Nix commands.
  • unflake: An alternative dependency resolver & runtime for Nix flakes.