-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
214 lines (188 loc) · 10 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
{
description = "tcarrio's NixOS and Home Manager Configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
# You can access packages and modules from different nixpkgs revs at the
# same time. See 'unstable-packages' overlay in 'overlays/default.nix'.
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-trunk.url = "github:nixos/nixpkgs/master";
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager/release-24.11";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Chaotic's Nyx provides many additional packages like NordVPN
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
chaotic.inputs.nixpkgs.follows = "nixpkgs-unstable";
nix-formatter-pack.url = "github:Gerschtli/nix-formatter-pack";
nix-formatter-pack.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
vscode-server.url = "github:msteen/nixos-vscode-server";
vscode-server.inputs.nixpkgs.follows = "nixpkgs";
devshells.url = "github:tcarrio/devshells";
devshells.inputs.nixpkgs.follows = "nixpkgs";
# Darwin support with nix-darwin
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# nixos-generators for sdcard and raw disk install generation
nixos-generators.url = "github:tcarrio/nixos-generators";
nixos-generators.inputs.nixpkgs.follows = "nixpkgs";
# Zen Browser
zen-browser.url = "github:MarceColl/zen-browser-flake";
zen-browser.inputs.nixpkgs.follows = "nixpkgs";
# IaC (WIP)
# inputs.terranix.url = "github:terranix/terranix";
# inputs.terranix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ self
, nix-formatter-pack
, nixpkgs
, devshells
, nix-darwin
, ...
} @ inputs:
let
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
stateVersion = "24.05";
inherit (self) outputs;
libx = import ./lib { inherit self inputs outputs stateVersion; };
in
{
# home-manager switch -b backup --flake $HOME/0xc/nixcfg
# nix build .#homeConfigurations."tcarrio@ripper".activationPackage
homeConfigurations = {
# .iso images
"nuc@iso-nuc" = libx.mkHome { hostname = "iso-nuc"; username = "nixos"; };
# TODO: Nvidia TK1 updates and installer
# "tk1@iso-tk1" = libx.mkHome { hostname = "iso-tk1"; username = "nixos"; };
# Workstations
"tcarrio@sktc0" = libx.mkHome { hostname = "sktc0"; username = "tcarrio"; platform = "aarch64-darwin"; };
"tcarrio@glass" = libx.mkHome { hostname = "glass"; username = "tcarrio"; desktop = "kde6"; };
# TODO: Update/reuse for new laptop or remove entirely
# "tcarrio@kuroi" = libx.mkHome { hostname = "kuroi"; username = "tcarrio"; desktop = "pantheon"; };
"tcarrio@t510" = libx.mkHome { hostname = "t510"; username = "tcarrio"; desktop = "i3"; };
"tcarrio@vm" = libx.mkHome { hostname = "vm"; username = "tcarrio"; desktop = "gnome"; };
};
# Support for nix-darwin workstations
# - darwin-rebuild build --flake .#sktc0
darwinConfigurations = {
"sktc0" = libx.mkDarwin { username = "tcarrio"; hostname = "sktc0"; stateVersion = 4; };
};
# Expose the package set, including overlays, for convenience.
darwinPackages = self.darwinConfigurations."sktc0".pkgs;
nixosConfigurations = {
# .iso images
# - nix build .#nixosConfigurations.{iso-console|iso-desktop}.config.system.build.isoImage
iso-nuc = libx.mkHost { systemType = "iso"; hostname = "iso-nuc"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
# TODO: Nvidia TK1 updates and installer
# iso-tk1 = libx.mkHost { systemType = "iso"; hostname = "iso-tk1"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "gnome"; };
iso-console = libx.mkHost { systemType = "iso"; hostname = "iso-console"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix"; };
iso-desktop = libx.mkHost { systemType = "iso"; hostname = "iso-desktop"; username = "nixos"; installer = nixpkgs + "/nixos/modules/installer/cd-dvd/installation-cd-graphical-calamares.nix"; desktop = "gnome"; };
# Workstations
# - sudo nixos-rebuild switch --flake $HOME/0xc/nixcfg
# - nix build .#nixosConfigurations.ripper.config.system.build.toplevel
glass = libx.mkHost { systemType = "workstation"; hostname = "glass"; username = "tcarrio"; desktop = "kde6"; };
# TODO: Update/reuse for new laptop or remove entirely
# kuroi = libx.mkHost { systemType = "workstation"; hostname = "kuroi"; username = "tcarrio"; desktop = "pantheon"; };
t510 = libx.mkHost { systemType = "workstation"; hostname = "t510"; username = "tcarrio"; desktop = "i3"; };
t510-headless = libx.mkHost { systemType = "workstation"; hostname = "t510-headless"; username = "tcarrio"; };
# Servers
# Can be executed locally:
# - sudo nixos-rebuild switch --flake $HOME/0xc/nixcfg
#
# Or remotely:
# - nixos-rebuild switch --fast --flake .#${HOST} \
# --target-host ${USERNAME}@${HOST}.${TAILNET} \
# --build-host ${USERNAME}@${HOST}.${TAILNET}
nuc-init = libx.mkHost { systemType = "server"; hostname = "nuc-init"; username = "nixos"; };
nuc0 = libx.mkHost { systemType = "server"; hostname = "nuc0"; username = "archon"; };
nuc1 = libx.mkHost { systemType = "server"; hostname = "nuc1"; username = "archon"; };
nuc2 = libx.mkHost { systemType = "server"; hostname = "nuc2"; username = "archon"; };
nuc3 = libx.mkHost { systemType = "server"; hostname = "nuc3"; username = "archon"; };
nuc4 = libx.mkHost { systemType = "server"; hostname = "nuc4"; username = "archon"; };
nuc5 = libx.mkHost { systemType = "server"; hostname = "nuc5"; username = "archon"; };
nuc6 = libx.mkHost { systemType = "server"; hostname = "nuc6"; username = "archon"; };
nuc7 = libx.mkHost { systemType = "server"; hostname = "nuc7"; username = "archon"; };
nuc8 = libx.mkHost { systemType = "server"; hostname = "nuc8"; username = "archon"; };
nuc9 = libx.mkHost { systemType = "server"; hostname = "nuc9"; username = "archon"; };
orca = libx.mkHost { systemType = "server"; hostname = "orca"; username = "archon"; };
shiroi = libx.mkHost { systemType = "server"; hostname = "shiroi"; username = "archon"; };
"nix-proxy-droplet" = libx.mkHost { systemType = "server"; hostname = "nix-proxy-droplet"; username = "archon"; };
};
# Devshell for bootstrapping; acessible via 'nix develop' or 'nix-shell' (legacy)
devShells = (libx.forAllDarwin (system:
let
pkgs = nixpkgs.legacyPackages.${system};
darwinNixPkgs = nix-darwin.packages.${system};
in
{
default = pkgs.mkShell {
NIX_CONFIG = "experimental-features = nix-command flakes";
packages = with pkgs; [ home-manager darwinNixPkgs.darwin-rebuild git ];
};
} // devshells.devShells.${system}
)) //
(libx.forAllLinux (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
NIX_CONFIG = "experimental-features = nix-command flakes";
packages = with pkgs; [ nix home-manager git ];
};
} // devshells.devShells.${system}
));
# nix fmt
formatter = libx.forAllSystems (system:
nix-formatter-pack.lib.mkFormatter {
pkgs = nixpkgs.legacyPackages.${system};
config.tools = {
alejandra.enable = false;
deadnix.enable = true;
nixpkgs-fmt.enable = true;
statix.enable = true;
};
}
);
# Custom packages and modifications, exported as overlays
overlays = import ./overlays { inherit inputs; };
# Custom packages; acessible via 'nix build', 'nix shell', etc
packages =
let
mkNuc = user: name: libx.mkGeneratorImage { systemType = "server"; hostname = name; username = user; };
in
(libx.forAllSystems
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
(import ./pkgs { inherit pkgs; })
//
{
# nuc-init = mkNuc "nixos" "nuc-init";
system-image-nuc0 = mkNuc "archon" "nuc0";
system-image-nuc1 = mkNuc "archon" "nuc1";
system-image-nuc2 = mkNuc "archon" "nuc2";
system-image-nuc3 = mkNuc "archon" "nuc3";
system-image-nuc4 = mkNuc "archon" "nuc4";
system-image-nuc5 = mkNuc "archon" "nuc5";
system-image-nuc6 = mkNuc "archon" "nuc6";
system-image-nuc7 = mkNuc "archon" "nuc7";
system-image-nuc8 = mkNuc "archon" "nuc8";
system-image-nuc9 = mkNuc "archon" "nuc9";
}
)) // {
x86_64-linux = {
# TODO: image is still too large: reduction with `qemu-img resize --shrink ./nixos.img 5.5G` didn't error out but image will not boot
linode-base-image = libx.mkGeneratorImage { systemType = "server"; hostname = "linode-base-image"; username = "archon"; format = "linode"; diskSize = 5120; };
digital-ocean-base-image = libx.mkGeneratorImage { systemType = "server"; hostname = "generic-base-image"; username = "archon"; format = "do"; };
};
};
# And custom nixos-generators definitions
# TODO: Nvidia Tegra TK1 image
# tk1 = libx.mkSdImage { hostname = "tk1"; username = "root"; systemType = "server"; };
};
}