···35 # In the case that you need this functionality,
36 # you will have to disable pyhocon validation.
37 , doCheck ? true
38- }: {
39- type = let
40- type' = with lib.types; let
41- atomType = nullOr (oneOf [
42- bool
43- float
44- int
45- path
46- str
47- ]);
48- in (oneOf [
49- atomType
50- (listOf atomType)
51- (attrsOf type')
52- ]) // {
53- description = "HOCON value";
54- };
55- in type';
56-57- lib = {
58 mkInclude = value: let
59 includeStatement = if lib.isAttrs value && !(lib.isDerivation value) then {
60 required = false;
···101 };
102 };
103000000000000000000000104 generate = name: value:
0000000000000000000000000000000000000105 callPackage
106 ({
107 stdenvNoCC
···114115 dontUnpack = true;
116117- json = builtins.toJSON value;
118 passAsFile = [ "json" ];
119120 strictDeps = true;
···35 # In the case that you need this functionality,
36 # you will have to disable pyhocon validation.
37 , doCheck ? true
38+ }: let
39+ hoconLib = {
00000000000000000040 mkInclude = value: let
41 includeStatement = if lib.isAttrs value && !(lib.isDerivation value) then {
42 required = false;
···83 };
84 };
8586+ in {
87+ type = let
88+ type' = with lib.types; let
89+ atomType = nullOr (oneOf [
90+ bool
91+ float
92+ int
93+ path
94+ str
95+ ]);
96+ in (oneOf [
97+ atomType
98+ (listOf atomType)
99+ (attrsOf type')
100+ ]) // {
101+ description = "HOCON value";
102+ };
103+ in type';
104+105+ lib = hoconLib;
106+107 generate = name: value:
108+ let
109+ # TODO: remove in 24.11
110+ # Backwards compatability for generators in the following locations:
111+ # - nixos/modules/services/networking/jibri/default.nix (__hocon_envvar)
112+ # - nixos/modules/services/networking/jicofo.nix (__hocon_envvar, __hocon_unquoted_string)
113+ # - nixos/modules/services/networking/jitsi-videobridge.nix (__hocon_envvar)
114+ replaceOldIndicators = value:
115+ if lib.isAttrs value then
116+ (if value ? "__hocon_envvar"
117+ then
118+ lib.warn ''
119+ Use of `__hocon_envvar` has been deprecated, and will
120+ be removed in the future.
121+122+ Please use `(pkgs.formats.hocon {}).lib.mkSubstitution` instead.
123+ ''
124+ (hoconLib.mkSubstitution value.__hocon_envvar)
125+ else if value ? "__hocon_unquoted_string"
126+ then
127+ lib.warn ''
128+ Use of `__hocon_unquoted_string` has been deprecated, and will
129+ be removed in the future.
130+131+ Please make use of the freeform options of
132+ `(pkgs.formats.hocon {}).format` instead.
133+ ''
134+ {
135+ value = value.__hocon_unquoted_string;
136+ _type = "unquoted_string";
137+ }
138+ else lib.mapAttrs (_: replaceOldIndicators) value)
139+ else if lib.isList value
140+ then map replaceOldIndicators value
141+ else value;
142+143+ finalValue = replaceOldIndicators value;
144+ in
145 callPackage
146 ({
147 stdenvNoCC
···154155 dontUnpack = true;
156157+ json = builtins.toJSON finalValue;
158 passAsFile = [ "json" ];
159160 strictDeps = true;
+11
pkgs/pkgs-lib/formats/hocon/src/src/main.rs
···10 List(Vec<HOCONValue>),
11 Substitution(String, bool),
12 Object(Vec<HOCONInclude>, Vec<(String, HOCONValue)>),
013}
1415#[derive(Debug)]
···91 let value = o.get("value").expect("Missing value for append");
9293 HOCONValue::Append(Box::new(json_to_hocon(value)))
00000000094 }
95 _ => panic!(
96 "\
···210 format!("{{\n{}\n}}", content)
211 }
212 HOCONValue::Append(_) => panic!("Append should not be present at this point"),
0213 }
214 }
215}
···10 List(Vec<HOCONValue>),
11 Substitution(String, bool),
12 Object(Vec<HOCONInclude>, Vec<(String, HOCONValue)>),
13+ Literal(String),
14}
1516#[derive(Debug)]
···92 let value = o.get("value").expect("Missing value for append");
9394 HOCONValue::Append(Box::new(json_to_hocon(value)))
95+ }
96+ "unquoted_string" => {
97+ let value = o
98+ .get("value")
99+ .expect("Missing value for unquoted_string")
100+ .as_str()
101+ .unwrap_or_else(|| panic!("Unquoted string value is not a string: {:?}", o));
102+103+ HOCONValue::Literal(value.to_string())
104 }
105 _ => panic!(
106 "\
···220 format!("{{\n{}\n}}", content)
221 }
222 HOCONValue::Append(_) => panic!("Append should not be present at this point"),
223+ Self::Literal(s) => s.to_string(),
224 }
225 }
226}