2024-10-05 12:33:48 -07:00
|
|
|
{ pkgs, hostConf, inputs, ... }: {
|
2024-10-08 17:03:45 -07:00
|
|
|
imports = [
|
|
|
|
"${inputs.nixpkgs-unstable}/nixos/modules/services/cluster/k3s/default.nix"
|
|
|
|
];
|
|
|
|
disabledModules = [
|
|
|
|
"services/cluster/k3s/default.nix"
|
|
|
|
];
|
2024-10-08 11:47:27 -07:00
|
|
|
networking.firewall = {
|
|
|
|
allowedTCPPorts = [
|
|
|
|
6443 # k3s API
|
|
|
|
2379 # k3s etcd clients
|
|
|
|
2380 # k3s etcd peers
|
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
|
|
|
8472 # k3s flannel
|
|
|
|
];
|
|
|
|
};
|
|
|
|
networking.hosts = {
|
|
|
|
"192.168.1.31" = [ "bard" ];
|
|
|
|
"192.168.1.32" = [ "ranger" ];
|
|
|
|
"192.168.1.33" = [ "cleric" ];
|
|
|
|
};
|
|
|
|
services.k3s = {
|
|
|
|
enable = true;
|
|
|
|
role = "server";
|
|
|
|
tokenFile = "/var/lib/rancher/k3s/server/token";
|
|
|
|
extraFlags = toString [
|
|
|
|
"--write-kubeconfig-mode \"0644\""
|
|
|
|
"--disable servicelb"
|
|
|
|
"--disable traefik"
|
|
|
|
"--disable local-storage"
|
|
|
|
];
|
|
|
|
clusterInit = (hostConf.name == "bard");
|
|
|
|
serverAddr = (if hostConf.name == "bard" then "" else "https://192.168.1.31:6443");
|
2024-10-25 14:12:23 -07:00
|
|
|
manifests = { }; # We are going to manage k8s resources separately from
|
|
|
|
# the infrastructure config
|
2024-10-08 17:03:45 -07:00
|
|
|
};
|
|
|
|
services.openiscsi = {
|
|
|
|
enable = false;
|
|
|
|
name = "iqn.2020-03.net.jafner:${hostConf.name}-initiatorhost";
|
2024-10-08 11:47:27 -07:00
|
|
|
};
|
2024-10-08 17:03:45 -07:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"L+ /usr/local/bin - - - - /run/current-system-sw/bin/"
|
|
|
|
];
|
|
|
|
virtualisation.docker.logDriver = "json-file";
|
2024-10-05 12:33:48 -07:00
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
vim
|
|
|
|
fastfetch
|
|
|
|
tree
|
|
|
|
btop
|
|
|
|
bat
|
|
|
|
fd
|
|
|
|
eza
|
|
|
|
fzf
|
2024-10-08 11:47:27 -07:00
|
|
|
k3s
|
|
|
|
cifs-utils
|
|
|
|
nfs-utils
|
|
|
|
git
|
2024-10-08 17:03:45 -07:00
|
|
|
dig
|
|
|
|
openiscsi
|
2024-10-05 12:33:48 -07:00
|
|
|
];
|
|
|
|
security.sudo = {
|
|
|
|
enable = true;
|
|
|
|
extraRules = [{
|
|
|
|
commands = [
|
|
|
|
{
|
|
|
|
command = "ALL";
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
groups = [ "wheel" ];
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
settings.KbdInteractiveAuthentication = false;
|
|
|
|
};
|
2024-10-08 17:03:45 -07:00
|
|
|
services.rpcbind.enable = true;
|
2024-10-05 12:33:48 -07:00
|
|
|
users.users = {
|
|
|
|
admin = {
|
|
|
|
isNormalUser = true;
|
|
|
|
description = "admin";
|
|
|
|
extraGroups = [ "networkmanager" "wheel" ];
|
|
|
|
openssh.authorizedKeys.keys = let
|
|
|
|
authorizedKeys = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/Jafner.keys";
|
|
|
|
sha256 = "1i3Vs6mPPl965g3sRmbXGzx6zQBs5geBCgNx2zfpjF4=";
|
|
|
|
};
|
|
|
|
in pkgs.lib.splitString "\n" (builtins.readFile authorizedKeys);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
networking = {
|
|
|
|
hostName = "${hostConf.name}";
|
2024-10-08 11:47:27 -07:00
|
|
|
defaultGateway = { address = "192.168.1.1"; interface = "enp1s0"; };
|
2024-10-05 12:33:48 -07:00
|
|
|
interfaces."${hostConf.nic.name}" = {
|
2024-10-08 11:47:27 -07:00
|
|
|
useDHCP = false;
|
2024-10-05 12:33:48 -07:00
|
|
|
macAddress = "${hostConf.nic.mac}";
|
|
|
|
ipv4.addresses = [ { address = "${hostConf.nic.ip}"; prefixLength = 24; } ];
|
|
|
|
};
|
2024-10-08 17:03:45 -07:00
|
|
|
nameservers = [
|
|
|
|
"10.0.0.1"
|
|
|
|
];
|
2024-10-05 12:33:48 -07:00
|
|
|
};
|
2024-10-08 11:47:27 -07:00
|
|
|
nix.settings.experimental-features = [ "nix-command" "flakes" ];
|
2024-10-05 12:33:48 -07:00
|
|
|
time.timeZone = "America/Los_Angeles";
|
|
|
|
nix.settings.trusted-users = [ "root" "admin" ];
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
2024-10-08 17:03:45 -07:00
|
|
|
boot.supportedFilesystems = [ "nfs" ];
|
2024-10-05 12:33:48 -07:00
|
|
|
system.stateVersion = "24.05";
|
|
|
|
}
|