From f34f2e45abd768d82c907ae48b31228185e9a207 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicolas=20=E2=80=9CNiols=E2=80=9D=20Jeannerod?=
 <nicolas.jeannerod@moduscreate.com>
Date: Thu, 27 Feb 2025 11:43:44 +0100
Subject: [PATCH] Get panel config as a block - use eg. `mastodon.enable`

---
 deployment/default.nix                 | 27 ++++++++++++--------------
 infra/test-machines/configuration.json |  6 +++---
 2 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/deployment/default.nix b/deployment/default.nix
index 370c2dd..7c7d89c 100644
--- a/deployment/default.nix
+++ b/deployment/default.nix
@@ -30,13 +30,10 @@
 ## partially applied only until here.
 
 ## Information on the specific deployment that we request. This is the
-## information that will come from the FediPanel.
-{
-  domain,
-  enableMastodon,
-  enablePeertube,
-  enablePixelfed,
-}:
+## information coming from the FediPanel.
+##
+## FIXME: lock step the interface with the definitions in the FediPanel
+panelConfig:
 
 let
   inherit (lib) mkMerge mkIf;
@@ -106,12 +103,12 @@ in
 
     mkMerge [
 
-      (mkIf (enableMastodon || enablePeertube || enablePixelfed) {
+      (mkIf (panelConfig.mastodon.enable || panelConfig.peertube.enable || panelConfig.pixelfed.enable) {
         garage-configuration = makeConfigurationResource garageConfigurationResource (
           { pkgs, ... }:
           {
             fediversity = {
-              inherit domain;
+              inherit (panelConfig) domain;
               garage.enable = true;
               pixelfed = pixelfedS3KeyConfig { inherit pkgs; };
               mastodon = mastodonS3KeyConfig { inherit pkgs; };
@@ -121,12 +118,12 @@ in
         );
       })
 
-      (mkIf enableMastodon {
+      (mkIf panelConfig.mastodon.enable {
         mastodon-configuration = makeConfigurationResource mastodonConfigurationResource (
           { pkgs, ... }:
           {
             fediversity = {
-              inherit domain;
+              inherit (panelConfig) domain;
               mastodon = mastodonS3KeyConfig { inherit pkgs; } // {
                 enable = true;
               };
@@ -137,12 +134,12 @@ in
         );
       })
 
-      (mkIf enablePeertube {
+      (mkIf panelConfig.peertube.enable {
         peertube-configuration = makeConfigurationResource peertubeConfigurationResource (
           { pkgs, ... }:
           {
             fediversity = {
-              inherit domain;
+              inherit (panelConfig) domain;
               peertube = peertubeS3KeyConfig { inherit pkgs; } // {
                 enable = true;
                 ## NOTE: Only ever used for testing anyway.
@@ -155,12 +152,12 @@ in
         );
       })
 
-      (mkIf enablePixelfed {
+      (mkIf panelConfig.pixelfed.enable {
         pixelfed-configuration = makeConfigurationResource pixelfedConfigurationResource (
           { pkgs, ... }:
           {
             fediversity = {
-              inherit domain;
+              inherit (panelConfig) domain;
               pixelfed = pixelfedS3KeyConfig { inherit pkgs; } // {
                 enable = true;
               };
diff --git a/infra/test-machines/configuration.json b/infra/test-machines/configuration.json
index 3b2cc6d..133b7a7 100644
--- a/infra/test-machines/configuration.json
+++ b/infra/test-machines/configuration.json
@@ -1,6 +1,6 @@
 {
   "domain": "abundos.eu",
-  "enableMastodon": false,
-  "enablePeertube": false,
-  "enablePixelfed": false
+  "mastodon": { "enable": false },
+  "peertube": { "enable": false },
+  "pixelfed": { "enable": false }
 }