DEVELOPMENT ENVIRONMENT

~liljamo/tamma

ref: fef670409e116af69b2607b954e949b9b4ba9c89 tamma/flake.nix -rw-r--r-- 1.7 KiB
fef67040Jonni Liljamo chore: bump version to 0.1.2 2 months 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
66
67
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";

    pre-commit-hooks = {
      url = "github:cachix/pre-commit-hooks.nix";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.flake-utils.follows = "flake-utils";
    };
  };

  outputs = inputs @ {
    self,
    nixpkgs,
    flake-utils,
    pre-commit-hooks,
  }:
    flake-utils.lib.eachSystem ["x86_64-linux"] (
      system: let
        pkgs = nixpkgs.legacyPackages.${system};
      in {
        packages.default = pkgs.buildGoModule {
          pname = "tamma";
          version = "0.1.2";
          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];
        };
      }
    );
}