{
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];
};
}
);
}