-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathvm.nix
102 lines (89 loc) · 2.12 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
96
97
98
99
100
101
102
{ ... }:
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 = {
"/zfs" = {
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;
boot = {
supportedFilesystems = [ "zfs" ];
zfs.forceImportRoot = false;
# See bug https://github.com/openebs/zfs-localpv/issues/614
kernelPackages = pkgs.linuxPackages_6_1;
zfs.package = pkgs.zfs;
};
networking = {
firewall = {
allowedTCPPorts = [
6443 # k3s: required so that pods can reach the API server (running on port 6443 by default)
];
};
# Set from machine-id or `head -c4 /dev/urandom | od -A none -t x4`
hostId = "111a0e06";
};
services = {
openssh.enable = true;
k3s = {
enable = true;
role = "server";
extraFlags = toString [
"--disable=traefik"
];
};
};
programs.git = {
enable = true;
config = {
safe = {
directory = [ "/zfs" "/zfs/nix/.go/src/github.com/kubernetes-csi/csi-test" "/zfs/nix/.go/src/github.com/kubernetes-csi/csi-test/.git" ];
};
};
};
systemd.tmpfiles.rules = [
"L+ /usr/local/bin - - - - /run/current-system/sw/bin/"
];
environment = {
variables = {
KUBECONFIG = "/etc/rancher/k3s/k3s.yaml";
CI_K3S = "true";
GOPATH = "/zfs/nix/.go";
EDITOR = "vim";
};
shellAliases = {
k = "kubectl";
ke = "kubectl -n openebs";
};
shellInit = ''
export PATH=$GOPATH/bin:$PATH
cd /zfs
'';
systemPackages = with pkgs; [ vim docker-client k9s e2fsprogs xfsprogs ];
};
}