Compare commits

...

10 commits

16 changed files with 480 additions and 6 deletions

33
flake.lock generated
View file

@ -20,6 +20,26 @@
"type": "github"
}
},
"disko": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1753140376,
"narHash": "sha256-7lrVrE0jSvZHrxEzvnfHFE/Wkk9DDqb+mYCodI5uuB8=",
"owner": "nix-community",
"repo": "disko",
"rev": "545aba02960caa78a31bd9a8709a0ad4b6320a5c",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "disko",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -117,11 +137,11 @@
},
"nixos-hardware": {
"locked": {
"lastModified": 1754229794,
"narHash": "sha256-yOl7REX6O/1mh+tpscJPKgjK6nmXSMOB1xhmDNAMUZM=",
"lastModified": 1754564048,
"narHash": "sha256-dz303vGuzWjzOPOaYkS9xSW+B93PSAJxvBd6CambXVA=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "a872d985392ee5b19d8409bfcc3f106de2070070",
"rev": "26ed7a0d4b8741fe1ef1ee6fa64453ca056ce113",
"type": "github"
},
"original": {
@ -133,11 +153,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1754028485,
"narHash": "sha256-IiiXB3BDTi6UqzAZcf2S797hWEPCRZOwyNThJIYhUfk=",
"lastModified": 1754767907,
"narHash": "sha256-8OnUzRQZkqtUol9vuUuQC30hzpMreKptNyET2T9lB6g=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "59e69648d345d6e8fef86158c555730fa12af9de",
"rev": "c5f08b62ed75415439d48152c2a784e36909b1bc",
"type": "github"
},
"original": {
@ -241,6 +261,7 @@
"root": {
"inputs": {
"auto-cpufreq": "auto-cpufreq",
"disko": "disko",
"home-manager": "home-manager",
"lazy-apps": "lazy-apps",
"nixos-hardware": "nixos-hardware",

View file

@ -18,6 +18,10 @@
inputs.nixpkgs.follows = "nixpkgs";
};
proxmox-nixos.url = "github:SaumonNet/proxmox-nixos";
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
systems.url = "github:nix-systems/default-linux";
};
@ -30,6 +34,7 @@
home-manager,
auto-cpufreq,
proxmox-nixos,
disko,
systems,
...
} @ inputs: let
@ -111,6 +116,59 @@
})
];
};
srv01-hf = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
inherit inputs outputs;
};
modules = [
disko.nixosModules.disko
./hosts/srv01.hf
];
};
kube01 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
inherit inputs outputs;
};
modules = [
disko.nixosModules.disko
./hosts/kube01
];
};
kube02 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
inherit inputs outputs;
};
modules = [
disko.nixosModules.disko
./hosts/kube02
];
};
kube03 = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";
specialArgs = {
inherit inputs outputs;
};
modules = [
disko.nixosModules.disko
./hosts/kube03
];
};
};
};
}

41
hosts/kube01/default.nix Normal file
View file

@ -0,0 +1,41 @@
{ inputs, outputs, config, lib, pkgs, ... }:
{
imports =
[
../../modules/disko/efi-full-btrfs.nix
../../modules/systemd-boot.nix
../../users/julius/nixos-server.nix
../../modules/nix.nix
../../modules/network-server.nix
../../modules/locale.nix
../../modules/server-cli.nix
../../modules/sshd.nix
../../modules/k3s.nix
../../modules/qemu-guest.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];
networking.hostName = "kube01"; # Define your hostname.
services.k3s = {
clusterInit = true;
};
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "25.05"; # Did you read the comment?
}

View file

@ -0,0 +1,24 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

41
hosts/kube02/default.nix Normal file
View file

@ -0,0 +1,41 @@
{ inputs, outputs, config, lib, pkgs, ... }:
{
imports =
[
../../modules/disko/efi-full-btrfs.nix
../../modules/systemd-boot.nix
../../users/julius/nixos-server.nix
../../modules/nix.nix
../../modules/network-server.nix
../../modules/locale.nix
../../modules/server-cli.nix
../../modules/sshd.nix
../../modules/k3s.nix
../../modules/qemu-guest.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];
networking.hostName = "kube02"; # Define your hostname.
services.k3s = {
serverAddr = "https://kube01:6443";
clusterInit = false;
};
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "25.05"; # Did you read the comment?
}

View file

@ -0,0 +1,24 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

42
hosts/kube03/default.nix Normal file
View file

@ -0,0 +1,42 @@
{ inputs, outputs, config, lib, pkgs, ... }:
{
imports =
[
../../modules/disko/efi-full-btrfs.nix
../../modules/systemd-boot.nix
../../users/julius/nixos-server.nix
../../modules/nix.nix
../../modules/network-server.nix
../../modules/locale.nix
../../modules/server-cli.nix
../../modules/sshd.nix
../../modules/k3s.nix
../../modules/qemu-guest.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];
networking.hostName = "kube03"; # Define your hostname.
services.k3s = {
serverAddr = "https://kube01:6443";
clusterInit = false;
};
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "25.05"; # Did you read the comment?
}

View file

@ -0,0 +1,24 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

View file

@ -34,6 +34,15 @@
};
};
nix.settings = {
substituters = [
"https://cache.saumon.network/proxmox-nixos"
];
trusted-public-keys = [
"proxmox-nixos:D9RYSWpQQC/msZUWphOY2I5RLH5Dd6yQcaHIuug7dWM="
];
};
services.proxmox-ve = {
enable = true;
ipAddress = "192.168.122.71";

View file

@ -0,0 +1,37 @@
{ inputs, outputs, config, lib, pkgs, ... }:
{
imports =
[
../../modules/disko/efi-full-btrfs.nix
../../modules/systemd-boot.nix
../../users/julius/nixos-server.nix
../../modules/nix.nix
../../modules/network-server.nix
../../modules/locale.nix
../../modules/server-cli.nix
../../modules/sshd.nix
../../modules/qemu-guest.nix
../../modules/docker.nix
# Include the results of the hardware scan.
./hardware-configuration.nix
];
networking.hostName = "srv01-hf"; # Define your hostname.
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "25.05"; # Did you read the comment?
}

View file

@ -0,0 +1,24 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "sr_mod" ];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

View file

@ -0,0 +1,56 @@
{
disko.devices = {
disk = {
sda = {
type = "disk";
device = "/dev/sda";
content = {
type = "gpt";
partitions = {
ESP = {
priority = 1;
name = "ESP";
start = "1M";
end = "128M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
root = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # Override existing partition
# Subvolumes must set a mountpoint in order to be mounted,
# unless their parent is mounted
subvolumes = {
# Subvolume name is different from mountpoint
"/rootfs" = {
mountpoint = "/";
};
# Subvolume name is the same as the mountpoint
"/home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
# Sub(sub)volume doesn't need a mountpoint as its parent is mounted
"/home/julius" = { };
# Parent is not mounted so the mountpoint must be set
"/nix" = {
mountOptions = [ "compress=zstd" "noatime" ];
mountpoint = "/nix";
};
};
mountpoint = "/partition-root";
};
};
};
};
};
};
};
}

28
modules/k3s.nix Normal file
View file

@ -0,0 +1,28 @@
{
pkgs,
lib,
...
}: {
services.k3s = {
enable = true;
role = "server";
token = "verysecrettoken";
extraFlags = toString ([
"--write-kubeconfig-mode \"0644\""
"--disable servicelb"
"--disable traefik"
"--disable local-storage"
]);
};
networking.firewall.allowedTCPPorts = [
6443
2379
2380
];
networking.firewall.allowedUDPPorts = [
8472
];
}

7
modules/qemu-guest.nix Normal file
View file

@ -0,0 +1,7 @@
{
...
}: {
services.qemuGuest.enable = true;
}

15
modules/systemd-boot.nix Normal file
View file

@ -0,0 +1,15 @@
{
...
}: {
boot = {
loader = {
systemd-boot = {
enable = true;
};
efi.canTouchEfiVariables = true;
};
tmp.useTmpfs = true;
};
}

View file

@ -0,0 +1,23 @@
{
...
}: {
users = {
users = {
julius = {
initialPassword = "password";
isNormalUser = true;
uid = 1000;
group = "julius";
extraGroups = [ "wheel" ];
};
};
groups = {
julius = {
gid = 1000;
};
};
};
nix.settings.trusted-users = [ "julius" ];
}