Update a package: Difference between revisions
imported>Jtojnar m use postPatch instead of patchPhase |
Update clone instructions to save disk space and avoid shallow clone |
||
| (11 intermediate revisions by 9 users not shown) | |||
| Line 21: | Line 21: | ||
mkdir ~/devel/ | mkdir ~/devel/ | ||
cd ~/devel/ | cd ~/devel/ | ||
git clone https://github.com/your_username/nixpkgs.git | git clone https://github.com/your_username/nixpkgs.git \ | ||
--filter=blob:none # Prevents downloading the entire history, which saves a couple Gb | |||
cd nixpkgs/ | cd nixpkgs/ | ||
git remote add upstream https://github.com/NixOS/nixpkgs.git</syntaxhighlight> | git remote add upstream https://github.com/NixOS/nixpkgs.git | ||
git gc --aggressive # nixpkgs is a large repository; this brings down the disk usage by another Gb or so</syntaxhighlight> | |||
* When the clone is not recent or you suspect there have been changes upstream (in official nixpkgs): | * When the clone is not recent or you suspect there have been changes upstream (in official nixpkgs): | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
| Line 40: | Line 42: | ||
== Following the white rabbit == | == Following the white rabbit == | ||
* This section does not apply for packages in the directory pkgs/by-name. For them, see the included [https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/README.md pkgs/by-name/README.md]. | |||
* I will center this tutorial on the nix expression that packages the [http://i3wm.org/ i3 window manager], as this expression is quite simple and it was contributing to this expression that I got to understand this whole workflow I am documenting. | * I will center this tutorial on the nix expression that packages the [http://i3wm.org/ i3 window manager], as this expression is quite simple and it was contributing to this expression that I got to understand this whole workflow I am documenting. | ||
* In <tt>~/devel/nixpkgs/default.nix</tt> there is an ''import'' statement that reads <tt>import ./pkgs/top-level/all-packages.nix</tt> | * In <tt>~/devel/nixpkgs/default.nix</tt> there is an ''import'' statement that reads <tt>import ./pkgs/top-level/all-packages.nix</tt> | ||
| Line 173: | Line 176: | ||
* If your current directory is, as we said, <tt>~/devel/nixpkgs/</tt>, you can request nix to build the modified package (see <tt>man nix-build</tt>): | * If your current directory is, as we said, <tt>~/devel/nixpkgs/</tt>, you can request nix to build the modified package (see <tt>man nix-build</tt>): | ||
<pre>nix-build -A i3</pre> | <pre>nix-build -A i3</pre> | ||
* In this invocation the <tt>i3</tt> in <tt>-A i3</tt> refers to <tt>i3 = callPackage ...</tt> in <tt>pkgs/top-level/all-packages.nix</tt>. In the same way as the <tt>pango</tt> we talked about above, both names are attributes from the top-level Nix expression being evaluated. In this case <tt>~/devel/nixpkgs/default.nix</tt> | |||
* In | |||
* Here I would have detected the error I introduced on <tt>pkgs/top-level/all-packages.nix</tt>. Too bad I didn't still know how to test my changes: | * Here I would have detected the error I introduced on <tt>pkgs/top-level/all-packages.nix</tt>. Too bad I didn't still know how to test my changes: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
| Line 206: | Line 207: | ||
* When the build succeeds, <tt>nix-build</tt> will leave the result linked as <tt>./result</tt> on the current working directory: | * When the build succeeds, <tt>nix-build</tt> will leave the result linked as <tt>./result</tt> on the current working directory: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
$ stat ./result | $ stat -c %N ./result | ||
File: "./result" -> "/nix/store/agld76p9rgvn3j610z8kgppz67f8kmg7-i3-4.5.1" | File: "./result" -> "/nix/store/agld76p9rgvn3j610z8kgppz67f8kmg7-i3-4.5.1" | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 471: | Line 472: | ||
* Now there are 3 commits on the <tt>example</tt> branch of out nixpkgs repository at GitHub. | * Now there are 3 commits on the <tt>example</tt> branch of out nixpkgs repository at GitHub. | ||
* The idea is to propose the official ''NixOS/nixpkgs'' maintainers to include our changes on the official repository, so all the ''nixpkgs'' users can eventually benefit of our improvements. | * The idea is to propose the official ''NixOS/nixpkgs'' maintainers to include our changes on the official repository, so all the ''nixpkgs'' users can eventually benefit of our improvements. | ||
* We should probably get in touch with the ''nixpkgs'' maintainers at [irc://irc.freenode.net/#nixos #nixos | * We should probably get in touch with the ''nixpkgs'' maintainers at [irc://irc.freenode.net/#nixos #nixos] to figure out the appropriate branch (e.g. <tt>master</tt>, <tt>x-updates</tt> or whatever) where the changes would be welcome. | ||
* So now we have to formally ''request'' them to ''pull'' our changes, from our branch to the appropriate branch in ''NixOS/nixpkgs''. Hence the name "''pull request''" which I don't feel so intuitive. | * So now we have to formally ''request'' them to ''pull'' our changes, from our branch to the appropriate branch in ''NixOS/nixpkgs''. Hence the name "''pull request''" which I don't feel so intuitive. | ||
* There is a "Pull Request" button in GitHub. Push it. Go ahead. | * There is a "Pull Request" button in GitHub. Push it. Go ahead. | ||
| Line 491: | Line 492: | ||
* [[Create and debug nix packages]] | * [[Create and debug nix packages]] | ||
* [[Generic Algorithm on Doing Packaging]] | * [[Generic Algorithm on Doing Packaging]] | ||
* [[Contributing to Nix documentation]] | * [[Contributing#Contributing to the documentation|Contributing to Nix documentation]] | ||
* [[Nixpkgs/Update Scripts]] - automatic updating of packages | |||
[[:Category: | [[Category:Tutorial]] | ||
[[Category:Nixpkgs]] | |||
[[Category:Contributing]] | |||