-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
203 lines (181 loc) · 5.5 KB
/
Copy pathflake.nix
File metadata and controls
203 lines (181 loc) · 5.5 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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
{
description = "A development shell for go";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
flake-fmt.url = "github:Mic92/flake-fmt";
};
outputs = inputs @ {
self,
nixpkgs,
flake-utils,
treefmt-nix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
# Add your overlays here
# Example:
# my-overlay = final: prev: {
# my-package = prev.callPackage ./my-package { };
# };
final.buildGoModule = prev.buildGo125Module;
buildGoModule = prev.buildGo125Module;
})
];
};
rooted = exec:
builtins.concatStringsSep "\n"
[
''REPO_ROOT="$(git rev-parse --show-toplevel)"''
exec
];
scripts = {
dx = {
exec = rooted ''$EDITOR "$REPO_ROOT"/flake.nix'';
description = "Edit flake.nix";
};
lint = {
exec = rooted ''
cd "$REPO_ROOT"
golangci-lint run
markdownlint -c .markdownlint.json ./spectr/
cd -
'';
description = "Run golangci-lint and markdownlint";
};
tests = {
exec = rooted ''
gotestsum --format testname -- -race "$REPO_ROOT"/... -timeout=2m
'';
description = "Run tests";
};
generate-gif = {
exec = rooted ''
cd "$REPO_ROOT"
DEMOS="init list validate archive partial-match"
if [[ "''${1:-}" == "-h" ]] || [[ "''${1:-}" == "--help" ]]; then
echo "Usage: generate-gif [demo]"
echo " generate-gif # Generate all GIFs"
echo " generate-gif init # Generate single GIF"
echo "Available demos: $DEMOS"
exit 0
fi
mkdir -p "$REPO_ROOT/docs/src/assets/gifs"
if [[ -n "''${1:-}" ]]; then
if [[ ! -f "$REPO_ROOT/docs/src/assets/vhs/$1.tape" ]]; then
echo "Error: Unknown demo '$1'. Available: $DEMOS" >&2
exit 1
fi
echo "==> Generating $1.gif..."
vhs "$REPO_ROOT/docs/src/assets/vhs/$1.tape"
else
echo "==> Generating all demo GIFs..."
for demo in $DEMOS; do
echo "==> Generating $demo.gif..."
vhs "$REPO_ROOT/docs/src/assets/vhs/$demo.tape"
done
echo "==> All GIFs generated successfully!"
fi
rm -rf "$REPO_ROOT"/_demo
'';
description = "Generate VHS demo GIFs";
};
};
scriptPackages =
pkgs.lib.mapAttrs
(
name: script:
pkgs.writeShellApplication {
inherit name;
text = script.exec;
runtimeInputs = script.deps or [];
}
)
scripts;
treefmtModule = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true; # Nix formatter
gofmt.enable = true; # Go formatter
golines.enable = true; # Go formatter (Shorter lines)
goimports.enable = true; # Go formatter (Organize/Clean imports)
};
};
in {
devShells.default = pkgs.mkShell {
name = "dev";
# Available packages on https://search.nixos.org/packages
packages = with pkgs;
[
alejandra # Nix
nixd
statix
deadnix
go_1_25 # Go Tools
air
golangci-lint
golangci-lint-langserver
gopls
revive
golines
gomarkdoc
gotests
gotestsum
gotools
reftools
goreleaser
vhs
gofumpt
# For docs site
biome
# Markdown linting
markdownlint-cli
inputs.flake-fmt.packages.${system}.default
]
++ builtins.attrValues scriptPackages;
};
devShells.ci = pkgs.mkShell {
name = "ci";
# Minimal CI/CD tooling - no interactive development tools
packages = with pkgs; [
# Nix formatting
alejandra
# Go toolchain
go_1_25
# Testing
gotestsum
gotools
# Linting
golangci-lint
# Build
goreleaser
];
};
packages = {
default = pkgs.buildGoModule rec {
pname = "spectr";
version = "0.0.10";
src = self;
vendorHash = "sha256-i0N0jXuI3r2LHruOuwFGscbk++kKgszKe6QDn07zkVk=";
ldflags = [
"-s"
"-w"
"-X github.com/connerohnesorge/spectr/internal/version.Version=${version}"
];
meta = with pkgs.lib; {
description = "A CLI tool for spec-driven development workflow with change proposals, validation, and archiving";
homepage = "https://github.com/connerohnesorge/spectr";
license = licenses.asl20;
maintainers = with maintainers; [connerohnesorge];
};
};
};
formatter = treefmt-nix.lib.mkWrapper pkgs treefmtModule;
});
}