python-aliases: add warnAlias

This commit is contained in:
Sandro Jäckel
2026-02-16 21:49:47 +01:00
parent 6a8895f830
commit aece3d33fb
+20
View File
@@ -27,6 +27,26 @@ let
lib.mapAttrs (
n: alias: removeDistribute (removeRecurseForDerivations (checkInPkgs n alias))
) aliases;
warnAlias =
msg: v:
if lib.isDerivation v then
lib.warnOnInstantiate msg v
else if lib.isAttrs v then
lib.mapAttrs (_: lib.warn msg) v
else if lib.isFunction v then
arg: lib.warn msg (v arg)
else if lib.isList v then
map (lib.warn msg) v
else
# Cant do better than this, and a `throw` would be more
# disruptive for users…
#
# `nix search` flags up warnings already, so hopefully this wont
# make things much worse until we have proper CI for aliases,
# especially since aliases of paths and numbers are presumably
# not common.
lib.warn msg v;
in
### Deprecated aliases - for backward compatibility