···3535 # In the case that you need this functionality,
3636 # you will have to disable pyhocon validation.
3737 , doCheck ? true
3838- }: {
3939- type = let
4040- type' = with lib.types; let
4141- atomType = nullOr (oneOf [
4242- bool
4343- float
4444- int
4545- path
4646- str
4747- ]);
4848- in (oneOf [
4949- atomType
5050- (listOf atomType)
5151- (attrsOf type')
5252- ]) // {
5353- description = "HOCON value";
5454- };
5555- in type';
5656-5757- lib = {
3838+ }: let
3939+ hoconLib = {
5840 mkInclude = value: let
5941 includeStatement = if lib.isAttrs value && !(lib.isDerivation value) then {
6042 required = false;
···10183 };
10284 };
103858686+ in {
8787+ type = let
8888+ type' = with lib.types; let
8989+ atomType = nullOr (oneOf [
9090+ bool
9191+ float
9292+ int
9393+ path
9494+ str
9595+ ]);
9696+ in (oneOf [
9797+ atomType
9898+ (listOf atomType)
9999+ (attrsOf type')
100100+ ]) // {
101101+ description = "HOCON value";
102102+ };
103103+ in type';
104104+105105+ lib = hoconLib;
106106+104107 generate = name: value:
108108+ let
109109+ # TODO: remove in 24.11
110110+ # Backwards compatability for generators in the following locations:
111111+ # - nixos/modules/services/networking/jibri/default.nix (__hocon_envvar)
112112+ # - nixos/modules/services/networking/jicofo.nix (__hocon_envvar, __hocon_unquoted_string)
113113+ # - nixos/modules/services/networking/jitsi-videobridge.nix (__hocon_envvar)
114114+ replaceOldIndicators = value:
115115+ if lib.isAttrs value then
116116+ (if value ? "__hocon_envvar"
117117+ then
118118+ lib.warn ''
119119+ Use of `__hocon_envvar` has been deprecated, and will
120120+ be removed in the future.
121121+122122+ Please use `(pkgs.formats.hocon {}).lib.mkSubstitution` instead.
123123+ ''
124124+ (hoconLib.mkSubstitution value.__hocon_envvar)
125125+ else if value ? "__hocon_unquoted_string"
126126+ then
127127+ lib.warn ''
128128+ Use of `__hocon_unquoted_string` has been deprecated, and will
129129+ be removed in the future.
130130+131131+ Please make use of the freeform options of
132132+ `(pkgs.formats.hocon {}).format` instead.
133133+ ''
134134+ {
135135+ value = value.__hocon_unquoted_string;
136136+ _type = "unquoted_string";
137137+ }
138138+ else lib.mapAttrs (_: replaceOldIndicators) value)
139139+ else if lib.isList value
140140+ then map replaceOldIndicators value
141141+ else value;
142142+143143+ finalValue = replaceOldIndicators value;
144144+ in
105145 callPackage
106146 ({
107147 stdenvNoCC
···114154115155 dontUnpack = true;
116156117117- json = builtins.toJSON value;
157157+ json = builtins.toJSON finalValue;
118158 passAsFile = [ "json" ];
119159120160 strictDeps = true;
+11
pkgs/pkgs-lib/formats/hocon/src/src/main.rs
···1010 List(Vec<HOCONValue>),
1111 Substitution(String, bool),
1212 Object(Vec<HOCONInclude>, Vec<(String, HOCONValue)>),
1313+ Literal(String),
1314}
14151516#[derive(Debug)]
···9192 let value = o.get("value").expect("Missing value for append");
92939394 HOCONValue::Append(Box::new(json_to_hocon(value)))
9595+ }
9696+ "unquoted_string" => {
9797+ let value = o
9898+ .get("value")
9999+ .expect("Missing value for unquoted_string")
100100+ .as_str()
101101+ .unwrap_or_else(|| panic!("Unquoted string value is not a string: {:?}", o));
102102+103103+ HOCONValue::Literal(value.to_string())
94104 }
95105 _ => panic!(
96106 "\
···210220 format!("{{\n{}\n}}", content)
211221 }
212222 HOCONValue::Append(_) => panic!("Append should not be present at this point"),
223223+ Self::Literal(s) => s.to_string(),
213224 }
214225 }
215226}