-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
251 lines (246 loc) · 8.65 KB
/
flake.nix
File metadata and controls
251 lines (246 loc) · 8.65 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
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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-raspberrypi.url = "github:NixOS/nixpkgs/adc7c6f1bbaa73cda26be2323353b63a05b42f61";
nixpkgs-jupyterhub-pinned.url = "github:NixOS/nixpkgs/3c8a5fa9a699d6910bbe70490918f1a4adc1e462";
nixpkgs-ollama.url = "github:NixOS/nixpkgs/f173d0881eff3b21ebb29a2ef8bedbc106c86ea5";
nixos-hardware.url = "github:nixos/nixos-hardware";
nixvim = {
url = "github:nix-community/nixvim/nixos-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-25.11";
inputs.nixpkgs.follows = "nixpkgs";
};
framework-audio-presets = {
url = "github:ceiphr/ee-framework-presets";
flake = false;
};
niri-flake = {
url = "github:sodiboo/niri-flake";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
inputs@{
self,
flake-utils,
nixpkgs,
nixos-hardware,
home-manager,
...
}:
{
homeManagerModules = {
profiles = {
bat = import ./home-manager/profiles/bat.nix;
eza = import ./home-manager/profiles/eza.nix;
fzf = import ./home-manager/profiles/fzf;
git = import ./home-manager/profiles/git.nix;
i3 = import ./home-manager/profiles/x11/i3.nix;
starship = import ./home-manager/profiles/starship;
tmux = import ./home-manager/profiles/tmux;
vivid = import ./home-manager/profiles/vivid.nix;
zoxide = import ./home-manager/profiles/zoxide.nix;
zsh = import ./home-manager/profiles/zsh.nix;
};
};
}
// flake-utils.lib.eachDefaultSystem (
system:
let
neovim = inputs.nixvim.legacyPackages.${system}.makeNixvimWithModule {
module.imports = [ ./neovim/default.nix ];
};
in
{
packages = {
inherit neovim;
# Nest homeConfigurations under packages to both be a recognized location
# by `home-manager switch --flake` and benefit from `eachDefaultSystem`.
homeConfigurations =
with nixpkgs.lib;
let
user = "dwf";
mkHome =
{
hostname ? null,
username ? user,
stateVersion ? "21.11",
homePath ? "/home",
homeDirectory ? "${homePath}/${username}",
nixpkgs ? inputs.nixpkgs,
includeNvim ? hostname != null,
}:
home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages.${system};
modules = [
(if hostname == null then ./home-manager/hosts else ./home-manager/hosts/${hostname})
{
home = {
inherit username homeDirectory stateVersion;
packages = optionals includeNvim [ neovim ];
};
}
];
extraSpecialArgs = { inherit inputs; };
};
in
listToAttrs (
map
(
hostname:
nameValuePair (concatStringsSep "@" ([ user ] ++ optionals (hostname != null) [ hostname ]))
(mkHome {
inherit hostname;
})
)
[
null
"shockwave"
"skyquake"
"superion"
"wheeljack"
"soundwave"
]
);
}
// (import ./pkgs/zelda3 { pkgs = nixpkgs.legacyPackages.${system}; });
}
)
// rec {
nixosModules = rec {
# Hardware profile for MacBookPro11,1, used by skyquake.
hardware.macbook-pro-11-1 = {
imports = [
# Inherit generic Intel CPU and SSD configuration from nixos-hardware.
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-pc-laptop-ssd
./nixos/profiles/macbook-pro-11-1.nix
];
};
# Syntactic sugar for setting up HTTPS reverse proxy gateways with
# certificates provided by Tailscale.
tailscale-https-reverse-proxy = import ./nixos/modules/tailscale-https.nix;
# TigerVNC with noVNC web client frontend all managed by systemd.
vnc = import ./nixos/modules/vnc.nix;
machines =
let
jupyterhub =
args:
import ./nixos/profiles/jupyterhub.nix (
args
// {
pkgs = inputs.nixpkgs-jupyterhub-pinned.legacyPackages.x86_64-linux;
}
);
mkMachine =
name: modules:
[
{ system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; }
./nixos/profiles/global.nix
(./. + "/nixos/hosts/${name}")
]
++ modules;
in
nixpkgs.lib.mapAttrs mkMachine {
bumblebee = [
tailscale-https-reverse-proxy
vnc
];
cliffjumper = [
./nixos/profiles/disable-efi.nix
"${nixpkgs}/nixos/modules/virtualisation/google-compute-image.nix"
];
kup = [ ];
perceptor = [ ];
shockwave = [
./nixos/profiles/disable-efi.nix
nixos-hardware.nixosModules.raspberry-pi-4
nixos-hardware.nixosModules.common-pc-ssd
./nixos/modules/auto-abcde.nix
tailscale-https-reverse-proxy
];
skyquake = [
hardware.macbook-pro-11-1
];
soundwave = [
tailscale-https-reverse-proxy
];
superion = [
nixos-hardware.nixosModules.framework-13-7040-amd
];
wheeljack = [
tailscale-https-reverse-proxy
jupyterhub
./nixos/profiles/remote-build.nix
(import ./nixos/profiles/ollama.nix {
nixpkgs = inputs.nixpkgs-ollama;
})
];
};
};
nixosConfigurations =
let
mkConfiguration =
name: modules:
let
defaultSystem = "x86_64-linux";
systemOverrides = {
shockwave = "aarch64-linux";
};
in
nixpkgs.lib.nixosSystem {
inherit modules;
system =
if (builtins.hasAttr name systemOverrides) then
(builtins.getAttr name systemOverrides)
else
defaultSystem;
specialArgs = { inherit nixosModules inputs; };
};
crossCompile = arch: {
nixpkgs = {
config.allowUnsupportedSystem = true;
hostPlatform.system = arch;
buildPlatform.system = "x86_64-linux";
};
};
raspberryPiZeroW =
name:
inputs.nixpkgs-raspberrypi.lib.nixosSystem {
modules = [
"${inputs.nixpkgs-raspberrypi}/nixos/modules/installer/sd-card/sd-image-raspberrypi.nix"
(crossCompile "armv6l-linux")
./nixos/profiles/rpi-zero-w
./nixos/profiles/global.nix
./nixos/profiles/disable-efi.nix
(./. + "/nixos/hosts/${name}")
];
system = "armv6l-linux";
};
raspberryPiZeroWHosts = [ "slamdance" ];
installerModules = [
"${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-graphical-gnome.nix"
"${nixpkgs}/nixos/modules/installer/cd-dvd/channel.nix"
];
in
{
# Build with `nix build .#nixosConfigurations.macbook-pro-11-1-installer.config.system.build.isoImage`
macbook-pro-11-1-installer = nixpkgs.lib.nixosSystem {
modules = installerModules ++ [ ./nixos/media/macbook-pro-11-1.nix ];
system = "x86_64-linux";
};
installer-with-sshd = nixpkgs.lib.nixosSystem {
modules = installerModules ++ [ ./nixos/media/with-sshd.nix ];
system = "x86_64-linux";
};
}
// nixpkgs.lib.mapAttrs mkConfiguration self.nixosModules.machines
// builtins.listToAttrs (
map (n: nixpkgs.lib.nameValuePair n (raspberryPiZeroW n)) raspberryPiZeroWHosts
);
};
}