From 10dbccae97ed1e1ed0cd336b69876fc23c19c6fb Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 6 Jan 2024 21:45:18 +0100 Subject: [PATCH] create top-level switch whether a machine holds the application data --- nixos/machines/default.nix | 4 +--- nixos/modules/default.nix | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/nixos/machines/default.nix b/nixos/machines/default.nix index c161060..572f87f 100644 --- a/nixos/machines/default.nix +++ b/nixos/machines/default.nix @@ -38,9 +38,7 @@ nixosModule.lab = { disko.osDiskDevice = "/dev/sda"; - backups.enable = true; - networking.allowDMZConnectivity = true; - data-sharing.enable = true; + dataHost.enable = true; dataDisk = { enable = true; diff --git a/nixos/modules/default.nix b/nixos/modules/default.nix index 5762b09..dbd248e 100644 --- a/nixos/modules/default.nix +++ b/nixos/modules/default.nix @@ -1,3 +1,7 @@ +{ lib, config, ... }: + +let cfg = config.lab.dataHost; +in { imports = [ ./terraform-database @@ -9,4 +13,20 @@ ./networking.nix ./data-sharing.nix ]; + + options.lab.dataHost.enable = lib.mkOption { + default = false; + type = lib.types.bool; + description = '' + Whether this machine holds application data. + This enables NFS and PostgreSQL to serve this data, and sets up backups. + Also enables networking on the DMZ to enable serving data. + ''; + }; + + config.lab = lib.mkIf cfg.enable { + backups.enable = true; + data-sharing.enable = true; + networking.allowDMZConnectivity = true; + }; }