···4444 system = pkgs.stdenv.hostPlatform.system;
4545 flake = getFlake flakeRef;
4646 notFound = throw "Package ${pkgName} not found in ${flakeRef}";
4747+ # pkgName may be dotted (e.g. "python3Packages.requests"), so walk the
4848+ # attr path rather than doing a single dotted-string lookup
4949+ pkgPath = lib.splitString "." pkgName;
5050+ inPackages = ["packages" system] ++ pkgPath;
5151+ inLegacy = ["legacyPackages" system] ++ pkgPath;
4752 in
4853 if flakeRef == "nixpkgs" && !(registry ? nixpkgs)
4949- then pkgs.${pkgName} or notFound
5050- else flake.legacyPackages.${system}.${pkgName} or flake.packages.${system}.${pkgName} or notFound;
5454+ then lib.attrByPath pkgPath notFound pkgs
5555+ else if lib.hasAttrByPath inLegacy flake
5656+ then lib.getAttrFromPath inLegacy flake
5757+ else if lib.hasAttrByPath inPackages flake
5858+ then lib.getAttrFromPath inPackages flake
5959+ else notFound;
51605261 # strings are resolved as package references only where the option type
5362 # actually expects packages; everything else passes through untouched