python-aliases: add warnAlias
This commit is contained in:
@@ -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
|
||||
# Can’t do better than this, and a `throw` would be more
|
||||
# disruptive for users…
|
||||
#
|
||||
# `nix search` flags up warnings already, so hopefully this won’t
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user