- **If it’s a _terminal emulator_:**
- `applications/terminal-emulators` (e.g. `alacritty` or `rxvt` or `termite`)
- **If it’s a _file manager_:**
- `applications/file-managers` (e.g. `mc` or `ranger` or `pcmanfm`)
- **If it’s for _video playback / editing_:**
- `applications/video` (e.g. `vlc`)
- **If it’s for _graphics viewing / editing_:**
- `applications/graphics` (e.g. `gimp`)
- **If it’s for _networking_:**
- **If it’s a _mailreader_:**
- `applications/networking/mailreaders` (e.g. `thunderbird`)
- **If it’s a _newsreader_:**
- `applications/networking/newsreaders` (e.g. `pan`)
- **If it’s a _web browser_:**
- `applications/networking/browsers` (e.g. `firefox`)
- **Else:**
- `applications/networking/misc`
- **Else:**
- `applications/misc`
**If it’s _data_ (i.e., does not have a straight-forward executable semantics):**
- **If it’s a _font_:**
- `data/fonts`
- **If it’s an _icon theme_:**
- `data/icons`
- **If it’s related to _SGML/XML processing_:**
- **If it’s an _XML DTD_:**
- `data/sgml+xml/schemas/xml-dtd` (e.g. `docbook`)
- **If it’s an _XSLT stylesheet_:**
(Okay, these are executable...)
- `data/sgml+xml/stylesheets/xslt` (e.g. `docbook-xsl`)
- **If it’s a _theme_ for a _desktop environment_, a _window manager_ or a _display manager_:**
- `data/themes`
**If it’s a _game_:**
- `games`
**Else:**
- `misc`
</details>
# Conventions
The key words _must_, _must not_, _required_, _shall_, _shall not_, _should_, _should not_, _recommended_, _may_, and _optional_ in this section are to be interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119). Only _emphasized_ words are to be interpreted in this way.
## Package naming
In Nixpkgs, there are generally three different names associated with a package:
- The `pname` attribute of the derivation. This is what most users see, in particular when using `nix-env`.
- The attribute name used for the package in the [`pkgs/by-name` structure](./by-name/README.md) or in [`all-packages.nix`](./top-level/all-packages.nix), and when passing it as a dependency in recipes.
- The filename for (the directory containing) the Nix expression.
Most of the time, these are the same. For instance, the package `e2fsprogs` has a `pname` attribute `"e2fsprogs"`, is bound to the attribute name `e2fsprogs` in `all-packages.nix`, and the Nix expression is in `pkgs/os-specific/linux/e2fsprogs/default.nix`.
Follow these guidelines:
- For the `pname` attribute:
- It _should_ be identical to the upstream package name.
- It _must not_ contain uppercase letters.
Example: Use `"mplayer"` instead of `"MPlayer"`
- For the package attribute name:
- It _must_ be a valid identifier in Nix.
- If the `pname` starts with a digit, the attribute name _should_ be prefixed with an underscore. Otherwise the attribute name _should not_ be prefixed with an underline.
Example: The corresponding attribute name for `0ad` should be `_0ad`.
- New attribute names _should_ be the same as the value in `pname`.
Hyphenated names _should not_ be converted to [snake case](https://en.wikipedia.org/wiki/Snake_case) or [camel case](https://en.wikipedia.org/wiki/Camel_case).
This was done historically, but is not necessary any more.
[The Nix language allows dashes in identifiers since 2012](https://github.com/NixOS/nix/commit/95c74eae269b2b9e4bc514581b5caa1d80b54acc).
- If there are multiple versions of a package, this _should_ be reflected in the attribute names in `all-packages.nix`.
Example: `json-c_0_9` and `json-c_0_11`
If there is an obvious “default” version, make an extra attribute.
Example: `json-c = json-c_0_9;`
See also [versioning][versioning].
## Versioning
These are the guidelines the `version` attribute of a package:
- It _must_ start with a digit. This is required for backwards-compatibility with [how `nix-env` parses derivation names](https://nix.dev/manual/nix/latest/command-ref/nix-env#selectors).