From 55b99bfba969bdaba40e4a151531abe41ac83923 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 11 Nov 2026 18:54:45 +0000 Subject: lib: add flakeFollows flakeFollows lists the inputs a source draws from other sources, with the paths of nested inputs flattened. --- lib/default.nix | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/default.nix b/lib/default.nix index 989920d..f720a08 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -28,6 +28,20 @@ let { # This function's return value can be used as pkgs.populate input. source: sanitize (eval source).config.source; + # Inputs a source draws from other sources, as list of attribute sets like + # { path = [ "stockholm" "nixpkgs" ]; source = "nixpkgs"; }. + flakeFollows = source: let + flatten = prefix: inputs: lib.concatLists (lib.mapAttrsToList + (name: input: + lib.optional (input.follows or null != null) { + path = prefix ++ [ name ]; + source = input.follows; + } ++ + flatten (prefix ++ [ name ]) (input.inputs or {})) + inputs); + in + flatten [] (source.${source.type}.inputs or {}); + maybeHostName = default: let # We're parsing /etc/hostname here because reading # /proc/sys/kernel/hostname yields "" -- cgit v1.3.1