query
On this page

warnOnInstantiate

lib.derivations.warnOnInstantiate

Docs pulled from | This Revision | 9 minutes ago


Nixpkgs manual

Wrap a derivation such that instantiating it produces a warning.

All attributes will be wrapped with lib.warn except from .meta, .name, and .type which are used by nix search, and .outputName which avoids double warnings with nix-instantiate and nix-build.

Inputs

msg
The warning message to emit (via lib.warn).
drv
The derivation to wrap.

Type

warnOnInstantiate :: String -> Derivation -> Derivation

Examples

lib.derivations.warnOnInstantiate usage example

{
  myPackage = warnOnInstantiate "myPackage has been renamed to my-package" my-package;
}

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

warnOnInstantiate =
    msg: drv:
    let
      drvToWrap = removeAttrs drv [
        "meta"
        "name"
        "type"
        "outputName"
      ];
    in
    drv
    // mapAttrs (_: lib.warn msg) drvToWrap
    // (
      if drv ? overrideAttrs && builtins.isFunction drv.overrideAttrs then
        { overrideAttrs = x: lib.derivations.warnOnInstantiate msg (drv.overrideAttrs x); }
      else
        { }
    );