-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
107 lines (101 loc) · 2.64 KB
/
flake.nix
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{
description = "gpxif";
inputs = {
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
rev = "4cf7951a91440879f61e05460441762d59adc017";
};
gomod2nix = {
type = "github";
owner = "nix-community";
repo = "gomod2nix";
rev = "4e08ca09253ef996bd4c03afa383b23e35fe28a1";
};
flake-utils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
rev = "b1d9ab70662946ef0850d488da1c9019f3a9752a";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "git-hooks.nix";
rev = "c7012d0c18567c889b948781bc74a501e92275d1";
};
};
outputs =
{
self,
nixpkgs,
flake-utils,
gomod2nix,
pre-commit-hooks,
...
}:
let
utils = flake-utils;
in
utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
mkGoEnv = gomod2nix.legacyPackages.${system}.mkGoEnv;
goEnv = mkGoEnv { pwd = ./.; };
buildGoApplication = gomod2nix.legacyPackages.${system}.buildGoApplication;
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
dprint = {
enable = true;
name = "dprint check";
entry = "dprint check --allow-no-files";
};
nixfmt = {
enable = true;
name = "nixfmt check";
entry = "nixfmt -c ";
types = [ "nix" ];
};
gomod2nix = {
enable = true;
name = "gomod2nix up to date";
entry = "just gomod2nix";
pass_filenames = false;
files = "^(go\\.mod|go\\.sum|gomod2nix\\.toml)$";
};
};
};
};
packages.default = buildGoApplication {
pname = "gpxif";
version = "0.1";
pwd = ./.;
src = ./.;
modules = ./gomod2nix.toml;
checkPhase = ''
NIX_BUILD=true go test -v ./...
'';
};
devShells = {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
buildInputs = self.checks.${system}.pre-commit-check.enabledPackages;
packages = with pkgs; [
go_1_22
golangci-lint
gomod2nix.packages.${system}.default
goEnv
dprint
nixfmt-rfc-style
];
};
};
}
);
}