Update a package: Difference between revisions
imported>Makefu m Makefu moved page Updating a package in Nixpkgs to Nixpkgs/Update a package |
m Fix category formatting |
||
(12 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 \ | ||
--depth=1 # Prevents cloning the entire history, which is multiple gigabytes | |||
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</syntaxhighlight> | ||
Line 40: | Line 41: | ||
== 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 65: | Line 67: | ||
* We will dive (not too deep, though) on <tt>pkgs/applications/window-managers/i3/default.nix</tt> which is the nix expression that corresponds to the package for the i3 window manager: | * We will dive (not too deep, though) on <tt>pkgs/applications/window-managers/i3/default.nix</tt> which is the nix expression that corresponds to the package for the i3 window manager: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
{ fetchurl, stdenv, which, | { fetchurl, stdenv, which, pkg-config, libxcb, xcbutilkeysyms, xcbutil, | ||
xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | ||
libXcursor, coreutils, perl, pango }: | libXcursor, coreutils, perl, pango }: | ||
Line 78: | Line 80: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | ||
postPatch = '' | |||
patchShebangs | patchShebangs | ||
''; | ''; | ||
Line 108: | Line 110: | ||
** Changed the <tt>version</tt> string. | ** Changed the <tt>version</tt> string. | ||
** Changed the checksum for the tarball on the <tt>sha256</tt> string. | ** Changed the checksum for the tarball on the <tt>sha256</tt> string. | ||
** Removed a line on the <tt> | ** Removed a line on the <tt>postPatch</tt> string. This line was a <tt>sed</tt> command which was erasing some lines from the file <tt>common.mk</tt>, which is part of the sources in the tarball, before building the application. | ||
* And in an attempt to extract something positive from the issue, we are going to review an additional [https://github.com/NixOS/nixpkgs/commit/1eb437784021521d57ae96980bf447e9162d4415 unfortunate change] I made on <tt>pkgs/top-level/all-packages.nix</tt> | * And in an attempt to extract something positive from the issue, we are going to review an additional [https://github.com/NixOS/nixpkgs/commit/1eb437784021521d57ae96980bf447e9162d4415 unfortunate change] I made on <tt>pkgs/top-level/all-packages.nix</tt> | ||
* To figure out the checksum for the tarball you have the <tt>nix-prefetch-url</tt> utility. In addition to returning the ''sha256 checksum'' it will also leave the downloaded blob on your ''nix store'', thus avoiding additional downloads when you test the build process. You get the path to the downloaded blob and the ''sha256sum'' on the last two lines of the command's output: | * To figure out the checksum for the tarball you have the <tt>nix-prefetch-url</tt> utility. In addition to returning the ''sha256 checksum'' it will also leave the downloaded blob on your ''nix store'', thus avoiding additional downloads when you test the build process. You get the path to the downloaded blob and the ''sha256sum'' on the last two lines of the command's output: | ||
Line 126: | Line 128: | ||
+++ b/pkgs/applications/window-managers/i3/default.nix | +++ b/pkgs/applications/window-managers/i3/default.nix | ||
@@ -1,21 +1,20 @@ | @@ -1,21 +1,20 @@ | ||
{ fetchurl, stdenv, which, | { fetchurl, stdenv, which, pkg-config, libxcb, xcbutilkeysyms, xcbutil, | ||
xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | ||
- libXcursor, coreutils, perl }: | - libXcursor, coreutils, perl }: | ||
Line 142: | Line 144: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
- libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | - libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | ||
+ libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | + libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | ||
postPatch = '' | |||
- sed -i -e '/^# Pango/,/^$/d' common.mk | - sed -i -e '/^# Pango/,/^$/d' common.mk | ||
patchShebangs . | patchShebangs . | ||
Line 173: | Line 175: | ||
* 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 206: | ||
* 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 298: | Line 298: | ||
+++ b/pkgs/applications/window-managers/i3/default.nix | +++ b/pkgs/applications/window-managers/i3/default.nix | ||
@@ -1,21 +1,20 @@ | @@ -1,21 +1,20 @@ | ||
{ fetchurl, stdenv, which, | { fetchurl, stdenv, which, pkg-config, libxcb, xcbutilkeysyms, xcbutil, | ||
xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | ||
- libXcursor, coreutils, perl }: | - libXcursor, coreutils, perl }: | ||
Line 314: | Line 314: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
- libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | - libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | ||
+ libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | + libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | ||
postPatch = '' | |||
- sed -i -e '/^# Pango/,/^$/d' common.mk | - sed -i -e '/^# Pango/,/^$/d' common.mk | ||
patchShebangs . | patchShebangs . | ||
Line 337: | Line 337: | ||
+++ b/pkgs/applications/window-managers/i3/default.nix | +++ b/pkgs/applications/window-managers/i3/default.nix | ||
@@ -1,21 +1,20 @@ | @@ -1,21 +1,20 @@ | ||
{ fetchurl, stdenv, which, | { fetchurl, stdenv, which, pkg-config, libxcb, xcbutilkeysyms, xcbutil, | ||
xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | ||
- libXcursor, coreutils, perl }: | - libXcursor, coreutils, perl }: | ||
Line 353: | Line 353: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
- libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | - libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | ||
+ libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | + libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | ||
postPatch = '' | |||
- sed -i -e '/^# Pango/,/^$/d' common.mk | - sed -i -e '/^# Pango/,/^$/d' common.mk | ||
patchShebangs . | patchShebangs . | ||
Line 365: | Line 365: | ||
Split into 5 hunks. | Split into 5 hunks. | ||
@@ -1,6 +1,6 @@ | @@ -1,6 +1,6 @@ | ||
{ fetchurl, stdenv, which, | { fetchurl, stdenv, which, pkg-config, libxcb, xcbutilkeysyms, xcbutil, | ||
xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | xcbutilwm, libstartup_notification, libX11, pcre, libev, yajl, | ||
- libXcursor, coreutils, perl }: | - libXcursor, coreutils, perl }: | ||
Line 391: | Line 391: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n | Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n | ||
@@ -12,6 +12,6 @@ | @@ -12,6 +12,6 @@ | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
- libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | - libstartup_notification libX11 pcre libev yajl libXcursor perl ]; | ||
+ libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | + libstartup_notification libX11 pcre libev yajl libXcursor perl pango ]; | ||
postPatch = '' | |||
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? y | Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? y | ||
@@ -16,6 +16,5 @@ | @@ -16,6 +16,5 @@ | ||
postPatch = '' | |||
- sed -i -e '/^# Pango/,/^$/d' common.mk | - sed -i -e '/^# Pango/,/^$/d' common.mk | ||
patchShebangs . | patchShebangs . | ||
Line 434: | Line 434: | ||
}; | }; | ||
buildInputs = [ which | buildInputs = [ which pkg-config libxcb xcbutilkeysyms xcbutil xcbutilwm | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* As these changes are both related, we can issue a simple commit: | * As these changes are both related, we can issue a simple commit: | ||
Line 471: | Line 471: | ||
* 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 491: | ||
* [[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]] |