-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathvm.nix
95 lines (85 loc) · 1.86 KB
/
vm.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
{ ... }:
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs { };
in
{
nix.nixPath = [
"nixpkgs=${pkgs.path}"
];
nixos-shell.mounts = {
mountHome = false;
mountNixProfile = false;
cache = "none"; # default is "loose"
extraMounts = {
"/lvm" = {
target = ./.;
cache = "none";
};
};
};
virtualisation = {
cores = 4;
memorySize = 2048;
# Uncomment to be able to ssh into the vm, example:
# ssh -p 2222 -o StrictHostKeychecking=no root@localhost
# forwardPorts = [
# { from = "host"; host.port = 2222; guest.port = 22; }
# ];
diskSize = 20 * 1024;
docker = {
enable = true;
};
};
documentation.enable = false;
networking.firewall = {
allowedTCPPorts = [
6443 # k3s: required so that pods can reach the API server (running on port 6443 by default)
];
};
services = {
openssh.enable = true;
k3s = {
enable = true;
role = "server";
extraFlags = toString [
"--disable=traefik"
];
};
lvm = {
dmeventd.enable = true;
};
};
programs.git = {
enable = true;
config = {
safe = { directory = "/lvm"; };
};
};
environment = {
variables = {
KUBECONFIG = "/etc/rancher/k3s/k3s.yaml";
CI_K3S = "true";
EDITOR = "vim";
GOPATH = "/lvm/nix/.go";
};
shellAliases = {
k = "kubectl";
ke = "kubectl -n openebs";
};
etc."lvm/lvm.conf".text = ''
global {
# system_id_source = "machineid"
}
activation {
thin_pool_autoextend_threshold = 50
thin_pool_autoextend_percent = 20
}
'';
shellInit = ''
export PATH=$GOPATH/bin:$PATH
cd /lvm
'';
systemPackages = with pkgs; [ vim docker-client k9s e2fsprogs ] ++ [ thin-provisioning-tools lvm2_dmeventd ];
};
}