{ description = "bug - a simplified CLI to git-bug"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; # Read the version from go.mod or use a default version = "1.5.0"; # Build the bug CLI tool bug = pkgs.buildGoModule { pname = "bug"; inherit version; src = ./.; # This is the vendor hash - update it when go.mod/go.sum changes # Run: nix build 2>&1 | grep "got:" | sed 's/.*got: *//' vendorHash = "sha256-CO/ynoBpljqysvljoEZP/Y1in5gRp+RHzTRVwZ9B9QQ="; # Build flags ldflags = [ "-s" # Strip symbol table "-w" # Strip debug info "-X main.version=${version}" ]; # Sub-packages to build (build all in root directory) subPackages = [ "." ]; # Tests require git in PATH which isn't available in the sandbox # Run tests separately with: go test ./... doCheck = false; # Ship the agent skill with the binary so they always match; # devkit's enterShell copies it into ~/.agents/skills postInstall = '' install -Dm644 SKILL.md $out/share/bug/skills/working-with-bug/SKILL.md ''; meta = with pkgs.lib; { description = "Simplified CLI to git-bug"; homepage = "https://tangled.org/rtw.run/bug"; license = licenses.mit; mainProgram = "bug"; platforms = platforms.all; }; }; in { # Default package builds the bug CLI packages.default = bug; # Also expose the bug package directly packages.bug = bug; # Development shell with Go tooling devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ go gopls golangci-lint ]; shellHook = '' echo "bug dev shell" echo " Go version: $(go version)" echo " Run 'make build' to build with nix" echo " Run 'make test' to run tests" ''; }; # App for running directly apps.default = flake-utils.lib.mkApp { drv = bug; exePath = "/bin/bug"; }; }); }