feat: add hetzner cloud config

Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
This commit is contained in:
Lander Van den Bulcke 2025-01-11 17:13:25 +01:00
parent ee92050e5a
commit 0a1b2e1b3c
Signed by: lander
GPG key ID: 0142722B4B0C536F
4 changed files with 159 additions and 0 deletions

64
hosts/cloud-1/default.nix Normal file
View file

@ -0,0 +1,64 @@
{ inputs, pkgs, ... }:
{
imports = [
inputs.disko.nixosModules.disko
./disk-config.nix
{
_module.args.disks = [ "/dev/sda" ];
}
./hetzner.nix
];
time.timeZone = "Europe/Helsinki";
networking.hostName = "cloud-1";
programs.zsh.enable = true;
environment.pathsToLink = [ "/share/zsh" ];
environment.shells = [ pkgs.zsh ];
environment.enableAllTerminfo = true;
users.users.lander = {
isNormalUser = true;
shell = pkgs.zsh;
extraGroups = [
"wheel"
];
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnthKtz0fE4yQ/X10cJgKVCjYCNkRNoqV28xAhD7h2M cardno:22_498_026"
];
};
nix = {
settings = {
trusted-users = [ "lander" ];
accept-flake-config = true;
auto-optimise-store = true;
};
registry = {
nixpks = {
flake = inputs.nixpkgs;
};
};
nixPath = [
"nixpkgs=${inputs.nixpkgs.outPath}"
"nixos-config=/etc/nixos/configuration.nix"
"/nix/var/nix/profiles/per-user/root/channels"
];
package = pkgs.nixVersions.stable;
extraOptions = ''experimental-features = nix-command flakes'';
gc = {
automatic = true;
options = "--delete-older-than 7d";
};
};
system.stateVersion = "24.11";
}

View file

@ -0,0 +1,52 @@
{
lib,
disks ? [ "/dev/sda" ],
...
}:
{
disko.devices = {
disk = lib.genAttrs disks (disk: {
device = disk;
type = "disk";
content = {
type = "gpt";
partitions = {
boot = {
name = "boot";
size = "256M";
type = "EF00";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
main = {
size = "100%";
content = {
type = "btrfs";
extraArgs = [ "-f" ]; # override existing partition
subvolumes = {
"/" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/";
};
"/home" = {
mountOptions = [ "compress=zstd" ];
mountpoint = "/home";
};
"/nix" = {
mountOptions = [
"compress=zstd"
"noatime"
];
mountpoint = "/nix";
};
};
};
};
};
};
});
};
}

28
hosts/cloud-1/hetzner.nix Normal file
View file

@ -0,0 +1,28 @@
{ modulesPath, ... }:
{
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.loader.grub = {
devices = [ "/dev/sda" ];
efiSupport = true;
efiInstallAsRemovable = true;
};
boot.initrd.kernelModules = [ "virtio_gpu" ];
boot.kernelParams = [ "console=tty" ];
services.openssh = {
enable = true;
settings.PasswordAuthentication = false;
extraConfig = ''
PrintLastLog no
'';
};
users.users.root.openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPnthKtz0fE4yQ/X10cJgKVCjYCNkRNoqV28xAhD7h2M cardno:22_498_026"
];
}