Files
rdbms-playground/flake.nix
T
claude@clouddev1 9189740028 build(nix): reproducible dev + build env via a flake (ADR-0049)
Root flake with two outputs: devShells.default (pinned 1.95.0
toolchain via rust-toolchain.toml + rust-overlay, plus cargo-sweep)
and packages.default (rustPlatform.buildRustPackage from the committed
Cargo.lock; doCheck=false). flake.lock pins nixpkgs nixos-26.05 /
rust-overlay / flake-utils. .envrc (use flake) for direnv parity.

Single source of toolchain for dev and the upcoming CI, so they can't
drift. Verified through the flake: nix build yields a working binary,
clippy clean, 2424 tests pass / 0 fail / 1 intentional ignored doctest.
First step toward requirements.md TT5 + D1/D2/D3.
2026-06-12 20:35:39 +00:00

81 lines
3.5 KiB
Nix

{
description = "RDBMS Playground Rust TUI dev environment + reproducible build";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
# Single source of the Rust toolchain: the rustup toolchain file.
# rust-overlay provisions the exact channel + components declared there,
# so the dev shell and the build package share one pinned toolchain.
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
# Read the package version straight from Cargo.toml so it never drifts
# from the crate metadata (no hand-maintained duplicate here).
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
# System build inputs are deliberately tiny — this is a pure-Rust TUI:
# * libsqlite3-sys is built with the `bundled` feature, so SQLite is
# compiled from vendored C. That needs a C compiler, which the
# stdenv provides automatically (no entry required here).
# * arboard's clipboard backend is `x11rb` — a pure-Rust socket XCB
# client. It links no C X11 libraries, so none appear below. A live
# X server is only needed at *runtime* to copy; headless sessions
# fall back to OSC 52.
# If a future dependency introduces a pkg-config / native-lib link, add
# it here (and document why) rather than leaking it into the host env.
nativeBuildInputs = [ ];
buildInputs = [ ];
# `nix build` → the release binary, built reproducibly from the pinned
# toolchain and the committed Cargo.lock (importCargoLock fetches each
# dependency by its lockfile checksum — offline, no cargoHash to churn).
# CI's release job consumes this artifact; the gate's tests run
# separately via `nix develop -c cargo test` (see below), so the package
# build skips the suite — the nix sandbox has no HOME/X server and would
# fight the project-dirs / clipboard paths the tests touch.
rdbms-playground = pkgs.rustPlatform.buildRustPackage {
pname = cargoToml.package.name;
version = cargoToml.package.version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
inherit nativeBuildInputs buildInputs;
doCheck = false;
};
in {
packages.default = rdbms-playground;
packages.rdbms-playground = rdbms-playground;
devShells.default = pkgs.mkShell {
inherit buildInputs;
nativeBuildInputs = nativeBuildInputs ++ [
rust
# Dev-disk maintenance: cargo never garbage-collects stale per-hash
# build artifacts, so target/ creeps into the tens of GB (see
# CLAUDE.md "Build hygiene"). cargo-sweep prunes them; run it
# periodically between milestones.
pkgs.cargo-sweep
];
shellHook = ''
echo "RDBMS Playground dev shell ($(uname -s))"
echo " rust: $(rustc --version | cut -d' ' -f1-2)"
echo " cargo: $(cargo --version | cut -d' ' -f1-2)"
'';
};
});
}