basic generation

This commit is contained in:
Primrose 2025-06-22 18:24:41 +02:00
parent c725b27c97
commit f2cdc96007
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
3 changed files with 203226 additions and 1 deletions

194513
asList.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
{sources ? import ./nix/sources.nix}: {
{sources ? import ./nix/sources.nix}: rec {
lib = import (sources.nixpkgs + "/lib");
nixosConfigurations = builtins.mapAttrs (_: import (sources.nixpkgs + "/nixos/lib/eval-config.nix")) {
@ -16,5 +16,67 @@
};
};
inherit (nixosConfigurations.vanadium) options;
/*
Idea:
We only have filepath based information on where an option is set.
The oniginal goal was to be able to tell by flipping on which option, which other option(s) will be impacted.
This is hence not possible because not all options are guarded by a `enable` option, for example.
We could draw out file -> option, and cluster each option in a file rectangle
*/
# Drop those that fail to eval
filtered = let
drop = path: {
inherit path;
update = _: {};
};
in
lib.updateManyAttrsByPath
(map drop [
["_module"]
["services" "immich"] # caused by option referencing a config value
["services" "nagios"]
["hardware" "nvidia"]
])
options;
# Transform each option to its path and call site
mapped =
lib.mapAttrsRecursiveCond
(as: !(as ? _type && as._type == "option"))
(
_: v: let
definedBy = builtins.tryEval (map (x: x.file) v.definitionsWithLocations);
in
lib.optionalAttrs definedBy.success {
_type = "result";
optionPath = v.loc;
definedBy = definedBy.value;
declaredAt = map (x: x.file) v.declarationPositions;
}
)
filtered;
attrValuesRecursiveCond = cond: attrs:
if lib.isAttrs attrs && cond attrs
then
lib.flatten (
map (attrValuesRecursiveCond cond) (builtins.attrValues attrs)
)
else [attrs];
# Run `nix eval --json -f ./. 'asList' | jq >asList.json` to generate
asList = let
untag = map (lib.flip lib.removeAttrs ["_type"]);
in
untag (
attrValuesRecursiveCond
(as: !(as ? _type && as._type == "result"))
mapped
);
packages = import ./nix/packages {inherit sources;};
}

8650
output.json Normal file

File diff suppressed because it is too large Load diff