Add configs for a new kubernetes cluster on NixOS.
This commit is contained in:
74
nix/kubernetes/formats/installer.nix
Normal file
74
nix/kubernetes/formats/installer.nix
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
modulesPath,
|
||||
targetSystem,
|
||||
...
|
||||
}:
|
||||
let
|
||||
installer = pkgs.writeShellApplication {
|
||||
name = "installer";
|
||||
runtimeInputs = with pkgs; [
|
||||
# clevis
|
||||
dosfstools
|
||||
e2fsprogs
|
||||
gawk
|
||||
nixos-install-tools
|
||||
util-linux
|
||||
config.nix.package
|
||||
];
|
||||
text = ''
|
||||
set -euo pipefail
|
||||
|
||||
${targetSystem.config.system.build.diskoScript}
|
||||
|
||||
nixos-install --no-channel-copy --no-root-password --option substituters "" --system ${targetSystem.config.system.build.toplevel}
|
||||
'';
|
||||
};
|
||||
installerFailsafe = pkgs.writeShellScript "failsafe" ''
|
||||
${lib.getExe installer} || echo "ERROR: Installation failure!"
|
||||
sleep 3600
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||
(modulesPath + "/profiles/all-hardware.nix")
|
||||
];
|
||||
|
||||
# boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_6_17;
|
||||
# boot.zfs.package = pkgs.zfs_unstable;
|
||||
boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux;
|
||||
boot.kernelParams = [
|
||||
"quiet"
|
||||
"systemd.unit=getty.target"
|
||||
];
|
||||
boot.supportedFilesystems.zfs = true;
|
||||
boot.initrd.systemd.enable = true;
|
||||
|
||||
networking.hostId = "04581ecf";
|
||||
|
||||
isoImage.makeEfiBootable = true;
|
||||
isoImage.makeUsbBootable = true;
|
||||
isoImage.squashfsCompression = "zstd -Xcompression-level 15";
|
||||
|
||||
environment.systemPackages = [
|
||||
installer
|
||||
];
|
||||
|
||||
systemd.services."getty@tty1" = {
|
||||
overrideStrategy = "asDropin";
|
||||
serviceConfig = {
|
||||
ExecStart = [
|
||||
""
|
||||
installerFailsafe
|
||||
];
|
||||
Restart = "no";
|
||||
StandardInput = "null";
|
||||
};
|
||||
};
|
||||
|
||||
# system.stateVersion = lib.mkDefault lib.trivial.release;
|
||||
system.stateVersion = "24.11";
|
||||
}
|
||||
36
nix/kubernetes/formats/iso.nix
Normal file
36
nix/kubernetes/formats/iso.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||
];
|
||||
|
||||
config = {
|
||||
isoImage.makeEfiBootable = true;
|
||||
isoImage.makeUsbBootable = true;
|
||||
|
||||
networking.dhcpcd.enable = true;
|
||||
networking.useDHCP = true;
|
||||
|
||||
me.buildingPortable = true;
|
||||
me.disko.enable = true;
|
||||
me.disko.offline.enable = true;
|
||||
me.mountPersistence = lib.mkForce false;
|
||||
# me.optimizations.enable = lib.mkForce false;
|
||||
|
||||
# Not doing image_based_appliance because this might be an install ISO, in which case we'd need nix to do the install.
|
||||
# me.image_based_appliance.enable = true;
|
||||
|
||||
# TODO: Should I use this instead of doing a mkIf for the disk config?
|
||||
# disko.enableConfig = false;
|
||||
|
||||
# Faster image generation for testing/development.
|
||||
isoImage.squashfsCompression = "zstd -Xcompression-level 15";
|
||||
};
|
||||
}
|
||||
32
nix/kubernetes/formats/sd.nix
Normal file
32
nix/kubernetes/formats/sd.nix
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/sd-card/sd-image.nix")
|
||||
];
|
||||
|
||||
config = {
|
||||
isoImage.makeEfiBootable = true;
|
||||
isoImage.makeUsbBootable = true;
|
||||
|
||||
boot.loader.grub.enable = false;
|
||||
boot.loader.generic-extlinux-compatible.enable = true;
|
||||
|
||||
# TODO: image based appliance?
|
||||
|
||||
# TODO: Maybe this?
|
||||
# fileSystems = {
|
||||
# "/" = {
|
||||
# device = "/dev/disk/by-label/NIXOS_SD";
|
||||
# fsType = "ext4";
|
||||
# options = [
|
||||
# "noatime"
|
||||
# "norelatime"
|
||||
# ];
|
||||
# };
|
||||
# };
|
||||
};
|
||||
}
|
||||
1
nix/kubernetes/formats/toplevel.nix
Normal file
1
nix/kubernetes/formats/toplevel.nix
Normal file
@@ -0,0 +1 @@
|
||||
{ }
|
||||
22
nix/kubernetes/formats/vm_iso.nix
Normal file
22
nix/kubernetes/formats/vm_iso.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/cd-dvd/iso-image.nix")
|
||||
(modulesPath + "/profiles/qemu-guest.nix") # VirtIO kernel modules
|
||||
];
|
||||
|
||||
config = {
|
||||
isoImage.makeEfiBootable = true;
|
||||
isoImage.makeUsbBootable = true;
|
||||
|
||||
networking.dhcpcd.enable = true;
|
||||
networking.useDHCP = true;
|
||||
|
||||
me.image_based_appliance.enable = true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user