Packaging/Quirks and Caveats: Difference between revisions
imported>Makefu add example shell.nix for libstdc++ issue |
Phanirithvij (talk | contribs) m update url to wayback machine url |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 25: | Line 25: | ||
* [https://github.com/NixOS/nixpkgs/blob/96d41e393da3ca27fbcc7c82b7221a5c923460c0/pkgs/development/libraries/libmms/default.nix#L13 libmms] | * [https://github.com/NixOS/nixpkgs/blob/96d41e393da3ca27fbcc7c82b7221a5c923460c0/pkgs/development/libraries/libmms/default.nix#L13 libmms] | ||
One typical error when <code>pkg-config</code> is required but not in the <code>nativeBuildInputs</code> is the following during the configure phase: | |||
<syntaxhighlight lang="shell"> | |||
./configure: line 20832: syntax error near unexpected token `nss,' | |||
./configure: line 20832: ` PKG_CHECK_MODULES(nss, nss)' | |||
</syntaxhighlight> | |||
== Package simple python scripts == | == Package simple python scripts == | ||
For scripts like a single Python file, it is not necessary to specify <code>src</code> in <code>mkDerivation</code>. When you want to use <code>buildPythonPackage</code> the sources need to provide a <code>setup.py</code> file which also is overkill for a lot of projects. The default <code>mkDerivation</code> will attempt to unpack your source code. This can be prevented | For scripts like a single Python file, it is not necessary to specify <code>src</code> in <code>mkDerivation</code>. When you want to use <code>buildPythonPackage</code> the sources need to provide a <code>setup.py</code> file which also is overkill for a lot of projects. The default <code>mkDerivation</code> will attempt to unpack your source code. This can be prevented by applying <code>unpackPhase = ":";</code> (<code>:</code> is a no-op in shell scripts). | ||
<syntaxhighlight lang="nix">myscript-package = pkgs.stdenv.mkDerivation { | <syntaxhighlight lang="nix">myscript-package = pkgs.stdenv.mkDerivation { | ||
Line 47: | Line 52: | ||
Source: [http://stackoverflow.com/questions/43837691/how-to-package-a-single-python-script-with-nix/43837692#43837692 nh2 @ StackOverflow] | Source: [http://stackoverflow.com/questions/43837691/how-to-package-a-single-python-script-with-nix/43837692#43837692 nh2 @ StackOverflow] | ||
A more lightweight alternative is to use <code>nix-shell</code> in the shebang line as described in this [http://iam.travishartwell.net/2015/06/17/nix-shell-shebang/ blog post]. This causes the expression to be evaluated and built every time the script is run; this means that the dependencies will always be kept up to date, but since nix-shell only creates a temporary GC root the dependencies may be removed by a garbage collection, so this approach is not advisable for users who don't have an internet connection available all the time. | A more lightweight alternative is to use <code>nix-shell</code> in the shebang line as described in this [https://web.archive.org/web/20230330010914/http://iam.travishartwell.net/2015/06/17/nix-shell-shebang/ blog post]. This causes the expression to be evaluated and built every time the script is run; this means that the dependencies will always be kept up to date, but since nix-shell only creates a temporary GC root the dependencies may be removed by a garbage collection, so this approach is not advisable for users who don't have an internet connection available all the time. | ||
== Caveats == | == Caveats == | ||
Line 115: | Line 120: | ||
</syntaxHighlight> | </syntaxHighlight> | ||
[[Category: | [[Category:Cookbook]] |