Loading maintainers/scripts/remove-old-aliases.py +4 −4 Original line number Diff line number Diff line Loading @@ -98,8 +98,8 @@ def get_date_lists( date_too_complex_list.append(f"{lineno:>5} {line}") elif "= with " in line: date_too_complex_list.append(f"{lineno:>5} {line}") elif "lib.warnOnInstantiate" in line or "warning" in line: if 'lib.warnOnInstantiate "' in line: elif "warnAlias" in line or "warning" in line: if 'warnAlias "' in line: date_older_warning_list.append(line) else: date_too_complex_list.append(f"{lineno:>5} {line}") Loading Loading @@ -140,7 +140,7 @@ def convert(lines: list[str], convert_to: str) -> list[tuple[str, str]]: before_equal, after_equal = ( x.strip() for x in line.split("=", maxsplit=2) ) if after_equal.startswith("lib.warnOnInstantiate"): if after_equal.startswith("warnAlias"): after_equal = after_equal.split("\"", maxsplit=3)[2].strip() except ValueError as err: print(err, line, "\n") Loading @@ -162,7 +162,7 @@ def convert(lines: list[str], convert_to: str) -> list[tuple[str, str]]: converted_lines[line] = converted elif convert_to == "warnings": converted = ( f"{indent}{alias} = lib.warnOnInstantiate \"'{alias_unquoted}' has been" f"{indent}{alias} = warnAlias \"'{alias_unquoted}' has been" f" renamed to/replaced by '{replacement}'\" {replacement};" f" # Converted to warning {datetime.today().strftime('%Y-%m-%d')}" ) Loading pkgs/top-level/aliases.nix +25 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,31 @@ let aliases: lib.mapAttrs (n: alias: removeRecurseForDerivations (checkInPkgs n alias)) aliases; plasma5Throws = mapAliases (lib.mapAttrs (k: _: makePlasma5Throw k) deprecatedPlasma5Packages); 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 if lib.isString v then # Unlike the other cases, this changes the type of the value and # is therefore a breaking change for some code, but it’s the best # we can do. { __toString = lib.warn msg (lib.const 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 mapAliases { Loading Loading
maintainers/scripts/remove-old-aliases.py +4 −4 Original line number Diff line number Diff line Loading @@ -98,8 +98,8 @@ def get_date_lists( date_too_complex_list.append(f"{lineno:>5} {line}") elif "= with " in line: date_too_complex_list.append(f"{lineno:>5} {line}") elif "lib.warnOnInstantiate" in line or "warning" in line: if 'lib.warnOnInstantiate "' in line: elif "warnAlias" in line or "warning" in line: if 'warnAlias "' in line: date_older_warning_list.append(line) else: date_too_complex_list.append(f"{lineno:>5} {line}") Loading Loading @@ -140,7 +140,7 @@ def convert(lines: list[str], convert_to: str) -> list[tuple[str, str]]: before_equal, after_equal = ( x.strip() for x in line.split("=", maxsplit=2) ) if after_equal.startswith("lib.warnOnInstantiate"): if after_equal.startswith("warnAlias"): after_equal = after_equal.split("\"", maxsplit=3)[2].strip() except ValueError as err: print(err, line, "\n") Loading @@ -162,7 +162,7 @@ def convert(lines: list[str], convert_to: str) -> list[tuple[str, str]]: converted_lines[line] = converted elif convert_to == "warnings": converted = ( f"{indent}{alias} = lib.warnOnInstantiate \"'{alias_unquoted}' has been" f"{indent}{alias} = warnAlias \"'{alias_unquoted}' has been" f" renamed to/replaced by '{replacement}'\" {replacement};" f" # Converted to warning {datetime.today().strftime('%Y-%m-%d')}" ) Loading
pkgs/top-level/aliases.nix +25 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,31 @@ let aliases: lib.mapAttrs (n: alias: removeRecurseForDerivations (checkInPkgs n alias)) aliases; plasma5Throws = mapAliases (lib.mapAttrs (k: _: makePlasma5Throw k) deprecatedPlasma5Packages); 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 if lib.isString v then # Unlike the other cases, this changes the type of the value and # is therefore a breaking change for some code, but it’s the best # we can do. { __toString = lib.warn msg (lib.const 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 mapAliases { Loading