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 be a string.The meta-attributes of a package can be queried from the
command-line using nix-env:
$ nix-env -qa hello --json
{
"hello": {
"meta": {
"description": "A program that produces a familiar, friendly greeting",
"homepage": "http://www.gnu.org/software/hello/manual/",
"license": {
"fullName": "GNU General Public License version 3 or later",
"shortName": "GPLv3+",
"url": "http://www.fsf.org/licensing/licenses/gpl.html"
},
"longDescription": "GNU Hello is a program that prints \"Hello, world!\" when you run it.\nIt is fully customizable.\n",
"maintainers": [
"Ludovic Court\u00e8s <ludo@gnu.org>"
],
"platforms": [
"i686-linux",
"x86_64-linux",
"armv5tel-linux",
"armv7l-linux",
"mips64el-linux",
"x86_64-darwin",
"i686-cygwin",
"i686-freebsd",
"x86_64-freebsd",
"i686-openbsd",
"x86_64-openbsd"
],
"position": "/home/user/dev/nixpkgs/pkgs/applications/misc/hello/default.nix:14"
},
"name": "hello-2.9",
"system": "x86_64-linux"
}
}
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-attributesIt is expected that each meta-attribute is one of the following: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.versionPackage version.branchRelease branch. Used to specify that a package is not
going to receive updates that are not in this branch; for example, Linux
kernel 3.0 is supposed to be updated to 3.0.X, not 3.1.homepageThe package’s homepage. Example:
http://www.gnu.org/software/hello/manual/downloadPageThe page where a link to the current version can be found. Example:
http://ftp.gnu.org/gnu/hello/license
The license, or licenses, for the package. One from the attribute set
defined in
nixpkgs/lib/licenses.nix. At this moment
using both a list of licenses and a single license is valid. If the
license field is in the form of a list representation, then it means
that parts of the package are licensed differently. Each license
should preferably be referenced by their attribute. The non-list
attribute value can also be a space delimited string representation of
the contained attribute shortNames or spdxIds. The following are all valid
examples:
Single license referenced by attribute (preferred)
stdenv.lib.licenses.gpl3.
Single license referenced by its attribute shortName (frowned upon)
"gpl3".
Single license referenced by its attribute spdxId (frowned upon)
"GPL-3.0".
Multiple licenses referenced by attribute (preferred)
with stdenv.lib.licenses; [ asl20 free ofl ].
Multiple licenses referenced as a space delimited string of attribute shortNames (frowned upon)
"asl20 free ofl".
For details, see .
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. Hydra builds packages according to the
platform specified. If no platform is specified, the package does
not have prebuilt binaries. 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.updateWalkerIf set to true, the package is
tested to be updated correctly by the update-walker.sh
script without additional settings. Such packages have
meta.version set and their homepage (or
the page specified by meta.downloadPage) contains
a direct link to the package tarball.LicensesThe meta.license attribute should preferrably contain
a value from stdenv.lib.licenses defined in
nixpkgs/lib/licenses.nix,
or in-place license description of the same format if the license is
unlikely to be useful in another expression.
A few generic options are available, although it's typically better
to indicate the specific license:
freeCatch-all for free 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.