From ec9f9b1acc0c4c2d04938b99a86a6b9000261d71 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Giraudeau Date: Sun, 13 Sep 2026 12:16:22 +0200 Subject: [PATCH] fix: overrideSubSpec to handle case where input override take source arg --- tests.nix | 15 +++++++++++++++ with-inputs.nix | 6 ++---- 2 files changed, 17 insertions(+), 4 deletions(-) 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.