From 53208759dbfafc2909c93ccaace32b5b8951abad Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 8 Dec 2024 17:51:38 +0100 Subject: Allow passing in single symmetrical port to foundation service module Signed-off-by: Mel --- modules/foundation/services.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/foundation/services.nix b/modules/foundation/services.nix index ddc3263..5acb0c6 100644 --- a/modules/foundation/services.nix +++ b/modules/foundation/services.nix @@ -28,7 +28,7 @@ let ports = mkOption { type = with types; listOf ( - either (listOf ints.u16) str + oneOf [(listOf port) str port] ); default = [ ]; }; @@ -134,15 +134,17 @@ in virtualisation.oci-containers.containers = let mkOciPort = - portStrOrTuple: - if builtins.isList portStrOrTuple then + portSetting: + if builtins.isList portSetting then let - host = builtins.elemAt portStrOrTuple 0; - container = builtins.elemAt portStrOrTuple 1; + host = builtins.elemAt portSetting 0; + container = builtins.elemAt portSetting 1; in "127.0.0.1:${toString host}:${toString container}" + else if builtins.isInt portSetting then + "127.0.0.1:${toString portSetting}:${toString portSetting}" else - portStrOrTuple; + portSetting; mkOciVolume = volumeTuple: -- cgit 1.4.1