diff --git a/tests.nix b/tests.nix index dc85ecb..cb053df 100644 --- a/tests.nix +++ b/tests.nix @@ -369,6 +369,21 @@ in expected = npins.nixpkgs.outPath; }; + introspection.test-follow-sub-npins-with-inputs-input-with-source-arg = { + # s: my-lib.inputs.nixpkgs.follows = "with-inputs-dep/nixpkgs" → traverse native inputs + expr = + (with-inputs + { + my-lib = mkSrc ./fixtures/fake-flake; + with-inputs-dep = mkSrc ./fixtures/with-inputs-flake; + } + { + my-lib = s: { inputs.nixpkgs.follows = "with-inputs-dep/nixpkgs2"; }; + } + ).my-lib.inputs.nixpkgs.outPath; + expected = npins.nixpkgs.outPath; + }; + real-flakes.test-npins-nix-maid-nixosModules-output-is-readable = { expr = (with-inputs npins { } (inputs: { diff --git a/with-inputs.nix b/with-inputs.nix index dedc559..8d300ec 100644 --- a/with-inputs.nix +++ b/with-inputs.nix @@ -62,11 +62,9 @@ let hostName: subName: let entry = inputs.${hostName} or null; + getSubInput = e: if builtins.isAttrs e && e ? inputs then e.inputs.${subName} or null else null; in - if entry != null && builtins.isAttrs entry && entry ? inputs then - entry.inputs.${subName} or null - else - null; + getSubInput (if builtins.isFunction entry then (entry sources.${hostName}) else entry); # Resolve an inputs entry to an actual input value, or null if unresolvable. # Values with outPath but no _type go through mkInput so their flake.nix is loaded.