Minimal reproducible example:
a.nix
{ lib, ...}:
{
imports = lib.singleton (lib.mkAliasOptionModule [ "b" ] [ "a" ]);
options.a = lib.mkEnableOption "test";
}
b.nix
{
b = true;
}
flake.nix
{
outputs =
{ nixpkgs, ... }:
nixpkgs.lib.evalModules {
modules = [ ./a.nix ./b.nix ];
};
}
If I inspect definition of option b, then its location is correctly set to b.nix file.
$ nix eval .#options.b.definitionsWithLocations
[ { file = "<nix store path>/b.nix"; value = true; } ]
But if I inspect definition of option a, then its location is set to a.nix, i.e., where lib.mkAliasOptionModule is imported.
$ nix eval .#options.a.definitionsWithLocations
[ { file = "<nix store path>/a.nix"; value = true; } ]
I suspect this issue is caused by mkAliasAndWrapDefsWithPriority naively copy definition in from option to to option without preserving location: https://github.com/NixOS/nixpkgs/blob/358822e453ecb2bf19c0455dddb9a0dbf09e9926/lib/modules.nix#L1583.
Is it possible to fix this issue or this is limitation of lib.mkAlias/RenamedOptionModule?