mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-06-05 21:03:40 +00:00
various: remove lib.warnIf from most critical functions (#524541)
This commit is contained in:
@@ -1158,8 +1158,10 @@ let
|
||||
value = if opt ? apply then opt.apply res.mergedValue else res.mergedValue;
|
||||
|
||||
warnDeprecation =
|
||||
warnIf (opt.type.deprecationMessage != null)
|
||||
"The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";
|
||||
if (opt.type.deprecationMessage != null) then
|
||||
warn "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}"
|
||||
else
|
||||
x: x;
|
||||
|
||||
in
|
||||
warnDeprecation opt
|
||||
|
||||
@@ -327,23 +327,27 @@ lib.extendMkDerivation {
|
||||
|
||||
outputHashMode = if (recursiveHash || executable) then "recursive" else "flat";
|
||||
|
||||
curlOpts = lib.warnIf (lib.isList curlOpts) (
|
||||
let
|
||||
url = toString (builtins.head urls_);
|
||||
curlOptsRepresentation = lib.generators.toPretty { multiline = false; } curlOpts;
|
||||
curlOptsAsStringRepresentation = lib.strings.escapeNixString (toString curlOpts);
|
||||
curlOptsListElementsRepresentation =
|
||||
lib.concatMapStringsSep " " lib.strings.escapeNixString
|
||||
curlOpts;
|
||||
in
|
||||
''
|
||||
fetchurl for ${url}: curlOpts is a list (${curlOptsRepresentation}), which is not supported anymore.
|
||||
- If you wish to get the same effect as before, for elements with spaces (even if escaped) to expand to multiple curl arguments, use a string argument instead:
|
||||
curlOpts = ${curlOptsAsStringRepresentation};
|
||||
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
|
||||
curlOptsList = [ ${curlOptsListElementsRepresentation} ];
|
||||
''
|
||||
) curlOpts;
|
||||
curlOpts =
|
||||
if lib.isList curlOpts then
|
||||
lib.warn (
|
||||
let
|
||||
url = toString (builtins.head urls_);
|
||||
curlOptsRepresentation = lib.generators.toPretty { multiline = false; } curlOpts;
|
||||
curlOptsAsStringRepresentation = lib.strings.escapeNixString (toString curlOpts);
|
||||
curlOptsListElementsRepresentation =
|
||||
lib.concatMapStringsSep " " lib.strings.escapeNixString
|
||||
curlOpts;
|
||||
in
|
||||
''
|
||||
fetchurl for ${url}: curlOpts is a list (${curlOptsRepresentation}), which is not supported anymore.
|
||||
- If you wish to get the same effect as before, for elements with spaces (even if escaped) to expand to multiple curl arguments, use a string argument instead:
|
||||
curlOpts = ${curlOptsAsStringRepresentation};
|
||||
- If you wish for each list element to be passed as a separate curl argument, allowing arguments to contain spaces, use curlOptsList instead:
|
||||
curlOptsList = [ ${curlOptsListElementsRepresentation} ];
|
||||
''
|
||||
) curlOpts
|
||||
else
|
||||
curlOpts;
|
||||
|
||||
inherit
|
||||
curlOptsList
|
||||
|
||||
@@ -106,9 +106,11 @@ lib.extendMkDerivation {
|
||||
)
|
||||
+ ''
|
||||
${postFetch}
|
||||
${lib.warnIf (extraPostFetch != "")
|
||||
"use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub' or 'fetchFromGitLab'."
|
||||
extraPostFetch
|
||||
${
|
||||
if extraPostFetch != "" then
|
||||
lib.warn "use 'postFetch' instead of 'extraPostFetch' with 'fetchzip' and 'fetchFromGitHub' or 'fetchFromGitLab'." extraPostFetch
|
||||
else
|
||||
extraPostFetch
|
||||
}
|
||||
chmod 755 "$out"
|
||||
'';
|
||||
|
||||
@@ -128,8 +128,8 @@ let
|
||||
# f is not a function; probably { ... }
|
||||
f0;
|
||||
in
|
||||
warnIf
|
||||
(
|
||||
(
|
||||
if
|
||||
prev ? src
|
||||
&& thisOverlay ? version
|
||||
&& prev ? version
|
||||
@@ -138,32 +138,36 @@ let
|
||||
# && prev.version != thisOverlay.version
|
||||
&& !(thisOverlay ? src)
|
||||
&& !(thisOverlay.__intentionallyOverridingVersion or false)
|
||||
)
|
||||
(
|
||||
let
|
||||
pos = unsafeGetAttrPos "version" thisOverlay;
|
||||
in
|
||||
''
|
||||
${
|
||||
args.name or "${args.pname or "<unknown name>"}-${args.version or "<unknown version>"}"
|
||||
} was overridden with `version` but not `src` at ${pos.file or "<unknown file>"}:${
|
||||
toString pos.line or "<unknown line>"
|
||||
}:${toString pos.column or "<unknown column>"}.
|
||||
|
||||
This is most likely not what you want. In order to properly change the version of a package, override
|
||||
both the `version` and `src` attributes:
|
||||
then
|
||||
warn (
|
||||
let
|
||||
pos = unsafeGetAttrPos "version" thisOverlay;
|
||||
in
|
||||
''
|
||||
${
|
||||
args.name or "${args.pname or "<unknown name>"}-${args.version or "<unknown version>"}"
|
||||
} was overridden with `version` but not `src` at ${pos.file or "<unknown file>"}:${
|
||||
toString pos.line or "<unknown line>"
|
||||
}:${toString pos.column or "<unknown column>"}.
|
||||
|
||||
hello.overrideAttrs (oldAttrs: rec {
|
||||
version = "1.0.0";
|
||||
src = pkgs.fetchurl {
|
||||
url = "mirror://gnu/hello/hello-''${version}.tar.gz";
|
||||
hash = "...";
|
||||
};
|
||||
})
|
||||
This is most likely not what you want. In order to properly change the version of a package, override
|
||||
both the `version` and `src` attributes:
|
||||
|
||||
(To silence this warning, set `__intentionallyOverridingVersion = true` in your `overrideAttrs` call.)
|
||||
''
|
||||
)
|
||||
hello.overrideAttrs (oldAttrs: rec {
|
||||
version = "1.0.0";
|
||||
src = pkgs.fetchurl {
|
||||
url = "mirror://gnu/hello/hello-''${version}.tar.gz";
|
||||
hash = "...";
|
||||
};
|
||||
})
|
||||
|
||||
(To silence this warning, set `__intentionallyOverridingVersion = true` in your `overrideAttrs` call.)
|
||||
''
|
||||
)
|
||||
else
|
||||
x: x
|
||||
)
|
||||
(prev // (removeAttrs thisOverlay [ "__intentionallyOverridingVersion" ]))
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user