2024-05-01 22:14:04 +00:00
{ lib , options , . . . }:
2024-06-30 08:16:52 +00:00
let
discardPositions = lib . mapAttrs ( k : v : v ) ;
2024-05-01 22:14:04 +00:00
in
# unsafeGetAttrPos is unspecified best-effort behavior, so we only want to consider this test on an evaluator that satisfies some basic assumptions about this function.
assert builtins . unsafeGetAttrPos " a " { a = true ; } != null ;
2024-06-30 08:16:52 +00:00
assert
builtins . unsafeGetAttrPos " a " ( discardPositions {
a = true ;
} ) == null ;
2024-05-01 22:14:04 +00:00
{
imports = [
{
2024-06-30 08:16:52 +00:00
options . imported . line10 = lib . mkOption { type = lib . types . int ; } ;
2024-05-01 22:14:04 +00:00
# Simulates various patterns of generating modules such as
# programs.firefox.nativeMessagingHosts.ff2mpv. We don't expect to get
# line numbers for these, but we can fall back on knowing the file.
2024-06-30 08:16:52 +00:00
options . generated = discardPositions { line18 = lib . mkOption { type = lib . types . int ; } ; } ;
2024-05-01 22:14:04 +00:00
options . submoduleLine34 . extraOptLine23 = lib . mkOption {
default = 1 ;
type = lib . types . int ;
} ;
}
] ;
2024-06-30 08:16:52 +00:00
options . nested . nestedLine30 = lib . mkOption { type = lib . types . int ; } ;
2024-05-01 22:14:04 +00:00
options . submoduleLine34 = lib . mkOption {
default = { } ;
type = lib . types . submoduleWith {
modules = [
2024-06-30 08:16:52 +00:00
(
{ options , . . . }:
{
options . submodDeclLine39 = lib . mkOption { } ;
}
)
2024-05-01 22:14:04 +00:00
{ freeformType = with lib . types ; lazyAttrsOf ( uniq unspecified ) ; }
] ;
} ;
} ;
config = {
2024-06-30 08:16:52 +00:00
submoduleLine34 . submodDeclLine39 =
( options . submoduleLine34 . type . getSubOptions [ ] ) . submodDeclLine39 . declarationPositions ;
2024-05-01 22:14:04 +00:00
} ;
}