forked from lucernae/nixos-pi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.control.nix
executable file
·79 lines (71 loc) · 1.75 KB
/
configuration.control.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
{ config, pkgs, lib, ... }:
let
user = builtins.getEnv "NIXOS_USER";
password = builtins.getEnv "NIXOS_PASSWORD";
sshPubKey = builtins.getEnv "NIXOS_SSH_PUBKEY";
SSID = builtins.getEnv "NIXOS_SSID";
SSIDpassword = builtins.getEnv "NIXOS_SSID_PASSWORD";
hostname = builtins.getEnv "NIXOS_HOSTNAME";
ip = builtins.getEnv "CONTROL_NODE_IP";
k3sToken = builtins.getEnv "K3S_TOKEN";
in {
imports = ["${fetchTarball "https://github.com/NixOS/nixos-hardware/archive/d2d9a58a5c03ea15b401c186508c171c07f9c4f1.tar.gz" }/raspberry-pi/4"];
fileSystems = {
"/" = {
device = "/dev/disk/by-label/NIXOS_SD";
fsType = "ext4";
options = [ "noatime" ];
};
};
networking = {
firewall = {
allowedTCPPorts = [ 6443 ];
enable = true;
trustedInterfaces = [ "cni0" ];
};
hostName = hostname;
wireless = {
enable = true;
networks."${SSID}".psk = SSIDpassword;
interfaces = [ "wlan0" ];
interfaces.wlan0 = {
useDHCP = false;
ipv4.addresses = [{
# I used static IP over WLAN because I want to use it as local DNS resolver
address = ip;
prefixLength = 24;
}];
};
};
};
environment.systemPackages = with pkgs; [
k3s
nano
curl
];
boot.kernelParams = [
"cgroup_memory=1"
"cgroup_enable=memory"
];
services.k3s = {
enable = true;
role = "server";
token = k3sToken;
clusterInit = true;
};
services.openssh = {
enable = true;
passwordAuthentication = false;
};
users = {
mutableUsers = false;
users."${user}" = {
openssh.authorizedKeys.keys = [
sshPubKey
];
isNormalUser = true;
password = password;
extraGroups = [ "wheel" ];
};
};
}