refactor(dotfiles): clarify registry validation #126
@@ -110,6 +110,8 @@
|
|||||||
Use `git -C <repository-root>` or top-anchored pathspecs for repository-wide history searches.
|
Use `git -C <repository-root>` or top-anchored pathspecs for repository-wide history searches.
|
||||||
- A `**/*.nix` Git pathspec does not include Nix files directly in its starting directory.
|
- A `**/*.nix` Git pathspec does not include Nix files directly in its starting directory.
|
||||||
Include both `*.nix` and `**/*.nix`, or use a recursive `*.nix` pathspec, when linting every Nix file.
|
Include both `*.nix` and `**/*.nix`, or use a recursive `*.nix` pathspec, when linting every Nix file.
|
||||||
|
- Nix `let` bindings are recursive; their source order does not determine binding availability.
|
||||||
|
Treat Natu `let_order` as a readability rule, not an evaluation dependency.
|
||||||
- Ariadne extraction must preserve the game-root season prefix for archived source.
|
- Ariadne extraction must preserve the game-root season prefix for archived source.
|
||||||
Different game installs can contain compiled scripts with the same internal path.
|
Different game installs can contain compiled scripts with the same internal path.
|
||||||
- Clew owns Ren'Py extraction, preparation, and compiled-script AST export. Ariadne owns analysis over Clew-produced data.
|
- Clew owns Ren'Py extraction, preparation, and compiled-script AST export. Ariadne owns analysis over Clew-produced data.
|
||||||
|
|||||||
@@ -19,14 +19,12 @@ let
|
|||||||
];
|
];
|
||||||
}).config;
|
}).config;
|
||||||
|
|
||||||
data = validate (
|
validation = import ./registry/validation.nix { inherit data definitions lib; };
|
||||||
lib.mapAttrs (
|
|
||||||
|
data = lib.mapAttrs (
|
||||||
registryName: _registry:
|
registryName: _registry:
|
||||||
lib.mapAttrs (hostName: host: host.config.registry.${registryName}.${hostName} or { }) hosts
|
lib.mapAttrs (hostName: host: host.config.registry.${registryName}.${hostName} or { }) hosts
|
||||||
) definitions
|
) definitions;
|
||||||
);
|
|
||||||
|
|
||||||
validate = import ./registry/validation.nix { inherit definitions lib; };
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
types = lib.mapAttrs (_name: definition: definition.type) definitions;
|
types = lib.mapAttrs (_name: definition: definition.type) definitions;
|
||||||
@@ -45,7 +43,10 @@ in
|
|||||||
) definitions;
|
) definitions;
|
||||||
};
|
};
|
||||||
|
|
||||||
collected = data // {
|
collected =
|
||||||
|
assert validation;
|
||||||
|
data
|
||||||
|
// {
|
||||||
join =
|
join =
|
||||||
host: entry:
|
host: entry:
|
||||||
lib.filterAttrs (_name: value: value != null) (
|
lib.filterAttrs (_name: value: value != null) (
|
||||||
|
|||||||
@@ -1,41 +1,34 @@
|
|||||||
{
|
{
|
||||||
|
data,
|
||||||
definitions,
|
definitions,
|
||||||
lib,
|
lib,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
validationAssertions =
|
checkResults = lib.concatLists (
|
||||||
data:
|
|
||||||
lib.concatLists (
|
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (
|
||||||
registryName: registry:
|
registryName: definition:
|
||||||
let
|
|
||||||
entries = flattenRegistryEntries registryName data.${registryName};
|
|
||||||
in
|
|
||||||
map (check: {
|
map (check: {
|
||||||
assertion = check.assertion entries;
|
assertion = check.assertion (entriesForRegistry registryName);
|
||||||
inherit (check) message;
|
inherit (check) message;
|
||||||
}) registry.checks
|
}) definition.checks
|
||||||
) definitions
|
) definitions
|
||||||
);
|
);
|
||||||
|
|
||||||
flattenRegistryEntries =
|
entriesForRegistry =
|
||||||
registryName: data:
|
registryName:
|
||||||
lib.concatLists (
|
lib.concatLists (
|
||||||
lib.mapAttrsToList (
|
lib.mapAttrsToList (host: entries: entriesForHost registryName host entries) data.${registryName}
|
||||||
host: entries:
|
);
|
||||||
|
|
||||||
|
entriesForHost =
|
||||||
|
registryName: host: entries:
|
||||||
lib.mapAttrsToList (entry: value: {
|
lib.mapAttrsToList (entry: value: {
|
||||||
path = "registry.${registryName}.${host}.${entry}";
|
path = "registry.${registryName}.${host}.${entry}";
|
||||||
inherit host entry value;
|
inherit host entry value;
|
||||||
}) entries
|
}) entries;
|
||||||
) data
|
|
||||||
);
|
failures = lib.filter (result: !result.assertion) checkResults;
|
||||||
in
|
in
|
||||||
data:
|
lib.assertMsg (lib.all (result: result.assertion) checkResults) (
|
||||||
let
|
lib.concatMapStringsSep "\n" (result: result.message) failures
|
||||||
assertions = validationAssertions data;
|
)
|
||||||
failures = lib.filter (assertion: !assertion.assertion) assertions;
|
|
||||||
in
|
|
||||||
assert lib.assertMsg (lib.all (assertion: assertion.assertion) assertions) (
|
|
||||||
lib.concatMapStringsSep "\n" (assertion: assertion.message) failures
|
|
||||||
);
|
|
||||||
data
|
|
||||||
|
|||||||
Reference in New Issue
Block a user