summary refs log tree commit diff
path: root/modules/foundation/services/utils.nix
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2025-08-31 17:24:03 +0200
committerMel <mel@rnrd.eu>2025-08-31 17:24:03 +0200
commitfcbc0446f11b8555c1204081c23fbd1442534aa0 (patch)
tree4479bef5a2bd80987add6c34440fee4ba894abed /modules/foundation/services/utils.nix
parent72ed2e170f32698f8a8596532c1d7655591267c3 (diff)
downloadnetwork-fcbc0446f11b8555c1204081c23fbd1442534aa0.tar.zst
network-fcbc0446f11b8555c1204081c23fbd1442534aa0.zip
Clean up & integrate service network configuration into foundation module
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'modules/foundation/services/utils.nix')
-rw-r--r--modules/foundation/services/utils.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/foundation/services/utils.nix b/modules/foundation/services/utils.nix
new file mode 100644
index 0000000..c7bbcf7
--- /dev/null
+++ b/modules/foundation/services/utils.nix
@@ -0,0 +1,29 @@
+{ ... }:
+
+{
+  naming = {
+    networkService = name: "docker-${name}-network";
+
+    groupTarget = group: "docker-${group}-group-root";
+
+    serviceService = fullName: "docker-${fullName}";
+
+    service =
+      {
+        group,
+        name,
+        full ? false,
+      }:
+      let
+        isGroup = group != "";
+        isDefault = name == "default" || name == group;
+
+        shortName = if isGroup && isDefault then group else name;
+
+        fullName = if isGroup then (if isDefault then group else "${group}-${name}") else name;
+      in
+      assert name != "";
+      assert isDefault -> isGroup;
+      if full then fullName else shortName;
+  };
+}