aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-11-11 18:54:45 +0000
committertv <tv@krebsco.de>2026-11-11 18:54:45 +0000
commit55b99bfba969bdaba40e4a151531abe41ac83923 (patch)
treee70a7743d676d3507944dc27899b986a15cf12e8
parent16da86c825f0dc3f85187311ec71ec1f038fc065 (diff)
lib: add flakeFollows
flakeFollows lists the inputs a source draws from other sources, with the paths of nested inputs flattened.
-rw-r--r--lib/default.nix14
1 files changed, 14 insertions, 0 deletions
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 ""