-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdevenv.nix
More file actions
173 lines (172 loc) · 4.98 KB
/
devenv.nix
File metadata and controls
173 lines (172 loc) · 4.98 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
{
pkgs,
lib,
config,
...
}: {
config = lib.mkMerge [
{
# Defaults
git-hooks.default_stages = ["pre-push" "manual"];
git-hooks.hooks = {
commitizen.enable = true;
gitleaks = {
enable = true;
name = "gitleaks";
description = "Gitleaks on entire project";
entry = "${pkgs.gitleaks}/bin/gitleaks protect --redact";
};
lychee.enable = true;
lychee.settings.configPath = builtins.toString ((pkgs.formats.toml {}).generate "lychee.toml" {
exclude = [
"localhost"
"file://"
"https://shadcn-svelte.com/registry"
"http://192.168.11.5:8000"
"https://fushigi.bunkbed.tech"
"https://demo.fushigi.bunkbed.tech"
];
});
markdownlint.enable = true;
markdownlint.settings.configuration.MD013.line_length = -1;
mdsh.enable = true;
tagref.enable = true;
typos.enable = true;
typos.excludes = [".*.json"];
typos.settings.ignored-words = ["ratatui"];
# pre-commit builtins
check-added-large-files.enable = true;
check-case-conflicts.enable = true;
check-executables-have-shebangs.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
check-vcs-permalinks.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
forbid-new-submodules.enable = true;
mixed-line-endings.enable = true;
no-commit-to-branch.enable = true;
no-commit-to-branch.settings.branch = ["main"];
trim-trailing-whitespace.enable = true;
};
}
{
# Nix
languages.nix.enable = true;
git-hooks.hooks = {
alejandra.enable = true;
deadnix.enable = true;
statix.enable = true;
statix.raw.args = [
"--config"
((pkgs.formats.toml {}).generate "statix.toml" {
disabled = [
"unquoted_uri"
"repeated_keys"
];
})
];
};
}
{
# Pocketbase database + backend as a service
languages.go.enable = true;
processes.backend = {
exec = "go run . serve --dev --http=0.0.0.0:8080";
process-compose = {
working_dir = "./pocketbase";
readiness_probe = {
http_get = {
host = "127.0.0.1";
port = 8080;
path = "/api/health";
};
initial_delay_seconds = 5;
period_seconds = 2;
timeout_seconds = 5;
success_threshold = 1;
failure_threshold = 30;
};
};
};
git-hooks.hooks = {
gofmt.enable = true;
#golangci-lint.enable = true;
govet.enable = true;
};
}
{
# SvelteKit frontend
git-hooks.hooks.biome.enable = true;
processes.frontend.exec = let
getIpCmd = pkg: "${pkg}/bin/ip route get 1 | ${pkgs.gnused}/bin/sed 's/^.*src \\([^ ]*\\).*$/\\1/;q'";
pkg =
if pkgs.stdenv.isLinux
then pkgs.iproute2
else if pkgs.stdenv.isDarwin
then pkgs.iproute2mac
else throw "${pkgs.stdenv.system} not supported";
in ''
export VITE_API_BASE="http://$(${getIpCmd pkg}):8080"
bun --bun run dev --open
'';
processes.frontend.process-compose.working_dir = "./frontend";
languages = {
typescript.enable = true;
javascript = {
enable = true;
directory = "./frontend";
bun.enable = true;
bun.install.enable = true;
};
};
}
{
# TUI
languages.rust.enable = true;
git-hooks.hooks = {
clippy.enable = true;
rustfmt.enable = true;
};
}
{
# OCI
git-hooks.hooks = {
hadolint.enable = true;
yamllint.enable = true;
};
}
(lib.mkIf pkgs.stdenv.isDarwin {
# SwiftUI app
languages.swift.enable = true;
packages = with pkgs; [
swiftformat
swiftlint
];
git-hooks.hooks = {
swiftlint = {
enable = true;
name = "SwiftLint";
description = "Enforcing Swift style and conventions";
files = "\\.swift$";
entry = "${pkgs.swiftlint}/bin/swiftlint";
};
swiftformat = {
enable = true;
name = "SwiftFormat";
description = "Formatting Swift code with conventional style";
files = "\\.swift$";
entry = "${pkgs.swiftformat}/bin/swiftformat";
};
};
# Assume all Apple developers have XCode installed.
# DEVELOPER_DIR env var must be set globally on macOS to run swiftlint
# env = {
# DEVELOPER_DIR = lib.mkForce "/Applications/Xcode.app/Contents/Developer";
# };
enterShell = ''
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
'';
})
];
}