flake.nix
1{
2 description = "bug - a simplified CLI to git-bug";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 flake-utils.url = "github:numtide/flake-utils";
7 };
8
9 outputs = { self, nixpkgs, flake-utils }:
10 flake-utils.lib.eachDefaultSystem (system:
11 let
12 pkgs = nixpkgs.legacyPackages.${system};
13
14 # Read the version from go.mod or use a default
15 version = "1.1.0";
16
17 # Build the bug CLI tool
18 bug = pkgs.buildGoModule {
19 pname = "bug";
20 inherit version;
21 src = ./.;
22
23 # This is the vendor hash - update it when go.mod/go.sum changes
24 # Run: nix build 2>&1 | grep "got:" | sed 's/.*got: *//'
25 vendorHash = "sha256-Rmx0T/Vfv71DL3Z1ytwKAsrVrQzd27hJNoMTwaDvrIQ=";
26
27 # Build flags
28 ldflags = [
29 "-s" # Strip symbol table
30 "-w" # Strip debug info
31 "-X main.version=${version}"
32 ];
33
34 # Sub-packages to build (build all in root directory)
35 subPackages = [ "." ];
36
37 # Tests require git in PATH which isn't available in the sandbox
38 # Run tests separately with: go test ./...
39 doCheck = false;
40
41 meta = with pkgs.lib; {
42 description = "Simplified CLI to git-bug";
43 homepage = "https://code.kilimanjaro.io/bug";
44 license = licenses.mit;
45 mainProgram = "bug";
46 platforms = platforms.all;
47 };
48 };
49 in
50 {
51 # Default package builds the bug CLI
52 packages.default = bug;
53
54 # Also expose the bug package directly
55 packages.bug = bug;
56
57 # Development shell with Go tooling
58 devShells.default = pkgs.mkShell {
59 buildInputs = with pkgs; [
60 go
61 gopls
62 golangci-lint
63 ];
64
65 shellHook = ''
66 echo "bug dev shell"
67 echo " Go version: $(go version)"
68 echo " Run 'make build' to build with nix"
69 echo " Run 'make test' to run tests"
70 '';
71 };
72
73 # App for running directly
74 apps.default = flake-utils.lib.mkApp {
75 drv = bug;
76 exePath = "/bin/bug";
77 };
78 });
79}