You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vibed/nbd/.beans/nbd-wbf7--nix-flake-for-nbd.md

1.6 KiB

title status type priority created_at updated_at
Nix flake for nbd completed task low 2026-03-10T23:30:30Z 2026-03-10T23:30:30Z

Add nbd/flake.nix so that nbd can be consumed as a Nix package and used as a CLI tool in other projects in the mono-repo.

Motivation

Other vibed services and external projects should be able to include nbd as a dev dependency via Nix, getting a pinned, reproducible binary without needing Cargo installed.

Approach

nbd/flake.nix

Follow the pattern from the repo root flake.nix. The service flake should:

  1. Inherit the base flake's inputs (nixpkgs, rust-overlay, etc.) or declare its own.
  2. Define a packages.default attribute that builds the nbd crate with rustPlatform.buildRustPackage.
  3. Define a devShells.default that includes the nbd binary and standard Rust tooling (rustfmt, clippy, cargo).
  4. Optionally expose an apps.default for nix run .#nbd.

Cargo.lock

Ensure Cargo.lock is committed (it already is) — required for reproducible Nix builds.

cargoHash / cargoSha256

The buildRustPackage derivation requires a cargoHash (or cargoSha256). Use the correct fetcher approach (vendored deps or fetchCargoTarball).

Steps

  1. Read the root flake.nix to understand the base structure.
  2. Write nbd/flake.nix following the same conventions.
  3. Run nix build .#nbd from the nbd/ directory to verify it builds.
  4. Run nix run .#nbd -- --help to verify the binary works.

Files touched

  • nbd/flake.nix — new file
  • README.md — add nix run usage section