-
-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: ckie <[email protected]> Signed-off-by: h7x4 <[email protected]>
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ lib, formats, stdenvNoCC, ... }: | ||
let | ||
libconfig = formats.libconfig { }; | ||
|
||
include_expr = { | ||
val = 1; | ||
}; | ||
|
||
include_file = libconfig.generate "libconfig-test-include" include_expr; | ||
|
||
expression = { | ||
simple_top_level_attr = "1.0"; | ||
nested.attrset.has.a.integer.value = 100; | ||
some_floaty = 29.95; | ||
## Same syntax here on these two, but they should get serialized differently: | ||
# > A list may have zero or more elements, each of which can be a scalar value, an array, a group, or another list. | ||
list1d = libconfig.lib.mkList [ 1 "mixed!" 5 2 ]; | ||
# You might also omit the mkList, as a list will be a list (in contrast to an array) by default. | ||
list2d = [ 1 [ 1 1.2 "foo" ] [ "bar" 1.2 1 ] ]; | ||
# > An array may have zero or more elements, but the elements must all be scalar values of the same type. | ||
array1d = libconfig.lib.mkArray [ 1 5 2 ]; | ||
array2d = [ | ||
(libconfig.lib.mkArray [ 1 2 ]) | ||
(libconfig.lib.mkArray [ 2 1 ]) | ||
]; | ||
nasty_string = "\"\n\\\t\r^*\b\f\n\0\";'''$"; | ||
|
||
weirderTypes = { | ||
_includes = [ include_file ]; | ||
pi = 3.141592654; | ||
bigint = 9223372036854775807; | ||
hex = libconfig.lib.mkHex "0x1FC3"; | ||
octal = libconfig.lib.mkOctal "0027"; | ||
float = libconfig.lib.mkFloat "1.2E-3"; | ||
array_of_ints = libconfig.lib.mkArray [ | ||
(libconfig.lib.mkOctal "0732") | ||
(libconfig.lib.mkHex "0xA3") | ||
1234 | ||
]; | ||
list_of_weird_types = [ | ||
3.141592654 | ||
9223372036854775807 | ||
(libconfig.lib.mkHex "0x1FC3") | ||
(libconfig.lib.mkOctal "0027") | ||
(libconfig.lib.mkFloat "1.2E-32") | ||
]; | ||
}; | ||
}; | ||
in | ||
libconfig.generate "libconfig-test.cfg" expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ pkgs, ... }: | ||
{ | ||
comprehensive = pkgs.callPackage ./comprehensive.nix { }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters