mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-23 21:57:52 +03:00
Merge pull request #167162 from hercules-ci/formats-javaProperties-fixups
Inline docs for javaProperties and formats test runner
This commit is contained in:
commit
d990baa309
@ -1,6 +1,30 @@
|
|||||||
{ lib, pkgs }:
|
{ lib, pkgs }:
|
||||||
{
|
{
|
||||||
javaProperties = { comment ? "Generated with Nix" }: {
|
javaProperties = { comment ? "Generated with Nix" }: {
|
||||||
|
|
||||||
|
# Design note:
|
||||||
|
# A nested representation of inevitably leads to bad UX:
|
||||||
|
# 1. keys like "a.b" must be disallowed, or
|
||||||
|
# the addition of options in a freeformType module
|
||||||
|
# become breaking changes
|
||||||
|
# 2. adding a value for "a" after "a"."b" was already
|
||||||
|
# defined leads to a somewhat hard to understand
|
||||||
|
# Nix error, because that's not something you can
|
||||||
|
# do with attrset syntax. Workaround: "a"."", but
|
||||||
|
# that's too little too late. Another workaround:
|
||||||
|
# mkMerge [ { a = ...; } { a.b = ...; } ].
|
||||||
|
#
|
||||||
|
# Choosing a non-nested representation does mean that
|
||||||
|
# we sacrifice the ability to override at the (conceptual)
|
||||||
|
# hierarchical levels, _if_ an application exhibits those.
|
||||||
|
#
|
||||||
|
# Some apps just use periods instead of spaces in an odd
|
||||||
|
# mix of attempted categorization and natural language,
|
||||||
|
# with no meaningful hierarchy.
|
||||||
|
#
|
||||||
|
# We _can_ choose to support hierarchical config files
|
||||||
|
# via nested attrsets, but the module author should
|
||||||
|
# make sure that problem (2) does not occur.
|
||||||
type = lib.types.attrsOf lib.types.str;
|
type = lib.types.attrsOf lib.types.str;
|
||||||
|
|
||||||
generate = name: value:
|
generate = name: value:
|
||||||
|
@ -9,7 +9,11 @@ let
|
|||||||
let
|
let
|
||||||
formatSet = format args;
|
formatSet = format args;
|
||||||
config = formatSet.type.merge [] (imap1 (n: def: {
|
config = formatSet.type.merge [] (imap1 (n: def: {
|
||||||
value = def;
|
# We check the input values, so that
|
||||||
|
# - we don't write nonsensical tests that will impede progress
|
||||||
|
# - the test author has a slightly more realistic view of the
|
||||||
|
# final format during development.
|
||||||
|
value = lib.throwIfNot (formatSet.type.check def) (builtins.trace def "definition does not pass the type's check function") def;
|
||||||
file = "def${toString n}";
|
file = "def${toString n}";
|
||||||
}) [ def ]);
|
}) [ def ]);
|
||||||
in formatSet.generate "test-format-file" config;
|
in formatSet.generate "test-format-file" config;
|
||||||
|
Loading…
Reference in New Issue
Block a user