DEVELOPMENT ENVIRONMENT

~liljamo/tamma

ref: 0.3.0 tamma/flake.nix -rw-r--r-- 1.6 KiB
8f9c9ff1Jonni Liljamo feat: optional confirm dialog, other rendering changes a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
  };

  outputs = inputs @ {
    self,
    flake-parts,
    pre-commit-hooks,
    ...
  }:
    flake-parts.lib.mkFlake {inherit inputs;} {
      systems = ["x86_64-linux"];
      perSystem = {
        pkgs,
        system,
        ...
      }: {
        packages.default = pkgs.buildGoModule {
          pname = "tamma";
          version = "0.2.0";
          src = ./.;
          vendorHash = "sha256-7exD/qZNPL1hzo2Fkc87J+ht1U9vl8hvmfGI+ykfZfE=";
          nativeBuildInputs = [
            pkgs.makeWrapper
          ];

          # wl-copy is needed at runtime
          postInstall = ''
            wrapProgram $out/bin/tamma \
              --prefix PATH : ${pkgs.lib.makeBinPath [
              pkgs.wl-clipboard
            ]}
          '';
        };

        checks = {
          pre-commit-check = pre-commit-hooks.lib.${system}.run {
            src = ./.;
            hooks = {
              # go
              gofmt.enable = true;
              govet.enable = true;
              revive.enable = true;

              # nix
              alejandra.enable = true;
            };
          };
        };

        devShells.default = pkgs.mkShell {
          inherit (self.checks.${system}.pre-commit-check) shellHook;
          buildInputs =
            [
              pkgs.go
              pkgs.gopls
            ]
            ++ [self.checks.${system}.pre-commit-check.enabledPackages];
        };
      };
    };
}