-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
285 lines (258 loc) · 9.43 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
{
description = "Matt's Personal NixOS Flake";
nixConfig = {
experimental-features = ["nix-command" "flakes"];
extra-substituters = [
# Nix community's cache server
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
# There are many ways to reference flake inputs. The most widely used is github:owner/name/reference,
# which represents the GitHub repository URL + branch/commit-id/tag.
# Official NixOS package source, using nixos-unstable branch here
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
# Master branch, for when packages haven't migrated to the unstable branch
nixpkgs-master.url = "github:NixOS/nixpkgs";
# Stable branch, for when packages need to be rolled back
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-24.05";
home-manager = {
url = "github:nix-community/home-manager";
# The `follows` keyword in inputs is used for inheritance.
# Here, `inputs.nixpkgs` of home-manager is kept consistent with the `inputs.nixpkgs` of the current flake,
# to avoid problems caused by different versions of nixpkgs.
inputs.nixpkgs.follows = "nixpkgs";
};
# secret management
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# swayfx
swayfx = {
url = "github:WillPower3309/swayfx";
inputs.nixpkgs.follows = "nixpkgs";
};
# waybar
waybar = {
url = "github:Alexays/Waybar";
inputs.nixpkgs.follows = "nixpkgs";
};
# Always up-to-date emacs
emacs-overlay = {
url = "github:nix-community/emacs-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
spicetify-nix = {
url = "github:Gerg-L/spicetify-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
foundry = {
url = "github:reckenrode/nix-foundryvtt";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware/master";
};
wezterm = {
url = "github:wez/wezterm?dir=nix";
# inputs.nixpkgs.follows = "nixpkgs";
};
# Keyboard tool
kmonad = {
url = "git+https://github.com/kmonad/kmonad?submodules=1&dir=nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# `outputs` are all the build result of the flake.
# A flake can have many use cases and different types of outputs.
# parameters in `outputs` are defined in `inputs` and can be referenced by their names.
# However, `self` is an exception, This special parameter points to the `outputs` itself (self-reference)
# The `@` syntax here is used to alias the attribute set of the inputs's parameter, making it convenient to use inside the function.
outputs = {
nixpkgs,
home-manager,
kmonad,
sops-nix,
nixos-hardware,
...
} @ inputs: {
nixosConfigurations = {
# By default, NixOS will try to refer the nixosConfiguration with its hostname.
# so the system named `nixos-test` will use this configuration.
# However, the configuration name can also be specified using `sudo nixos-rebuild switch --flake /path/to/flakes/directory#<name>`.
# The `nixpkgs.lib.nixosSystem` function is used to build this configuration, the following attribute set is its parameter.
# Run `sudo nixos-rebuild switch --flake .#nixos-test` in the flake's directory to deploy this configuration on any NixOS system
"terra" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
# The Nix module system can modularize configuration, improving the maintainability of configuration.
#
# Each parameter in the `modules` is a Nix Module, and there is a partial introduction to it in the nixpkgs manual:
# <https://nixos.org/manual/nixpkgs/unstable/#module-system-introduction>
# It is said to be partial because the documentation is not complete, only some simple introductions
# (such is the current state of Nix documentation...)
# A Nix Module can be an attribute set, or a function that returns an attribute set.
# If a Module is a function, this function can only have the following parameters:
#
# lib: the nixpkgs function library, which provides many useful functions for operating Nix expressions
# https://nixos.org/manual/nixpkgs/stable/#id-1.4
# config: all config options of the current flake
# options: all options defined in all NixOS Modules in the current flake
# pkgs: a collection of all packages defined in nixpkgs.
# you can assume its default value is `nixpkgs.legacyPackages."${system}"` for now.
# can be customed by `nixpkgs.pkgs` option
# modulesPath: the default path of nixpkgs's builtin modules folder,
# used to import some extra modules from nixpkgs.
# this parameter is rarely used, you can ignore it for now.
#
# Only these parameters can be passed by default.
# If you need to pass other parameters, you must use `specialArgs` by uncomment the following line
specialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
modules = [
sops-nix.nixosModules.sops
kmonad.nixosModules.default
./system/terra.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.mjs = import ./home/terra.nix;
extraSpecialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
};
nixpkgs.overlays = [inputs.emacs-overlay.overlay];
}
];
};
"mars" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
modules = [
sops-nix.nixosModules.sops
kmonad.nixosModules.default
./system/mars.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.mjs = import ./home/mars.nix;
extraSpecialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
};
nixpkgs.overlays = [inputs.emacs-overlay.overlay];
}
];
};
"luna" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
modules = [
nixos-hardware.nixosModules.microsoft-surface-pro-intel
sops-nix.nixosModules.sops
kmonad.nixosModules.default
./system/luna.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.mjs = import ./home/luna.nix;
extraSpecialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
};
};
nixpkgs.overlays = [inputs.emacs-overlay.overlay];
}
];
};
"sol" = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
modules = [
sops-nix.nixosModules.sops
kmonad.nixosModules.default
./system/sol.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
users.mjs = import ./home/sol.nix;
extraSpecialArgs =
inputs
// {
pkgs-master = import inputs.nixpkgs-master {
inherit system;
};
pkgs-stable = import inputs.nixpkgs-stable {
inherit system;
};
};
};
}
];
};
};
};
}