Nix packages can declare meta-attributes that contain information about a package such as a description, its homepage, its license, and so on. For instance, the GNU Hello package has a meta declaration like this:
meta = {
description = "A program that produces a familiar, friendly greeting";
longDescription = ''
GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable.
'';
homepage = http://www.gnu.org/software/hello/manual/;
license = "GPLv3+";
};
Meta-attributes are not passed to the builder of the package. Thus, a change to a meta-attribute doesn’t trigger a recompilation of the package. The value of a meta-attribute must a string.
The meta-attributes of a package can be queried from the command-line using nix-env:
$ nix-env -qa hello --meta --xml
<?xml version='1.0' encoding='utf-8'?>
<items>
<item attrPath="hello" name="hello-2.3" system="i686-linux">
<meta name="description" value="A program that produces a familiar, friendly greeting" />
<meta name="homepage" value="http://www.gnu.org/software/hello/manual/" />
<meta name="license" value="GPLv3+" />
<meta name="longDescription" value="GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable.
" />
</item>
</items>
nix-env knows about the description field specifically:
$ nix-env -qa hello --description
hello-2.3 A program that produces a familiar, friendly greeting
The following meta-attributes have a standard interpretation:
A short (one-line) description of the package. This is shown by nix-env -q --description and also on the Nixpkgs release pages.
Don’t include a period at the end. Don’t include newline characters. Capitalise the first character. For brevity, don’t repeat the name of package — just describe what it does.
Wrong: "libpng is a library that allows you to decode PNG images."
Right: "A library for decoding PNG images"
A list of names and e-mail addresses of the maintainers of this Nix expression, e.g. ``[“Alice
<alice@example.org>” “Bob <bob@example.com>”]``. If you are the
maintainer of multiple packages, you may want to add yourself to `pkgs/lib/maintainers.nix <https://github.com/NixOS/nixpkgs/blob/master/pkgs/lib/maintainers.nix>`__ and write something like ``[stdenv.lib.maintainers.alice
stdenv.lib.maintainers.bob]``.
The list of Nix platform types on which the package is supported. If this attribute is set, the package will refuse to build, and won’t show up in ``nix-env
-qa`` output, on any platform not listed here. An example is:
meta.platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" ];
The set lib.platforms defines various common lists of platforms types, so it’s more typical to write:
meta.platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
The list of Nix platform types for which the Hydra instance at hydra.nixos.org should build the package. (Hydra is the Nix-based continuous build system.) It defaults to the value of meta.platforms. Thus, the only reason to set meta.hydraPlatforms is if you want hydra.nixos.org to build the package on a subset of meta.platforms, or not at all, e.g.
meta.platforms = stdenv.lib.platforms.linux;
meta.hydraPlatforms = [];
Note
This is just a first attempt at standardising the license attribute.
The meta.license attribute must be one of the following:
Unfree package that can be redistributed in binary form. That is, it’s legal to redistribute the output of the derivation. This means that the package can be included in the Nixpkgs channel.
Sometimes proprietary software can only be redistributed unmodified. Make sure the builder doesn’t actually modify the original binaries; otherwise we’re breaking the license. For instance, the NVIDIA X11 drivers can be redistributed unmodified, but our builder applies patchelf to make them work. Thus, its license is unfree and it cannot be included in the Nixpkgs channel.