feat(nbd): add Nix flake for building and running nbd [6e4239]

Add flake.nix so nbd can be consumed as a reproducible Nix package.
Exposes packages.default, apps.default (nix run), and a devShell with
stable Rust toolchain and the nbd binary. Uses cargoLock for
dependency hashing without a pre-computed cargoHash.

Also adds an Installation section to README.md covering nix run and
nix build usage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
quotesdb
Elijah Voigt 3 months ago
parent 7aa547633f
commit ffbb0157e3

@ -1,7 +1,7 @@
+++
title = "Nix flake for nbd"
priority = 4
status = "todo"
status = "done"
ticket_type = "task"
dependencies = []
+++

@ -177,6 +177,38 @@ nbd migrate --dry-run # preview changes without writing
nbd migrate --json # machine-readable summary
```
## Installation
### Nix (recommended)
Run directly without installing, using the bundled Nix flake:
```sh
nix run github:elijah/vibed?dir=nbd -- --help
```
Or add to a Nix devShell:
```nix
{
inputs.nbd.url = "github:elijah/vibed?dir=nbd";
# then use nbd.packages.${system}.nbd in your devShell packages
}
```
Build locally from the `nbd/` directory:
```sh
nix build # builds the nbd binary
nix run -- init # run nbd init via nix run
```
### Cargo
```sh
cargo install --path .
```
## Running
```sh

@ -0,0 +1,98 @@
{
description = "nbd CLI tool for managing work tickets, targeted at agent workflows";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
rust-overlay,
}:
let
systems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
}
);
in
{
packages = forAllSystems (
{ pkgs, system }:
{
# The nbd CLI package, built with rustPlatform.buildRustPackage.
nbd = pkgs.rustPlatform.buildRustPackage {
pname = "nbd";
version = "0.1.0";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
meta = {
description = "CLI tool for managing work tickets, targeted at agent workflows";
license = with pkgs.lib.licenses; [
asl20
mit
];
mainProgram = "nbd";
};
};
# Make nbd the default package so `nix build` works without specifying an attribute.
default = self.packages.${system}.nbd;
}
);
apps = forAllSystems (
{ system, ... }:
{
# Run nbd directly with `nix run .#nbd`.
nbd = {
type = "app";
program = "${self.packages.${system}.nbd}/bin/nbd";
};
# Make nbd the default app so `nix run` works without specifying an attribute.
default = self.apps.${system}.nbd;
}
);
devShells = forAllSystems (
{ pkgs, system }:
{
# Development shell with stable Rust toolchain and nbd binary.
default = pkgs.mkShell {
packages = [
# Stable Rust toolchain: compiler, cargo, rustfmt, clippy.
pkgs.rust-bin.stable.latest.default
# The built nbd binary, available as `nbd` in the shell.
self.packages.${system}.nbd
];
};
}
);
};
}
Loading…
Cancel
Save