Nix Cookbook: Difference between revisions
new recipe |
|||
Line 126: | Line 126: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
== Deprecating input | == Deprecating a specific input parameter in mkDerivation-style packages == | ||
Sometimes we want to rename | Sometimes we want to rename some input parameter in . | ||
E.G. an option `withX` that enables the X11 GUI for a certain app: | E.G. an option `withX` that enables the X11 GUI for a certain app: | ||
Line 137: | Line 137: | ||
withX ? true, | withX ? true, | ||
/*. . .*/ | /*. . .*/ | ||
} | }: | ||
stdenv.mkDerivation { /* . . . */} | |||
</syntaxHighlight> | </syntaxHighlight> | ||
Suppose that a new version of this package features a more agnostic GUI that can be linked to X11, GTK, Qt etc. | Suppose that a new version of this package features a more agnostic GUI that can be linked to X11, GTK, Qt etc. | ||
Because of it, `withX` is no longer a | Because of it, `withX` is no longer a descriptive name for this functionality. | ||
However, renaming the parameter is dangerous, because other functions that call this function expect this parameter. | |||
The problem becomes more pronounced when in conjunction with custom, third-party overlays. | |||
The solution is, roughly, emit a warning about the old parameter being used, reporting the user to the new parameter: | The solution is, roughly, to emit a warning about the old parameter being used, reporting the user to the new parameter: | ||
<syntaxHighlight lang="nix"> | <syntaxHighlight lang="nix"> |