flake.nix

 1{
 2  description = "matcha  a beautiful and functional email client for the terminal";
 3
 4  inputs = {
 5    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
 6    flake-utils.url = "github:numtide/flake-utils";
 7    gomod2nix = {
 8      url = "github:nix-community/gomod2nix";
 9      inputs.nixpkgs.follows = "nixpkgs";
10    };
11  };
12
13  outputs = { self, nixpkgs, flake-utils, gomod2nix }:
14    flake-utils.lib.eachDefaultSystem
15      (system:
16        let
17          pkgs = nixpkgs.legacyPackages.${system};
18          gomod2nixPkgs = gomod2nix.legacyPackages.${system};
19        in
20        {
21          packages = rec {
22            matcha = gomod2nixPkgs.buildGoApplication {
23              go = pkgs.go_1_26;
24              pname = "matcha";
25              version = self.shortRev or "dev";
26
27              src = ./.;
28              modules = ./gomod2nix.toml;
29
30              CGO_ENABLED = 1;
31
32              nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
33                pkgs.pkg-config
34              ];
35
36              buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
37                pkgs.apple-sdk
38              ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux [
39                pkgs.pcsclite
40              ];
41
42              ldflags = [
43                "-s"
44                "-w"
45                "-X main.version=${self.shortRev or "dev"}"
46                "-X main.commit=${self.rev or "dirty"}"
47                "-X main.date=1970-01-01T00:00:00Z"
48              ];
49
50              meta = {
51                description = "A beautiful and functional email client for the terminal";
52                homepage = "https://github.com/floatpane/matcha";
53                license = pkgs.lib.licenses.mit;
54                mainProgram = "matcha";
55              };
56            };
57            default = matcha;
58          };
59
60          devShells.default = pkgs.mkShell {
61            buildInputs = with pkgs; [
62              go_1_26
63              gopls
64              gotools
65              gomod2nix.packages.${system}.default
66            ];
67          };
68        }
69      ) // {
70      overlays.default = final: _prev: {
71        matcha = self.packages.${final.system}.matcha;
72      };
73    };
74}