-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
154 lines (125 loc) · 5.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
{
description = "Skarabox's flake to install NixOS";
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs/nixos-unstable";
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixos-generators, disko, ... }: {
packages.x86_64-linux = {
beacon = nixos-generators.nixosGenerate {
system = "x86_64-linux";
format = "install-iso";
modules = [({ config, lib, ... }: {
users.users.nixos.initialHashedPassword = lib.mkForce "$y$j9T$7EZvmryvlpTHSRG7dC5IU1$lBc/nePnkvqZ//jNpx/UpFKze/p6P7AIhJubK/Ghj68";
isoImage.isoName = lib.mkForce "beacon.iso";
networking.firewall.allowedTCPPorts = [ 22 ];
services.hostapd = {
enable = true;
radios.skarabox = {
band = "2g";
networks.skarabox = {
ssid = "Skarabox";
authentication = {
mode = "wpa2-sha256";
wpaPassword = "skarabox";
};
};
};
};
services.getty.helpLine = lib.mkForce ''
/ \\
|/ _.-=-._ \\| SKARABOX
\\'_/`-. .-'\\_'/
'-\\ _ V _ /-'
.' 'v' '. Hello, you just booted on the Skarabox beacon.
.'| | |'. Congratulations!
v'| | |'v
| | | Nothing is installed yet on this server. To abort, just
.\\ | /. close this server and remove the USB stick.
(_.'._^_.'._)
\\\\ // To complete the installation of Skarabox on this server, you
\\'- -'/ must follow the steps below to run the Skarabox installer.
WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING
* *
* Running the Skarabox installer WILL ERASE EVERYTHING on this server. *
* Make sure the only drives connected and powered on are the disks to *
* install the Operating System on. This drive should be a SSD or NVMe *
* drive for optimal performance and 2 hard drives for data. *
* *
* THESE DRIVES WILL BE ERASED. *
* *
WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING
* Step 1. Enable network access to this server.
For a wired network connection, just plug in an ethernet cable from your router
to this server. The connection will be made automatically.
If the server is equipped with a WiFi card, a WiFi network called "skarabox" will
be available. Connect your laptop to that WiFi network. This network will only be
available during installation.
A wired network connection is available if you connect an Ethernet cable. If you
need a wireless connection, configure a network by typing the command "wpa_cli"
without the enclosing double quotes.
* Step 2. Run the installer.
When running the installer, you will need to enter the password "skarabox123" as
well as the IP address of this server. To know the IP address, first follow the
step 1 above then type the command "ip -brief a" verbatim, without the enclosing
double quotes.
Try all IP addresses one by one until one works. An IP address looks like so:
192.168.1.15
10.0.2.15
* Step 3.
No step 3. The server will reboot automatically in the new system as soon as the
installer ran successfully. Enjoy your NixOS system powered by Skarabox!
'';
})];
};
beacon-test = let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
iso = "${self.outputs.packages.${system}.beacon}/iso/beacon.iso";
hostSshPort = 2222;
in (pkgs.writeShellScriptBin "runner.sh" ''
${pkgs.qemu}/bin/qemu-system-x86_64 \
-m 2048M \
-nic hostfwd=tcp::${toString hostSshPort}-:22 \
--drive media=cdrom,format=raw,readonly=on,file=${iso}
'');
};
nixosModules.skarabox = let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
};
in {
imports = [
disko.nixosModules.disko
"${pkgs.path}/nixos/modules/profiles/all-hardware.nix"
./installNixOs/disks.nix
./installNixOs/configuration.nix
];
};
apps.x86_64-linux = {
beacon-test = {
type = "app";
program = "${self.outputs.packages.x86_64-linux.beacon-test}/bin/runner.sh";
};
};
templates = {
skarabox = {
path = ./template;
description = "Skarabox template";
};
default = self.templates.skarabox;
};
};
}