Meta-attributesNix 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 = stdenv.lib.licenses.gpl3Plus;
maintainers = [ stdenv.lib.maintainers.eelco ];
platforms = stdenv.lib.platforms.all;
};
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="nixos.pkgs.hello" name="hello-2.9" system="x86_64-linux">
<meta name="description" type="string" value="A program that produces a familiar, friendly greeting" />
<meta name="homepage" type="string" value="http://www.gnu.org/software/hello/manual/" />
<meta name="license" type="string" value="GPLv3+" />
<meta name="longDescription" type="string" value="GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable.
" />
<meta name="maintainers" type="strings">
<string value="Ludovic Courtès <ludo@gnu.org>" />
</meta>
<meta name="platforms" type="strings">
<string value="i686-linux" />
<string value="x86_64-linux" />
<string value="armv5tel-linux" />
<string value="armv7l-linux" />
<string value="mips64el-linux" />
<string value="x86_64-darwin" />
<string value="i686-cygwin" />
<string value="i686-freebsd" />
<string value="x86_64-freebsd" />
<string value="i686-openbsd" />
<string value="x86_64-openbsd" />
</meta>
<meta name="position" type="string" value="/nix/store/cn8zjjdd9kvmp1p5d21h7ya0cr1jhkk3-nixos-14.10pre44264.12f06b3/nixos/nixpkgs/pkgs/applications/misc/hello/ex-2/default.nix:14" />
</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
Standard meta-attributesThe following meta-attributes have a standard
interpretation:descriptionA 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"longDescriptionAn arbitrarily long description of the
package.homepageThe package’s homepage. Example:
http://www.gnu.org/software/hello/manual/licenseThe license for the package. One from attribute set defined in
nixpkgs/lib/licenses.nix.
Example:
stdenv.lib.licenses.gpl3.maintainersA list of names and e-mail addresses of the
maintainers of this Nix expression. If
you would like to be a maintainer of a package, you may want to add
yourself to nixpkgs/lib/maintainers.nix
and write something like [ stdenv.lib.maintainers.alice
stdenv.lib.maintainers.bob ].priorityThe priority of the package,
used by nix-env to resolve file name conflicts
between packages. See the Nix manual page for
nix-env for details. Example:
"10" (a low-priority
package).platformsThe list of Nix platform types on which the
package is supported. An example is:
meta.platforms = stdenv.lib.platforms.linux;
Attribute Set stdenv.lib.platforms in
nixpkgs/lib/platforms.nix defines various common
lists of platforms types.
hydraPlatformsThe list of Nix platform types for which the Hydra
instance at hydra.nixos.org will 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 = [];
brokenIf set to true, the package is
marked as “broken”, meaning that it won’t show up in
nix-env -qa, and cannot be built or installed.
Such packages should be removed from Nixpkgs eventually unless
they are fixed.LicensesThis is just a first attempt at standardising the license
attribute.The meta.license attribute must be one of the
following:
GPLGNU General Public License; version not
specified.GPLv2GNU General Public License, version
2.GPLv2+GNU General Public License, version
2 or higher.GPLv3GNU General Public License, version
3.GPLv3+GNU General Public License, version
3 or higher.bsdCatch-all for licenses that are essentially
similar to the
original BSD license with the advertising clause removed,
i.e. permissive non-copyleft free software licenses. This
includes the X11
(“MIT”) License.perl5The Perl 5 license (Artistic License, version 1
and GPL, version 1 or later).freeCatch-all for free software licenses not listed
above.free-copyleftCatch-all for free, copyleft software licenses not
listed above.free-non-copyleftCatch-all for free, non-copyleft software licenses
not listed above.unfree-redistributableUnfree 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.unfreeUnfree package that cannot be redistributed. You
can build it yourself, but you cannot redistribute the output of
the derivation. Thus it cannot be included in the Nixpkgs
channel.unfree-redistributable-firmwareThis package supplies unfree, redistributable
firmware. This is a separate value from
unfree-redistributable because not everybody
cares whether firmware is free.