-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
103 lines (92 loc) · 2.76 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
{
description = "Utilities for working with JSON RPC";
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
devshell,
nixpkgs,
flake-utils,
pre-commit-hooks,
...
} @ inputs: let
inherit (flake-utils.lib) eachDefaultSystem flattenTree mkApp;
in
eachDefaultSystem
(system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlay
];
};
inherit (pkgs) dockerTools buildGoModule;
inherit (pkgs.stdenv) isLinux;
inherit (pkgs.lib) lists fakeSha256 licenses platforms;
inherit (pkgs.devshell) mkShell;
pkgWithCategory = category: package: {inherit package category;};
linters = with pkgs; [
alejandra # https://github.com/kamadorueda/alejandra
gofumpt # https://github.com/mvdan/gofumpt
nodePackages.prettier # https://prettier.io/
treefmt # https://github.com/numtide/treefmt
];
# devshell command categories
dev = pkgWithCategory "dev";
linter = pkgWithCategory "linters";
formatter = pkgWithCategory "formatters";
util = pkgWithCategory "utils";
in {
checks = {
format =
pkgs.runCommandNoCC "treefmt" {
nativeBuildInputs = linters;
} ''
# keep timestamps so that treefmt is able to detect mtime changes
cp --no-preserve=mode --preserve=timestamps -r ${self} source
cd source
HOME=$TMPDIR treefmt --fail-on-change
touch $out
'';
};
devShells.default = mkShell {
packages = with pkgs;
[
delve # https://github.com/go-delve/delve
go_1_19 # https://go.dev/
gotools # https://go.googlesource.com/tools
websocat # https://github.com/vi/websocat
]
++ linters;
commands = with pkgs; [
(formatter alejandra)
(formatter gofumpt)
(formatter nodePackages.prettier)
(linter golangci-lint)
(util jq)
(util just)
];
};
});
}