Skip to content

Commit e495418

Browse files
committed
chopper: add kube0 microvm
1 parent cb374eb commit e495418

File tree

5 files changed

+179
-1
lines changed

5 files changed

+179
-1
lines changed

flake.lock

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@
4444
url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz";
4545
inputs.nixpkgs.follows = "nixpkgs";
4646
};
47-
# treefmt-nix
4847
treefmt-nix = {
4948
url = "github:numtide/treefmt-nix";
5049
};
50+
microvm = {
51+
url = "github:astro/microvm.nix";
52+
inputs.nixpkgs.follows = "nixpkgs";
53+
};
5154
};
5255

5356
outputs =

hosts/chopper/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ in
4343
./glance.nix
4444
./buildbot.nix
4545
./calibre.nix
46+
./microvm.nix
4647
];
4748

4849
boot.loader.systemd-boot.enable = true;

hosts/chopper/microvm.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{ inputs, ... }:
2+
{
3+
imports = [
4+
inputs.microvm.nixosModules.host
5+
];
6+
7+
microvm = {
8+
vms = {
9+
kube0.config = import ./vms/kube0.nix;
10+
};
11+
};
12+
13+
}

hosts/chopper/vms/kube0.nix

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{ pkgs, lib, ... }:
2+
{
3+
microvm = {
4+
mem = 8192;
5+
vcpu = 4;
6+
interfaces = [
7+
{
8+
type = "tap";
9+
id = "vm-kube0";
10+
mac = "02:00:00:00:00:01";
11+
}
12+
];
13+
shares = [
14+
{
15+
tag = "ro-store";
16+
source = "/nix/store";
17+
mountPoint = "/nix/.ro-store";
18+
}
19+
];
20+
volumes = [
21+
{
22+
image = "etc.img";
23+
label = "etc";
24+
mountPoint = "/etc";
25+
size = 500;
26+
autoCreate = true;
27+
}
28+
{
29+
image = "var.img";
30+
label = "var";
31+
mountPoint = "/var";
32+
size = 8192;
33+
autoCreate = true;
34+
}
35+
];
36+
};
37+
38+
# enable passwordless sudo
39+
security.sudo = {
40+
enable = lib.mkDefault true;
41+
wheelNeedsPassword = lib.mkForce false;
42+
};
43+
44+
users.users.mhelton = {
45+
isNormalUser = true;
46+
extraGroups = [
47+
"wheel"
48+
"networkmanager"
49+
];
50+
};
51+
users.users.mhelton.openssh.authorizedKeys.keys = [
52+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHD+tZ4hf4MhEW+akoZbXPN3Zi4cijSkQlX6bZlnV+Aq mhelton@gmail.com"
53+
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC5rmy7r//z1fARqDe6sIu5D4Nt5uD3rRvwtADDgb+sS6slv6I51Gm2rKcxDIHgYBSyhTDIuhNHlnn+cyJK4ZPxyZFxF0Vy0fZIFG3Y7AqkyQ0oXEDGYyqfL8U0mi0uGKmVW02T45w16REJG3x77uncw8VVxdEpKuYw+wk7uRlQpP/UiFYWsX4NS9rUS/aZrYZ2ys1/dCPqvz4KPXk7SZrqyqkiumIr8O0wluYI5FwhMtd3xpD9AQVI3V0zjYZPwesL+BkW4CAAm5dSnsns3haAuWHti/QLSR+90k15KhflXlq6JDzE4jrMbd1DYZqoVuTgoZxDB3HDJwEwpbYCWKLFaGR6ZDhE3NeFikNkdDRrlIcrK1wJCEO2QuDZ43IE/bDhLhOmqfliL6kRr+2G1AvY4Hr0jnJHbbHqN9mES5+VJZuhH2ii+QHS70VZN0NNQv7f0QJqiTVcUVuPXksBp6oojbkXK79CWd1X0u3shd6XinZ5N3KAD4PT8zlTCmglXNYamc1JpRqKzgFwgFcljXpHwtfuezpNVmzo1Vqi6Ib9S8qJi9rahhsafYP3Y+8EV3Ii3oXmGQBSwumAHCQIkiQ/Sc+FRS02GRgWuYOaQfvW99kLXbX+0eCMSdCJSLC+H1cO2b451qpDGGDnH9w+EvS04oyv4yufpwFlhys7qfU6HQ== mhelton@gmail.com"
54+
];
55+
56+
services.openssh = {
57+
enable = true;
58+
settings = {
59+
PermitRootLogin = lib.mkForce "no";
60+
PasswordAuthentication = false;
61+
};
62+
};
63+
64+
networking.firewall.enable = false;
65+
66+
networking.hostName = "kube0";
67+
environment.systemPackages = with pkgs; [
68+
neovim
69+
bottom
70+
];
71+
systemd.network.enable = true;
72+
systemd.network.networks."20-lan" = {
73+
matchConfig.Type = "ether";
74+
networkConfig = {
75+
Address = "192.168.20.70/23";
76+
Gateway = "192.168.20.1";
77+
DNS = "8.8.8.8";
78+
};
79+
};
80+
81+
services.k3s = {
82+
enable = true;
83+
role = "server";
84+
extraFlags = [
85+
"--flannel-backend wireguard-native"
86+
];
87+
};
88+
89+
}

0 commit comments

Comments
 (0)