Packaging/Tutorial: Difference between revisions
imported>Makefu m Makefu moved page Generic Algorithm on Doing Packaging to Packaging/Tutorial |
imported>Akavel m fix indentation of lists |
||
| Line 19: | Line 19: | ||
$ configurePhase | $ configurePhase | ||
$ buildPhase</syntaxhighlight> | $ buildPhase</syntaxhighlight> | ||
<p>(visit [https://nixos.org/nixpkgs/manual/#sec-stdenv-phases stdenv-phases] chapter to learn more about phases)</p | <p>(visit [https://nixos.org/nixpkgs/manual/#sec-stdenv-phases stdenv-phases] chapter to learn more about phases)</p> | ||
You may need to run <syntaxhighlight lang="console" inline>$ eval "$configurePhase"</syntaxhighlight> sometimes if build expression overrides that phase. | <p>You may need to run <syntaxhighlight lang="console" inline>$ eval "$configurePhase"</syntaxhighlight> sometimes if build expression overrides that phase.</p> | ||
It most likely will fail. | <p>It most likely will fail.</p> | ||
</li></ol> | |||
<ol start="6" style="list-style-type: decimal;"> | <ol start="6" style="list-style-type: decimal;"> | ||
<li>Try to find failure category. It may be headers not found, library not found, executable not found, compiler not found, wrong build system, empty result, and many many more... But solutions to these problems are a bit more controllable: | <li>Try to find failure category. It may be headers not found, library not found, executable not found, compiler not found, wrong build system, empty result, and many many more... But solutions to these problems are a bit more controllable: | ||
<ol style="list-style-type: lower-alpha;"> | |||
<li><code>buildInput</code> dependency missing</li> | |||
<li><code>buildInput</code> dependency missing</li | <li>source requires patching</li> | ||
<li>you should enter a subdir first</li> | |||
<li>you should specify correct build parameters</li> | |||
<li>source requires patching | <li><code>patchShebangs</code> should be run first</li> | ||
</li | <li>....</li> | ||
</ol> | |||
<li>you should enter a subdir first | |||
</li | |||
<li>you should specify correct build parameters | |||
</li | |||
<li><code>patchShebangs</code> should be run first | |||
</li> | |||
<li>....</li></ | |||
Don't hesitate to learn from other package manager expressions, like AUR. | Don't hesitate to learn from other package manager expressions, like AUR. | ||
</li> | |||
<li><p>Apply a fix, [https://unix.stackexchange.com/questions/191885/quickly-reload-nix-expression-in-nix-shell exit nix-shell and enter it again]. Do steps 6-7 while there are problems.</p></li> | <li><p>Apply a fix, [https://unix.stackexchange.com/questions/191885/quickly-reload-nix-expression-in-nix-shell exit nix-shell and enter it again]. Do steps 6-7 while there are problems.</p></li> | ||
<li><p>After you got <code>buildPhase</code> to pass and produce correct binaries/libraries, time to <code>installPhase</code>. There are two ways: either you do package developement under root and have write access to Nix store inside nix-shell, or you simply run <code>nix-build</code> on you expression, so Nix will perform it's <code>installPhase</code>.</p | <li><p>After you got <code>buildPhase</code> to pass and produce correct binaries/libraries, time to <code>installPhase</code>. There are two ways: either you do package developement under root and have write access to Nix store inside nix-shell, or you simply run <code>nix-build</code> on you expression, so Nix will perform it's <code>installPhase</code>.</p> | ||
In first case, you can run | <p>In first case, you can run</p> | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
$ installPhase | $ installPhase | ||
</syntaxhighlight> | </syntaxhighlight> | ||
directly and examine using <code>tree $out</code> your package files. If something is missing or too many, fix the <code>postInstallPhase</code> or <code>preInstallPhase</code> or <code>installPhase</code> in your expression. | |||
<p>directly and examine using <code>tree $out</code> your package files. If something is missing or too many, fix the <code>postInstallPhase</code> or <code>preInstallPhase</code> or <code>installPhase</code> in your expression.</p> | |||
</li></ol> | |||
<ol start="9" style="list-style-type: decimal;"> | <ol start="9" style="list-style-type: decimal;"> | ||
<li><p>At this point you should have something that is both buildable and packageable. It still may not be runnable. Run the binaries to find out hidden dependencies, or patches required, or wrapper required, or patchelf required, or ... In general, I use Google and search in Nixpkgs issue tracker related problems.</p></li> | <li><p>At this point you should have something that is both buildable and packageable. It still may not be runnable. Run the binaries to find out hidden dependencies, or patches required, or wrapper required, or patchelf required, or ... In general, I use Google and search in Nixpkgs issue tracker related problems.</p></li> | ||
<li><p>After all the modifications, package should be buildable, runnable and should be self-sufficient. You may add <code>meta</code> section, but it isn't strictly required if you don't plan to publish your result.</p></li></ol> | <li><p>After all the modifications, package should be buildable, runnable and should be self-sufficient. You may add <code>meta</code> section, but it isn't strictly required if you don't plan to publish your result.</p></li></ol> | ||