diff options
| author | adikro <adikro@disroot.org> | 2026-06-29 00:31:26 +0200 |
|---|---|---|
| committer | adikro <adikro@disroot.org> | 2026-06-29 00:31:26 +0200 |
| commit | 8a820cacee1ff07ae7397d053b26e66f7086a4a4 (patch) | |
| tree | 23153683130799babd4e5ed1a39068c52fa7d588 /os/core | |
| parent | 9b8f9a4bf5e13efe49ec101f127d0df3d7bb3cf3 (diff) | |
Diffstat (limited to 'os/core')
| -rw-r--r-- | os/core/default.nix | 1 | ||||
| -rw-r--r-- | os/core/networking.nix | 25 | ||||
| -rw-r--r-- | os/core/persistance.nix | 50 | ||||
| -rw-r--r-- | os/core/users.nix | 2 | ||||
| -rw-r--r-- | os/core/zfs.nix | 60 |
5 files changed, 125 insertions, 13 deletions
diff --git a/os/core/default.nix b/os/core/default.nix index 1146f2d..963436b 100644 --- a/os/core/default.nix +++ b/os/core/default.nix @@ -17,6 +17,7 @@ in ./security.nix ./storage.nix ./users.nix + ./zfs.nix ]; options.os.core = { diff --git a/os/core/networking.nix b/os/core/networking.nix index b94b540..9e4c329 100644 --- a/os/core/networking.nix +++ b/os/core/networking.nix @@ -20,20 +20,21 @@ in ips = lib.mkOption { type = lib.types.attrsOf lib.types.str; - default = rec { - router = opnsense-vm; - host = "10.0.0.2"; + default = { + bare-metal = "10.0.0.2"; opnsense-vm = "10.0.0.1"; gateway-vm = "10.0.0.3"; - databse-vm = "10.0.0.4"; - monitor-vm = "10.0.0.5"; - media-vm = "10.0.0.6"; - sandbox-vm = "10.0.0.7"; - storage-vm = "10.0.0.8"; - web-vm = "10.0.0.9"; - mail-vm = "10.0.0.10"; - relay-vm = "10.0.0.11"; - gameserver-vm = "10.0.0.12"; + auth-vm = "10.0.0.4"; + database-vm = "10.0.0.5"; + monitor-vm = "10.0.0.6"; + media-vm = "10.0.0.7"; + torrent-vm = "10.0.0.8"; + storage-vm = "10.0.0.9"; + web-vm = "10.0.0.10"; + comm-vm = "10.0.0.11"; + mail-vm = "10.0.0.12"; + relay-vm = "10.0.0.13"; + gameserver-vm = "10.0.0.14"; }; description = "Central registry of static IP allocations for the cluster."; }; diff --git a/os/core/persistance.nix b/os/core/persistance.nix new file mode 100644 index 0000000..89f3702 --- /dev/null +++ b/os/core/persistance.nix @@ -0,0 +1,50 @@ +{ + config, + lib, + inputs, + ... +}: +let + cfg = config.os.srv.persistance; +in +{ + imports = [ inputs.impermanence.nixosModules.impermanence ]; + + options.os.srv.persistance.enable = lib.mkEnableOption "enables persistance drive maintnance"; + config = lib.mkMerge [ + (lib.mkIf cfg.enable { + environment.persistence."/persist" = { + hideMounts = true; + directories = [ + "/var/lib/nixos" + "/var/lib/systemd" + "/var/lib/microvm" + ]; + files = [ + "/etc/machine-id" + ]; + }; + }) + (lib.mkIf (cfg.enable && config.os.srv.ssh.server.enable) { + environment.persistence."/persist" = { + files = [ + "/etc/ssh/ssh_host_ed25519_key" + "/etc/ssh/ssh_host_ed25519_key.pub" + ]; + }; + }) + (lib.mkIf (cfg.enable && config.os.srv.crowdsec.agent.enable) { + environment.persistence."/persist" = lib.mkIf cfg.agent.enable { + hideMounts = true; + directories = [ + { + directory = "/var/lib/crowdsec"; + user = "crowdsec"; + group = "crowdsec"; + mode = "0750"; + } + ]; + }; + }) + ]; +} diff --git a/os/core/users.nix b/os/core/users.nix index 494406b..ff45a99 100644 --- a/os/core/users.nix +++ b/os/core/users.nix @@ -43,7 +43,7 @@ in "render" ]) (lib.mkIf (config.os.core.network.enable or false) [ "networkmanager" ]) - (lib.mkIf (config.os.srv.virtualization.enable or false) [ "libvirtd" ]) + (lib.mkIf (config.os.srv.virtualization.kvm.enable or false) [ "libvirtd" ]) (lib.mkIf (config.os.srv.docker.enable or false) [ "docker" ]) ]; }; diff --git a/os/core/zfs.nix b/os/core/zfs.nix new file mode 100644 index 0000000..771644d --- /dev/null +++ b/os/core/zfs.nix @@ -0,0 +1,60 @@ +{ config, lib, ... }: +let + cfg = config.os.srv.zfs; +in +{ + options.os.srv.zfs.enable = lib.mkEnableOption "enables zfs drive maintnance"; + config = lib.mkIf cfg.enable { + assertions = [ + { + assertion = config.os.core.drivers.kernel == "zfs"; + message = "ZFS requires the zfs supported kernel"; + } + { + assertion = config.os.srv.sops.enable; + message = "required for storing the ntfy token"; + } + ]; + + sops.secrets."ntfy/zed".neededForUsers = false; + + boot = { + kernelParams = [ "zfs.zfs_arc_max=${toString (32 * 1024 * 1024 * 1024)}" ]; + zfs = { + # requestEncryptionCredentials = [ "zroot" ]; + # useKeyringForCredentials = true; + extraPools = [ "tank" ]; + }; + supportedFilesystems = [ "zfs" ]; + initrd.supportedFilesystems = [ "zfs" ]; + }; + services.zfs = { + expandOnBoot = "all"; + autoScrub.enable = true; + trim.enable = true; + autoSnapshot = { + enable = true; + flags = "-k -p --utc"; + }; + zed = { + settings = { + ZED_DEBUG_LOG = "/var/log/zed.debug.log"; + + ZED_NOTIFY_INTERVAL_SECS = 3600; + ZED_NOTIFY_VERBOSE = 0; + + ZED_USE_ENCLOSURE_LEDS = 1; + ZED_SCRUB_AFTER_RESILVER = 1; + ZED_POWER_OFF_ENCLOSURE_SLOT_ON_FAULT = 1; + ZED_POWER_OFF_ENCLOSURE_SLOT_ON_DEADMAN = 1; + + ZED_NTFY_TOPIC = "zed-alerts-bibus-lab"; + ZED_NTFY_URL = "http://${config.os.core.network.ips.monitor-vm}:8085"; + }; + }; + }; + systemd.services.zfs-zed.serviceConfig.EnvironmentFile = config.sops.secrets."ntfy/zed".path; + networking.hostId = "4e3e22e1"; + + }; +} |
