Nixpkgs/Modifying Packages: Difference between revisions

imported>Nix
link to overlays page
Add link and tweak styling
Tags: Mobile edit Mobile web edit
 
Line 1: Line 1:
To modify the behavior of a Nix package, you typically have more than one option. The first approach you may consider is changing its runtime configuration: passing command line options, environment variables or configuration files that exist outside the package itself. Not modifying the definition of a package has the benefit of being able to use the publicly available Hydra build cache.
To modify the behavior of a Nix package, you typically have more than one option. The first approach you may consider is changing its runtime configuration: passing command line options, environment variables or configuration files that exist outside the package itself. Not modifying the definition of a package has the benefit of being able to use the publicly available [[Hydra|Hydra]] build cache.


If the software as packaged does not have the flexibility you need, you have various options.
If the software as packaged does not have the flexibility you need, you have various options.
Line 7: Line 7:
If you expect your changes to be generally useful to others, you may consider creating a pull request for [https://github.com/NixOS/nixpkgs nixpkgs on github]. This has the benefit that others can help maintaining the package and that a binary of your package will be available for you to download.
If you expect your changes to be generally useful to others, you may consider creating a pull request for [https://github.com/NixOS/nixpkgs nixpkgs on github]. This has the benefit that others can help maintaining the package and that a binary of your package will be available for you to download.


If upstreaming into the official NixPkgs is not an option, consider creating an overlay. This is slightly more involved at first, but is easier to maintain than a NixPkgs fork and, unlike a fork, it can be combined with other overlays. In an overlay, you can also choose not to redefine the package, but only override part of the arguments or derivation attributes. For example, you may only need to change one of the [https://nixos.org/nixpkgs/manual/#sec-stdenv-phases stdenv build phases].
If upstreaming into the official NixPkgs is not an option, consider creating an overlay. This is slightly more involved at first, but is easier to maintain than a Nixpkgs fork and, unlike a fork, it can be combined with other overlays. In an overlay, you can also choose not to redefine the package, but only override part of the arguments or derivation attributes. For example, you may only need to change one of the [https://nixos.org/nixpkgs/manual/#sec-stdenv-phases stdenv build phases].


== The Copy Paste Option ==
== The Copy Paste Option ==