blob: 2a0a7ab25771f134ac6068d7543415ede79aaae1 [file] [log] [blame]
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.hscloud.base;
in {
options.hscloud.base = {
fqdn = mkOption {
type = types.str;
description = "Node's FQDN.";
default = "${config.networking.hostName}.${config.networking.domain}";
};
mgmtIf = mkOption {
type = types.str;
description = "Main network interface. Called mgmtIf for legacy reasons.";
};
ipAddr = mkOption {
type = types.str;
description = "IPv4 address on main network interface.";
};
ipAddrBits = mkOption {
type = types.int;
description = "IPv4 CIDR mask bits.";
};
gw = mkOption {
type = types.str;
description = "IPv4 address of gateway.";
};
};
# Override current nixos kubernetes with our vendored fork.
# Also nuke flannel from orbit.
disabledModules = [
"services/cluster/kubernetes/apiserver.nix"
"services/cluster/kubernetes/controller-manager.nix"
"services/cluster/kubernetes/default.nix"
"services/cluster/kubernetes/kubelet.nix"
"services/cluster/kubernetes/pki.nix"
"services/cluster/kubernetes/proxy.nix"
"services/cluster/kubernetes/scheduler.nix"
"services/cluster/kubernetes/flannel.nix"
];
imports = [
./vendor/apiserver.nix
./vendor/controller-manager.nix
./vendor/default.nix
./vendor/kubelet.nix
./vendor/pki.nix
./vendor/proxy.nix
./vendor/scheduler.nix
];
config = rec {
boot.loader.grub.enable = true;
boot.loader.grub.version = 2;
fileSystems."/" =
{ # device = ""; needs to be defined
fsType = "ext4";
};
swapDevices = [ ];
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelParams = [ "boot.shell_on_fail" ];
boot.kernel.sysctl."net.ipv4.conf.all.rp_filter" = "0";
boot.kernel.sysctl."net.ipv4.conf.default.rp_filter" = "0";
boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "megaraid_sas" "usb_storage" "usbhid" "sd_mod" "sr_mod" ];
boot.initrd.kernelModules = [ "dm-raid" "dm-snapshot" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [];
hardware.enableRedistributableFirmware = true;
hardware.cpu.intel.updateMicrocode = true;
hardware.cpu.amd.updateMicrocode = true;
environment.etc."lvm/lvm.conf".text = ''
devices/issue_discards = 1
'';
time.timeZone = "Europe/Warsaw";
environment.systemPackages = with pkgs; [
wget vim htop tcpdump screen tmux smartmontools pciutils lm_sensors ipmitool
rxvt_unicode.terminfo
];
programs.mtr.enable = true;
networking.useDHCP = false;
networking.interfaces."${cfg.mgmtIf}" = {
ipv4.addresses = [
{
address = cfg.ipAddr;
prefixLength = cfg.ipAddrBits;
}
];
};
networking.defaultGateway = cfg.gw;
networking.nameservers = ["185.236.240.1"];
# Instead of using nixpkgs from the root/nixos channel, use pkgs pin from this file.
nix.nixPath = [ "nixpkgs=${pkgs.path}" "nixos-config=/etc/nixos/configuration.nix" ];
# Otherwise fetchGit nixpkgs pin fails.
systemd.services.nixos-upgrade.path = [ pkgs.git ];
# Use Chrony instead of systemd-timesyncd
services.chrony = {
enable = true;
# cockroach will refuse to start up at error>500ms, so let's just step
# aggresively so it's correct ASAP
initstepslew = {
enabled = true;
threshold = 1;
};
extraConfig = ''
rtcfile /var/lib/chrony/rtc
rtcautotrim 10
'';
};
# Symlink lvm into /sbin/lvm on activation. This is needed by Rook OSD
# instances running on Kubernetes.
# See: https://github.com/rook/rook/commit/f3c4975e353e3ce3599c958ec6d2cae8ee8f6f61
system.activationScripts.sbinlvm =
''
mkdir -m 0755 -p /sbin
ln -sfn ${pkgs.lvm2.bin}/bin/lvm /sbin/lvm
'';
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Enable fstrim, as we run / on SSDs everywhere.
services.fstrim = {
enable = true;
interval = "daily";
};
users.users.root.openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDD4VJXAXEHEXZk2dxNwehneuJcEGkfXG/U7z4fO79vDVIENdedtXQUyLyhZJc5RTEfHhQj66FwIqzl7mzBHd9x9PuDp6QAYXrkVNMj48s6JXqZqBvF6H/weRqFMf4a2TZv+hG8D0kpvmLheCwWAVRls7Jofnp/My+yDd57GMdsbG/y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