Home Explore Blog Models CI



nixpkgs

4th chunk of `pkgs/README.md`
ef65afa7ad2b779c58452de64092829dcb6577a3d42dfe910000000100000fa7
   - buildMozillaMach: [`pkgs/build-support/build-mozilla-mach/default.nix`](./build-support/build-mozilla-mach/default.nix).
     A reusable build function for Firefox, Thunderbird and Librewolf.

   - JDiskReport, a Java utility: [`pkgs/by-name/jd/jdiskreport/package.nix`](./by-name/jd/jdiskreport/package.nix).
     Nixpkgs doesn’t have a decent `stdenv` for Java yet so this is pretty ad-hoc.

   - XML::Simple, a Perl module: [`pkgs/top-level/perl-packages.nix`](top-level/perl-packages.nix) (search for the `XMLSimple` attribute).
     Most Perl modules are so simple to build that they are defined directly in `perl-packages.nix`; no need to make a separate file for them.

   - Discord Game SDK: [`pkgs/by-name/di/discord-gamesdk/package.nix`](./by-name/di/discord-gamesdk/package.nix).
     Shows how binary-only packages can be supported.
     In particular, the `autoPatchelfHook` is used to set the RUNPATH and ELF interpreter of the executables so that the right libraries are found at runtime.

   Some notes:

   - Add yourself as the maintainer of the package.

     - If this is your first time contributing (welcome!), [add yourself to the maintainers list](../maintainers/README.md#how-to-become-a-maintainer) in a separate commit.

   - All other [`meta`](https://nixos.org/manual/nixpkgs/stable/#chap-meta) attributes are optional, but it’s still a good idea to provide at least the `description`, `homepage` and [`license`](https://nixos.org/manual/nixpkgs/stable/#sec-meta-license).

   - The exact syntax and semantics of the Nix expression language, including the built-in functions, are [Nix language reference](https://nixos.org/manual/nix/stable/language/).

5. To test whether the package builds, run the following command from the root of the nixpkgs source tree:

   ```ShellSession
   $ nix-build -A some-package
   ```

   where `some-package` should be the package name.
   You may want to add the flag `-K` to keep the temporary build directory in case something fails.
   If the build succeeds, a symlink `./result` to the package in the Nix store is created.

6. If you want to install the package into your profile (optional), do

   ```ShellSession
   $ nix-env -f . -iA libfoo
   ```

7. Optionally commit the new package and open a pull request [to nixpkgs](https://github.com/NixOS/nixpkgs/pulls), or use [the Patches category](https://discourse.nixos.org/t/about-the-patches-category/477) on Discourse for sending a patch without a GitHub account.

## Commit conventions

- Make sure you read about the [commit conventions](../CONTRIBUTING.md#commit-conventions) common to Nixpkgs as a whole.

- Format the commit messages in the following way:

  ```
  (pkg-name): (from -> to | init at version | refactor | etc)

  (Motivation for change. Link to release notes. Additional information.)
  ```

  Examples:

  * nginx: init at 2.0.1
  * firefox: 54.0.1 -> 55.0

    https://www.mozilla.org/en-US/firefox/55.0/releasenotes/

(using "→" instead of "->" is also accepted)

Using the `(pkg-name):` prefix is important beyond just being a convention: it queues automatic builds by CI.
More sophisticated prefixes are also possible:

| Message                                                                  | Automatic Builds                                           |
|--------------------------------------------------------------------------|------------------------------------------------------------|
| `vim: 1.0.0 -> 2.0.0`                                                    | `vim`                                                      |
| `vagrant: fix dependencies for version 2.0.2`                            | `vagrant`                                                  |
| `python3{9,10}Packages.requests: 1.0.0 -> 2.0.0`                         | `python39Packages.requests`, `python310Packages.requests`  |
| `python312.pkgs.numpy,python313.pkgs.scipy: fix build`                   | `python312.pkgs.numpy` , `python313.pkgs.scipy`            |

Title: Nixpkgs Package Contribution: Examples, Testing, and Commit Guidelines
Summary
This chunk concludes the examples of `package.nix` files, showcasing reusable build functions (like `buildMozillaMach`), ad-hoc Java setups (`JDiskReport`), Perl modules within a single file (`XML::Simple`), and support for binary-only packages (`Discord Game SDK` using `autoPatchelfHook`). It then provides essential notes for contributors: adding oneself as a maintainer (including first-time contributors), and optionally including `meta` attributes like `description`, `homepage`, and `license`. The document details how to test a new package using `nix-build -A some-package`, how to install it with `nix-env -f . -iA libfoo`, and how to contribute changes via GitHub pull requests or Discourse patches. Finally, it outlines Nixpkgs commit conventions, specifying a message format like `(pkg-name): (version change | init | refactor)` followed by a motivation, and explaining how specific prefixes trigger automatic CI builds for affected packages.