diff --git a/nbd/.nbd/tickets/6e4239.md b/nbd/.nbd/tickets/6e4239.md index 647f9fa..56def80 100644 --- a/nbd/.nbd/tickets/6e4239.md +++ b/nbd/.nbd/tickets/6e4239.md @@ -1,7 +1,7 @@ +++ title = "Nix flake for nbd" priority = 4 -status = "todo" +status = "done" ticket_type = "task" dependencies = [] +++ diff --git a/nbd/README.md b/nbd/README.md index 27382fc..0b46c4a 100644 --- a/nbd/README.md +++ b/nbd/README.md @@ -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 diff --git a/nbd/flake.nix b/nbd/flake.nix new file mode 100644 index 0000000..1f07581 --- /dev/null +++ b/nbd/flake.nix @@ -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 + ]; + }; + } + ); + }; +}