Nixpkgs/Modifying Packages: Difference between revisions
imported>Roberth mNo edit summary |
Add link and tweak styling Tags: Mobile edit Mobile web edit |
||
(2 intermediate revisions by 2 users not shown) | |||
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 | 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 == | ||
Line 34: | Line 34: | ||
== Create an Overlay == | == Create an Overlay == | ||
Overlays are a composable method of managing packages that are not (or not yet) suitable for upstream NixPkgs. Unlike a fork, you can have multiple active overlays and you can make changes to packages without having to maintain a git fork of the entire repository. | [[Overlays]] are a composable method of managing packages that are not (or not yet) suitable for upstream NixPkgs. Unlike a fork, you can have multiple active overlays and you can make changes to packages without having to maintain a git fork of the entire repository. | ||
[https://github.com/basvandijk/nixtodo/blob/master/default.nix Nixtodo] has an example of using an overlay to structure the packages in a web application project. | [https://github.com/basvandijk/nixtodo/blob/master/default.nix Nixtodo] has an example of using an overlay to structure the packages in a web application project. | ||
[https://github.com/mozilla/nixpkgs-mozilla Nixpkgs-mozilla] is an example of an overlay containing alternative and extra open source software. | [https://github.com/mozilla/nixpkgs-mozilla Nixpkgs-mozilla] is an example of an overlay containing alternative and extra open source software. |