-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
334 lines (308 loc) · 9.37 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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
{
description = "My flake configuration";
nixConfig = {
experimental-features = ["nix-command" "flakes"];
#substituters = [
# # replace official cache with a mirror located in China
# # "https://mirrors.ustc.edu.cn/nix-channels/store"
# "https://cache.nixos.org/"
#];
# nix communitys cache server
# extra-substituters = [
# "https://hadolint.cachix.org"
# ];
# extra-trusted-public-keys = [
# "hadolint.cachix.org-1:CdmLJ7MXh5ojKBPUQGYklkbetIdIcC8tgOTGRUnxBjo="
# ];
};
outputs = inputs @ {
self,
nixpkgs,
...
}: let
inherit (inputs.nixpkgs) lib;
mylib = import ./lib {inherit lib;};
myvars = import ./vars {inherit lib;};
genSpecialArgs = system:
inputs
// {
pkgs-unstable = import inputs.nixpkgs-unstable {
inherit system; # refer the `system` parameter form outer scope recursively
# To use chrome, we need to allow the installation of non-free software
config.allowUnfree = true;
};
mylibx = import ./lib/extend.nix {
pkgs = import inputs.nixpkgs {inherit system;};
secrets = inputs.secrets;
inherit lib;
};
inherit mylib myvars system;
inherit (myvars) username userfullname useremail;
};
args = {inherit inputs lib mylib myvars genSpecialArgs;};
pve155Modules = {
nixos-modules = map mylib.relativeToRoot [
"hosts/pve155"
# "modules/nixos/hyprland.nix"
];
home-modules = map mylib.relativeToRoot [
"home/linux"
];
};
pve156Modules = {
nixos-modules = map mylib.relativeToRoot [
"hosts/pve156"
];
home-modules = map mylib.relativeToRoot [
"home/linux"
];
};
workTestModules = {
nixos-modules = map mylib.relativeToRoot [
"modules/nixos/base"
"modules/base.nix"
];
home-modules = map mylib.relativeToRoot [
"home/linux"
];
};
yuukoModules = {
darwin-modules = map mylib.relativeToRoot [
"modules/darwin"
"hosts/yuuko"
];
home-modules = map mylib.relativeToRoot [
"home/darwin"
"secrets/home.nix"
"hosts/yuuko/home.nix"
];
};
sakamotoModules = {
darwin-modules = map mylib.relativeToRoot [
"modules/darwin"
"hosts/sakamoto"
];
home-modules = map mylib.relativeToRoot [
"home/darwin"
"secrets/home.nix"
"hosts/sakamoto/home.nix"
];
};
mioModules = {
darwin-modules = map mylib.relativeToRoot [
"modules/darwin"
"hosts/mio"
];
home-modules = map mylib.relativeToRoot [
"home/darwin"
"secrets/home.nix"
"hosts/mio/home.nix"
];
};
nanoModules = {
darwin-modules = map mylib.relativeToRoot [
"modules/darwin"
"hosts/nano"
];
home-modules = map mylib.relativeToRoot [
"home/darwin"
];
};
lingModules = {
darwin-modules = map mylib.relativeToRoot [
"modules/darwin"
"hosts/ling"
];
home-modules = map mylib.relativeToRoot [
"home/darwin"
"hosts/ling/home.nix"
];
};
allSystemAbove = [
"x86_64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
forAllSystems = func: (nixpkgs.lib.genAttrs allSystemAbove func);
in {
# linux x86
nixosConfigurations = {
nixos = mylib.nixosSystem (pve155Modules // args // {system = "x86_64-linux";});
pve156 = mylib.nixosSystem (pve156Modules // args // {system = "x86_64-linux";});
work-test = mylib.nixosSystem (workTestModules // args // {system = "x86_64-linux";});
};
darwinConfigurations = {
# mac mini
yuuko = mylib.macosSystem (yuukoModules // args // {system = "aarch64-darwin";});
sakamoto = mylib.macosSystem (sakamotoModules // args // {system = "aarch64-darwin";});
# macbook air
mio = mylib.macosSystem (mioModules // args // {system = "aarch64-darwin";});
nano = mylib.macosSystem (nanoModules // args // {system = "x86_64-darwin";});
ling = mylib.macosSystem (lingModules // args // {system = "aarch64-darwin";});
};
colmena =
{
meta = (
let
system = "x86_64-linux";
in {
# colmena's default nixpkgs & specialArgs
nixpkgs = import nixpkgs {inherit system;};
specialArgs = genSpecialArgs system;
}
);
}
// {
pve156 = mylib.colmenaSystem (pve156Modules
// args
// {
tags = ["pve156"];
ssh-user = myvars.username;
system = "x86_64-linux";
});
};
checks = forAllSystems (
system: {
pre-commit-check = inputs.git-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra.enable = true; # formatter
typos = {
enable = true;
settings = {
write = true; # Automatically fix typos
configPath = "./.typos.toml"; # relative to the flake root
};
}; # Source code spell checker
prettier = {
enable = true;
settings = {
write = true; # Automatically format files
configPath = "./.prettierrc.yaml"; # relative to the flake root
};
}; # 主要用于文档检查
# deadnix.enable = true; # detect unused variable bindings in `*.nix`
# statix.enable = true; # lints and suggestions for Nix code(auto suggestions)
};
};
}
);
# Development Shells
devShells = forAllSystems (
system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
default = pkgs.mkShell {
packages = with pkgs; [
# fix https://discourse.nixos.org/t/non-interactive-bash-errors-from-flake-nix-mkshell/33310
bashInteractive
# deploy
colmena
# Nix-related
alejandra
deadnix
statix
# spell checker
typos
# code formatter
nodePackages.prettier
# tools
nix-prefetch-git
nix-prefetch-github
];
name = "dots";
shellHook = ''
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
}
);
formatter =
forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
# darwin
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-24.11-darwin";
nix-darwin = {
url = "github:lnl7/nix-darwin";
# inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "nixpkgs-darwin";
};
home-manager = {
#url = "github:nix-community/home-manager/release-24.05";
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
rime-main = {
# 霧凇拼音
url = "github:iDvel/rime-ice/main";
flake = false;
};
# hyprland
# hyprland = {
# url = "github:hyprwm/Hyprland/v0.38.1";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# my dotfiles
dotfiles = {
url = "github:shelken/dotfiles.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# secrets management
agenix = {
# lock with git commit at 0.15.0
url = "github:ryantm/agenix/564595d0ad4be7277e07fa63b5a991b3c645655d";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# secrets
secrets = {
url = "git+ssh://[email protected]/shelken/secrets.nix.git?shallow=1";
flake = false;
};
# git-hooks; gen pre-commit-config
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# generate iso/qcow2/docker/... image from nixos configuration
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
# vscode-server
vscode-server = {
url = "github:nix-community/nixos-vscode-server/fc900c16";
inputs.nixpkgs.follows = "nixpkgs";
};
# superfile = {
# url = "github:yorukot/superfile";
# inputs.nixpkgs.follows = "nixpkgs";
# };
# ╭──────────────────────────────────────────────────────────╮
# │ theme │
# ╰──────────────────────────────────────────────────────────╯
# btop主题
catppuccin-btop = {
url = "github:catppuccin/btop/21b8d595";
flake = false;
};
catppuccin-bat = {
url = "github:catppuccin/bat/d714cc1d";
flake = false;
};
catppuccin-yazi = {
url = "github:catppuccin/yazi/9bfdccc2";
flake = false;
};
catppuccin-lazygit = {
url = "github:catppuccin/lazygit/21a25afd";
flake = false;
};
};
}