-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
263 lines (239 loc) · 6.8 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
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs/nixos-unstable";
};
systems = {
url = "github:nix-systems/default";
};
# For declarative block device provisioning
disko = {
url = "github:nix-community/disko";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
# For fetch-closure shrunk release packages with minimal eval time and dependency sizes
# Currently x86_64-linux only
capkgs = {
url = "github:input-output-hk/capkgs";
};
# Required image signing tooling
credential-manager = {
url = "github:IntersectMBO/credential-manager";
};
# Even secure operations can be pretty
catppuccin = {
url = "github:catppuccin/nix";
};
# For better caps lock
xremap-flake = {
url = "github:xremap/nix-flake";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
# For various shell configs
home-manager = {
url = "github:nix-community/home-manager";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
# Just because
nvim = {
url = "github:cymenix/nvim";
inputs = {
nixpkgs = {
follows = "nixpkgs";
};
};
};
};
outputs = {
self,
nixpkgs,
systems,
...
} @ inputs: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
nixosModules = let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
inherit (pkgs) lib;
in {
default = import ./modules {inherit inputs pkgs nixpkgs system lib;};
};
nixosConfigurations = let
system = "x86_64-linux";
pkgs = import nixpkgs {inherit system;};
inherit (pkgs) lib;
in {
minimal = nixpkgs.lib.nixosSystem rec {
inherit system;
specialArgs = {inherit self inputs pkgs lib nixpkgs system;};
modules = [
self.nixosModules.default
({...}: {
airgap = {
enable = true;
device = "/dev/sdc";
keymap = "us";
locale = "en_US.UTF-8";
host = "airgap";
user = "airgap";
group = "airgap";
initialPassword = "airgap";
uid = 1234;
home = {
enable = false;
};
catppuccin = {
enable = false;
};
ui = {
enable = false;
gnome = {
enable = false;
};
};
};
})
];
};
de_minimal_themed = nixpkgs.lib.nixosSystem rec {
inherit system;
specialArgs = {inherit self inputs pkgs lib nixpkgs system;};
modules = [
self.nixosModules.default
({...}: {
airgap = {
enable = true;
device = "/dev/sdc";
keymap = "de";
locale = "de_DE.UTF-8";
host = "airgap";
user = "airgap";
group = "airgap";
initialPassword = "airgap";
uid = 1234;
home = {
enable = true;
};
catppuccin = {
enable = true;
};
ui = {
enable = false;
gnome = {
enable = false;
};
};
};
})
];
};
de_gnome_themed = nixpkgs.lib.nixosSystem rec {
inherit system;
specialArgs = {inherit self inputs pkgs nixpkgs system;};
modules = [
self.nixosModules.default
({...}: {
airgap = {
enable = true;
device = "/dev/sdc";
keymap = "de";
locale = "de_DE.UTF-8";
host = "airgap";
user = "airgap";
group = "airgap";
initialPassword = "airgap";
uid = 1234;
home = {
enable = true;
};
catppuccin = {
enable = true;
};
ui = {
enable = true;
gnome = {
enable = true;
};
};
};
})
];
};
};
packages = forEachSystem (system: let
pkgs = import nixpkgs {inherit system;};
in {
default = self.packages.${system}.airgap-install;
airgap-install = pkgs.writeShellApplication {
name = "airgap-install";
runtimeInputs = with pkgs; [disko];
text = ''
usage() {
echo "Usage: $0 [--dry-run] <device> [config]"
echo " --dry-run Run in dry-run mode"
echo " --update Update only"
echo " [config] Nix flake output for disko-install (default: github:clemenscodes/airgap2go#minimal)"
exit 1
}
error() {
echo "Error: Invalid config or $1 not found."
exit 1
}
resolve_config_value() {
local config
local path
local full_uri
local value
config=$1
path=$2
full_uri=$(echo "$config" | awk -v insert="nixosConfigurations." -F'#' '{print $1 "#" insert $2}')
value=$(nix eval "$full_uri.$path" 2>/dev/null || error "$path")
value=$(echo "$value" | tr -d '"')
echo "$value"
}
if [ "$#" -lt 1 ]; then
usage
fi
DRY_RUN=false
if [ "$#" -ge 1 ] && [ "$1" == "--dry-run" ]; then
DRY_RUN=true
shift
fi
MODE="format"
if [ "$#" -ge 1 ] && [ "$1" == "--update" ]; then
MODE="mount"
shift
fi
CONFIG=''${1:-github:clemenscodes/airgap2go#minimal}
DEVICE=$(resolve_config_value "$CONFIG" "config.airgap.device")
MOUNTPOINT=$(resolve_config_value "$CONFIG" "config.airgap.rootMountPoint")
if [ "$DRY_RUN" == true ]; then
echo "Running in dry-run mode..."
disko-install --dry-run --mode "$MODE" -f "$CONFIG" --mount-point "$MOUNTPOINT" --disk main "$DEVICE"
else
echo "Running in actual mode (requires sudo)..."
sudo disko-install --mode "$MODE" -f "$CONFIG" --mount-point "$MOUNTPOINT" --disk main "$DEVICE"
fi
'';
};
});
formatter = forEachSystem (system: let pkgs = import nixpkgs {inherit system;}; in pkgs.alejandra);
};
nixConfig = {
extra-trusted-public-keys = ["hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="];
extra-substituters = ["https://cache.iog.io"];
};
}