2022-12-28 22:39:05 +00:00
{ lib , options , . . . }:
2024-07-12 01:20:47 +00:00
let
discardPositions = lib . mapAttrs ( k : v : v ) ;
2022-12-28 22:39:05 +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-07-12 01:20:47 +00:00
assert
builtins . unsafeGetAttrPos " a " ( discardPositions {
a = true ;
} ) == null ;
2022-12-28 22:39:05 +00:00
{
imports = [
{
2024-07-12 01:20:47 +00:00
options . imported . line14 = lib . mkOption {
2022-12-28 22:39:05 +00:00
type = lib . types . int ;
} ;
# 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.
options . generated = discardPositions {
2024-07-12 01:20:47 +00:00
line22 = lib . mkOption {
2022-12-28 22:39:05 +00:00
type = lib . types . int ;
} ;
} ;
2024-07-12 01:20:47 +00:00
options . submoduleLine38 . extraOptLine27 = lib . mkOption {
2022-12-28 22:39:05 +00:00
default = 1 ;
type = lib . types . int ;
} ;
}
] ;
2024-07-12 01:20:47 +00:00
options . nested . nestedLine34 = lib . mkOption {
2022-12-28 22:39:05 +00:00
type = lib . types . int ;
} ;
2024-07-12 01:20:47 +00:00
options . submoduleLine38 = lib . mkOption {
2022-12-28 22:39:05 +00:00
default = { } ;
type = lib . types . submoduleWith {
modules = [
2024-07-12 01:20:47 +00:00
(
{ options , . . . }:
{
options . submodDeclLine45 = lib . mkOption { } ;
}
)
2022-12-28 22:39:05 +00:00
{ freeformType = with lib . types ; lazyAttrsOf ( uniq unspecified ) ; }
] ;
} ;
} ;
config = {
2024-07-12 01:20:47 +00:00
submoduleLine38 . submodDeclLine45 =
( options . submoduleLine38 . type . getSubOptions [ ] ) . submodDeclLine45 . declarationPositions ;
2022-12-28 22:39:05 +00:00
} ;
}