tvl-depot/tvix/serde/examples/foods.nix
Vincent Ambo 4da1e64c03 feat(tvix/serde): add an example application to the project
This shows how people can use tvix_serde to deserialise configuration
structs for their programs from Nix code.

Change-Id: I71bf4e03dce19dddafe67dd729b4e4b10719a739
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7945
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
2023-01-31 13:11:28 +00:00

22 lines
414 B
Nix

# This is content for the `Data` struct, written in intentionally
# convoluted Nix code.
let
mkFlavour = flavour: name: {
inherit name;
value = flavour;
};
tasty = mkFlavour "Tasty";
okay = mkFlavour "Okay";
eww = mkFlavour "Eww";
in
{
name = "exhaustive list of foods";
foods = builtins.listToAttrs [
(tasty "beef")
(okay "tomatoes")
(eww "olives")
(tasty "coffee")
];
}