nixos-config/machines/tank.nix
2024-08-24 14:12:16 +02:00

131 lines
3 KiB
Nix

{ my, pkgs, ... }:
{
imports = [
../secrets/machines/tank.nix
../services/grafana.nix
../services/home-assistant.nix
../services/navidrome.nix
../services/nginx.nix
../services/node-exporter.nix
../services/paperless.nix
../services/postgresql.nix
../services/prometheus.nix
../services/restic-client.nix
../system/baremetal-server.nix
../system/btrfs.nix
../system/ucode-amd.nix
../system/zfs.nix
];
system.stateVersion = "24.05";
boot.blacklistedKernelModules = [ "acpi_cpufreq" ];
boot.kernelParams = [
"amd_pstate=active"
"zfs.zfs_arc_max=34359738368" # 32 GiB
];
boot.initrd = {
availableKernelModules = [ "r8169" ];
luks.devices.nixos-root.device = "/dev/md1";
};
boot.swraid = {
enable = true;
mdadmConf = ''
DEVICE partitions
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.0 name=nixos:0 UUID=dda45d00:e5cfa978:d3db8bd9:7edeeadb
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 name=nixos:1 UUID=a5d36756:621e6063:13479129:2c556705
PROGRAM ${pkgs.toybox}/bin/true
'';
};
fileSystems."/" = {
device = "/dev/mapper/nixos-root";
fsType = "btrfs";
options = [ "subvol=@" "noatime" "discard=async" ];
};
fileSystems."/home" = {
device = "/dev/mapper/nixos-root";
fsType = "btrfs";
options = [ "subvol=@home" "discard=async" ];
};
fileSystems."/nix" = {
device = "/dev/mapper/nixos-root";
fsType = "btrfs";
options = [ "subvol=@nix" "noatime" "discard=async" ];
};
fileSystems."/var/log" = {
device = "/dev/mapper/nixos-root";
fsType = "btrfs";
options = [ "subvol=@log" "noatime" "discard=async" "compress=zstd" ];
};
fileSystems."/boot" = {
device = "/dev/md0";
fsType = "vfat";
};
services.btrfs.autoScrub.fileSystems = [ "/" ];
home-manager.users.christoph = {
home.packages = with pkgs; [ tagutil ];
programs.yt-dlp.enable = true;
programs.zsh.shellAliases.yt-dlp-flac =
"yt-dlp -i -x -f bestaudio --audio-format flac --embed-thumbnail --embed-metadata";
};
powerManagement.cpuFreqGovernor = "powersave";
networking.nat.externalInterface = "enp4s0";
systemd.services.dhcpcd.preStart = ''
echo '${my.machines.tank.duid}' >/var/db/dhcpcd/duid
'';
services.dashboard-icons = {
enable = true;
virtualHost = {
name = my.homelab.fqdn;
location = "/_icons";
};
};
services.filebrowser = {
enable = true;
address = "[::1]";
baseUrl = "/filebrowser";
rootDir = "/tank/bunker";
};
services.homer = {
enable = true;
virtualHost.name = my.homelab.fqdn;
};
services.restic.server = {
enable = true;
dataDir = "/tank/backup";
listenAddress = "[::1]:8000";
appendOnly = true;
};
services.prometheus.exporters = {
smartctl = {
enable = true;
listenAddress = "[::1]";
maxInterval = "5m";
};
zfs = {
enable = true;
listenAddress = "[::1]";
extraFlags = [ "--collector.dataset-snapshot" ];
};
};
}