You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parsing type strings is hacky and we can do better for all types. For this issue, we will update lib.nix to extract the type, and update types.py to handle type checking without parsing.
Simple case
nix-instantiate --eval '<nixpkgs/nixos>' --arg configuration '{}' -A "options.sound.enable.type.name"
"bool"
The above PRs author suggests we can break down each component of a type so it's more specific than YAML (AnythingType):
nix-instantiate --eval '<nixpkgs/nixos>' --arg configuration '{}' -A "options.services.zrepl.settings.type.nestedTypes.freeformType.nestedTypes.elemType.nestedTypes.left.nestedTypes.left.nestedTypes.left.nestedTypes.left.nestedTypes.left.name"
"bool"
Submodules
Get submodule structure in cases where <name> and * don't exist
Some options, for example system.userActivationScripts, system.activationScripts, services.certmgr.specs, programs.firejail.wrappedBinaries have the types AttrsOf(Submodule) or ListOf(Submodule), however there isn't system.userActivationScripts."<name>".options in the option tree.
Additionally, some options are simply submodules whose structure isn't discoverable through the option tree.
pkgs.nixosOptionsDoc is insufficient to get data about all submodules, however matrix user sternenseemann has suggested:
(builtins.head ((nixos {}).options.system.userActivationScripts.type.nestedTypes.elemType.nestedTypes.right.getSubModules)) which gives us details about the structure of submodules.
Types with Checks
Types that have checks (e.g. time.timezone is "null or string without spaces"):
nix-instantiate --eval '<nixpkgs/nixos>' --arg configuration '{}' -A "options.time.timeZone.type.name"
"nullOr"
nix-instantiate --eval '<nixpkgs/nixos>' --arg configuration '{}' -A "options.time.timeZone.type.nestedTypes.elemType.name"
"str"
nix-instantiate --eval '<nixpkgs/nixos>' --arg configuration '{}' -A "options.time.timeZone.type.nestedTypes.elemType.check"
<LAMBDA>
# We can execute the typecheck as follows
nix-instantiate --eval -E 'let nixos = (import <nixpkgs/nixos> {configuration={};}); in nixos.options.time.timeZone.type.nestedTypes.elemType.check "foo"'
true
nix-instantiate --eval -E 'let nixos = (import <nixpkgs/nixos> {configuration={};}); in nixos.options.time.timeZone.type.nestedTypes.elemType.check "foo bar"'
false
The text was updated successfully, but these errors were encountered:
#187 (comment)
Parsing type strings is hacky and we can do better for all types. For this issue, we will update
lib.nix
to extract the type, and updatetypes.py
to handle type checking without parsing.Simple case
A complex YAML type example
NixOS/nixpkgs#99132
The above PRs author suggests we can break down each component of a type so it's more specific than YAML (
AnythingType
):Submodules
Get submodule structure in cases where
<name>
and*
don't existSome options, for example
system.userActivationScripts
,system.activationScripts
,services.certmgr.specs
,programs.firejail.wrappedBinaries
have the typesAttrsOf(Submodule)
orListOf(Submodule)
, however there isn'tsystem.userActivationScripts."<name>".options
in the option tree.Additionally, some options are simply submodules whose structure isn't discoverable through the option tree.
pkgs.nixosOptionsDoc
is insufficient to get data about all submodules, however matrix usersternenseemann
has suggested:(builtins.head ((nixos {}).options.system.userActivationScripts.type.nestedTypes.elemType.nestedTypes.right.getSubModules))
which gives us details about the structure of submodules.Types with Checks
Types that have checks (e.g.
time.timezone
is "null or string without spaces"):The text was updated successfully, but these errors were encountered: