From 753240353cdafc8f409255e4c81896a9c723fe5d Mon Sep 17 00:00:00 2001 From: dawn Date: Tue, 30 Jun 2026 01:32:40 +0300 Subject: [PATCH] nix/microvm: lookup packages by attr path Signed-off-by: dawn --- nix/microvm/user-config.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nix/microvm/user-config.nix b/nix/microvm/user-config.nix index ae5cceee..1a566741 100644 --- a/nix/microvm/user-config.nix +++ b/nix/microvm/user-config.nix @@ -44,10 +44,19 @@ system = pkgs.stdenv.hostPlatform.system; flake = getFlake flakeRef; notFound = throw "Package ${pkgName} not found in ${flakeRef}"; + # pkgName may be dotted (e.g. "python3Packages.requests"), so walk the + # attr path rather than doing a single dotted-string lookup + pkgPath = lib.splitString "." pkgName; + inPackages = ["packages" system] ++ pkgPath; + inLegacy = ["legacyPackages" system] ++ pkgPath; in if flakeRef == "nixpkgs" && !(registry ? nixpkgs) - then pkgs.${pkgName} or notFound - else flake.legacyPackages.${system}.${pkgName} or flake.packages.${system}.${pkgName} or notFound; + then lib.attrByPath pkgPath notFound pkgs + else if lib.hasAttrByPath inLegacy flake + then lib.getAttrFromPath inLegacy flake + else if lib.hasAttrByPath inPackages flake + then lib.getAttrFromPath inPackages flake + else notFound; # strings are resolved as package references only where the option type # actually expects packages; everything else passes through untouched -- 2.51.2