File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 121121 inherit ( self . customisation ) overrideDerivation makeOverridable
122122 callPackageWith callPackagesWith extendDerivation hydraJob
123123 makeScope makeScopeWithSplicing makeScopeWithSplicing' ;
124- inherit ( self . derivations ) lazyDerivation optionalDrvAttr ;
124+ inherit ( self . derivations ) lazyDerivation optionalDrvAttr warnOnInstantiate ;
125125 inherit ( self . meta ) addMetaAttrs dontDistribute setName updateName
126126 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
127127 hiPrioSet licensesSpdx getLicenseFromSpdxId getLicenseFromSpdxIdOr
Original file line number Diff line number Diff line change 44 inherit ( lib )
55 genAttrs
66 isString
7+ mapAttrs
8+ removeAttrs
79 throwIfNot
810 ;
911
206208 optionalDrvAttr =
207209 cond :
208210 value : if cond then value else null ;
211+
212+ /**
213+ Wrap a derivation such that instantiating it produces a warning.
214+
215+ All attributes apart from `meta`, `name`, and `type` (which are used by
216+ `nix search`) will be wrapped in `lib.warn`.
217+
218+ # Inputs
219+
220+ `msg`
221+ : The warning message to emit (via `lib.warn`).
222+
223+ `drv`
224+ : The derivation to wrap.
225+
226+ # Examples
227+ :::{.example}
228+ ## `lib.derivations.warnOnInstantiate` usage example
229+
230+ ```nix
231+ {
232+ myPackage = warnOnInstantiate "myPackage has been renamed to my-package" my-package;
233+ }
234+ ```
235+
236+ :::
237+ */
238+ warnOnInstantiate =
239+ msg : drv :
240+ let
241+ drvToWrap = removeAttrs drv [ "meta" "name" "type" ] ;
242+ in
243+ drv
244+ // mapAttrs ( _ : lib . warn msg ) drvToWrap ;
209245}
You can’t perform that action at this time.
0 commit comments