nixos-servers/nixos/modules/k3s/default.nix

37 lines
929 B
Nix
Raw Normal View History

{ pkgs, lib, config, kubenix, ... }:
2023-12-29 12:46:12 +00:00
let cfg = config.lab.k3s;
in {
2023-12-29 12:46:12 +00:00
options.lab.k3s.enable = lib.mkOption {
default = false;
type = lib.types.bool;
description = ''
Whether to start k3s with custom configuration.
'';
};
config = lib.mkIf cfg.enable {
2024-02-11 13:18:11 +00:00
environment.systemPackages = with pkgs; [ k3s ];
networking = {
nftables.enable = lib.mkForce false;
firewall.enable = lib.mkForce false;
};
2023-12-26 12:44:59 +00:00
services.k3s = {
enable = true;
role = "server";
2024-02-11 13:18:11 +00:00
extraFlags = "--tls-san ${config.networking.fqdn} --snapshotter native";
2023-12-26 12:44:59 +00:00
};
system.activationScripts.k3s-bootstrap.text =
let
k3sBootstrapFile = (kubenix.evalModules.x86_64-linux {
module = import ./bootstrap.nix;
}).config.kubernetes.result;
in
''
2024-02-11 13:18:11 +00:00
ln -sf ${k3sBootstrapFile} /var/lib/rancher/k3s/server/manifests/k3s-bootstrap.json
'';
};
}