From 4e14aa4aa4d0475c0f55bd096f6b39ed4f2e9a3e Mon Sep 17 00:00:00 2001 From: Kerstin Humm Date: Tue, 16 Jun 2026 15:38:43 +0200 Subject: [PATCH] pkgs.formats.elixirConf: Allow for Elixir charlists These are needed for defining strings that reach through to Erlang code --- pkgs/pkgs-lib/formats.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/pkgs-lib/formats.nix b/pkgs/pkgs-lib/formats.nix index e6806816d1c8..b9361186a2a6 100644 --- a/pkgs/pkgs-lib/formats.nix +++ b/pkgs/pkgs-lib/formats.nix @@ -607,6 +607,8 @@ optionalAttrs allowAliases aliases elixirMap value else if _elixirType == "tuple" then tuple value + else if _elixirType == "charlist" then + charlist value else abort "formats.elixirConf: should never happen (_elixirType = ${_elixirType})"; @@ -620,6 +622,8 @@ optionalAttrs allowAliases aliases tuple = values: "{${listContent values}}"; + charlist = value: "~c\"${value}\""; + toConf = let keyConfig = @@ -687,6 +691,12 @@ optionalAttrs allowAliases aliases _elixirType = "atom"; }; + # Make an Elixir charlist out of a string. + mkCharlist = value: { + inherit value; + _elixirType = "charlist"; + }; + # Make an Elixir tuple out of a list. mkTuple = value: { inherit value; @@ -727,6 +737,12 @@ optionalAttrs allowAliases aliases check = isElixirType "atom"; }); + charlist = elixirOr (mkOptionType { + name = "elixirCharlist"; + description = "elixir charlist"; + check = isElixirType "charlist"; + }); + tuple = elixirOr (mkOptionType { name = "elixirTuple"; description = "elixir tuple";