Unverified Commit d3312786 authored by Alois Wohlschlager's avatar Alois Wohlschlager
Browse files

lib: make deprecation warnings consistent

The deprecation warnings in lib were wildly inconsistent. Different
formulations were used in different places for the same meaning. Some warnings
used builtins.trace instead of lib.warn, which prevents silencing; one even
only had a comment instead. Make everything more uniform.
parent b8b232ae
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@

let
  inherit (builtins) head tail length;
  inherit (lib.trivial) id mergeAttrs;
  inherit (lib.trivial) id mergeAttrs warn;
  inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName;
  inherit (lib.lists) foldr foldl' concatMap concatLists elemAt all partition groupBy take foldl;
in
@@ -1197,9 +1197,10 @@ rec {
      (x // y) // mask;

  # DEPRECATED
  zipWithNames = zipAttrsWithNames;
  zipWithNames = warn
    "lib.zipWithNames is a deprecated alias of lib.zipAttrsWithNames." zipAttrsWithNames;

  # DEPRECATED
  zip = builtins.trace
    "lib.zip is deprecated, use lib.zipAttrsWith instead" zipAttrsWith;
  zip = warn
    "lib.zip is a deprecated alias of lib.zipAttrsWith." zipAttrsWith;
}
+3 −3
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
{ lib }:
let
  inherit (lib.strings) toInt;
  inherit (lib.trivial) compare min id;
  inherit (lib.trivial) compare min id warn;
  inherit (lib.attrsets) mapAttrs;
  inherit (lib.lists) sort;
in
@@ -848,8 +848,8 @@ rec {
      crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
      => [ "13" "14" "23" "24" ]
  */
  crossLists = builtins.trace
    "lib.crossLists is deprecated, use lib.cartesianProductOfSets instead"
  crossLists = warn
    "lib.crossLists is deprecated, use lib.cartesianProductOfSets instead."
    (f: foldl (fs: args: concatMap (f: map f args) fs) [f]);


+1 −1
Original line number Diff line number Diff line
@@ -379,7 +379,7 @@ rec {
    if ! isString text then throw "literalExpression expects a string."
    else { _type = "literalExpression"; inherit text; };

  literalExample = lib.warn "literalExample is deprecated, use literalExpression instead, or use literalMD for a non-Nix description." literalExpression;
  literalExample = lib.warn "lib.literalExample is deprecated, use lib.literalExpression instead, or use lib.literalMD for a non-Nix description." literalExpression;

  /* Transition marker for documentation that's already migrated to markdown
     syntax. This is a no-op and no longer needed.
+2 −2
Original line number Diff line number Diff line
@@ -561,7 +561,7 @@ rec {
    [""" "'" "<" ">" "&"];

  # warning added 12-12-2022
  replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings;
  replaceChars = lib.warn "lib.replaceChars is a deprecated alias of lib.replaceStrings." builtins.replaceStrings;

  # Case conversion utilities.
  lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
@@ -1133,7 +1133,7 @@ rec {
            "/prefix/nix-profiles-library-paths.patch"
            "/prefix/compose-search-path.patch" ]
  */
  readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead"
  readPathsFromFile = lib.warn "lib.readPathsFromFile is deprecated, use a list instead."
    (rootPath: file:
      let
        lines = lib.splitString "\n" (readFile file);
+1 −1
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ in {
       else if lib.pathExists revisionFile then lib.fileContents revisionFile
       else default;

  nixpkgsVersion = builtins.trace "`lib.nixpkgsVersion` is deprecated, use `lib.version` instead!" version;
  nixpkgsVersion = warn "lib.nixpkgsVersion is a deprecated alias of lib.version." version;

  /* Determine whether the function is being called from inside a Nix
     shell.