kimb.dev

It's not hard to be a nixpkgs maintainer

The computer genome project

nixpkgs is intimidating! It has to be because it’s ambitious, encoding both how to build nixos as well as any software/assets a nix daemon can ask for. If you try to clone it, git will crawl. There’s rules and hundreds of contributors.

However, it’s a peer reviwed project that relies on the labor of enthusiastic volunteers. If you’ve learned enough nix to package tools you like, they’d love your help.

Contributing to open source

I’m embarassed to say that even though I’ve enjoyed programming since the 00’s, I’d never contributed to anyone else’s open source projects. Truthfully, it’s a mix of social anxiety and laziness, and I’m realizing I need to fix that if I want to get more out of life.

When I’m nervous, I let every small frustration become a showstopper, and I want to remove that out from you. So here’s how I got myself on the maintainer’s list.

If you’ve been running NixOS and are comfortable building smaller programming projects in Nix, I recommend you do this if it sounds even a little fun!

Prerequisites

Before contributing, read CONTRIBUTING.md and maintainers/README.md for the ground rules. This guide is really just a paraphrasing of those two, plus some github forking details I never learned and had to muddle through.

This assumes you’re used to using github for personal projects, or have maybe used it to work in a private codebase. If you haven’t already, set up an ssh key with Github.

Nixpkgs also has an active Matrix chat. Sign up for it, and make sure to join any channels around packages you’d like to maintain.

Joining, step by step

For this example, let’s assume you’re named Megumin and would like to maintain the Exlosion package.

  1. Go to github and fork nixpkgs to your own account, pressing the fork button in the upper right.
  2. Make a shallow clone of your forked nixpkgs. Cloning all of nixpkgs takes forever and makes your machine process lots of diffs. Like this:
git clone git@github.com:megumin/nixpkgs.git --depth 1
  1. Make a new branch for adding yourself. git switch --create join-maintainers
  2. Add an entry for yourself in maintainers/maintainer-list.nix, in the correct alphabetical spot. You can id yourself one of several ways, but let’s do github account and email. To get your github id number, go to https://api.github.com/users/YOUR_USERNAME, and find the id field. Don’t forget to add it in alphabetical order!
1megumin = {
2  name = "Megumin";
3  email = "megumin@crimsondemons.edu";
4  github = "megumin";
5  githubId = 100000;
6};
  1. Add and commit your change like this:
git add .
git commit -am "maintainers: add megumin"
git push --set-upstream origin join-maintainers
  1. Think of a package you’d like to maintain. Some nixpkgs are missing containers, and you can help! Or, join a project even if it already has maintainers. In that package’s default.nix in nixpkgs, there’s a meta object with a maintainers field. Add your handle to it, without quotes. This tells the community you’re volunteering to help keep this package up to date and working.
 1    # Inside the fictious package nixpkgs/pkgs/magic/explosion/default.nix
 2    meta = with lib; {
 3      homepage = "https://github.com/oppenheimer/explosion";
 4      description = "Cast a large explosion, once per day. No warranty implied.";
 5      changelog = "https://github.com/oppenheimer/explosion/releases/tag/${version}";
 6      license = licenses.asl20;
 7      mainProgram = "explosion";
 8      maintainers = with maintainers; [
 9        megumin
10      ];
11    };
  1. Add and commit your change like this:
git add .
git commit -am "explosion.maintainers: add YOUR_USERNAME"
git push
  1. Go to NixOS’s nixpkgs, and click “pull requests”. Create a new pr pointing to master with YOUR_USERNAME:YOUR_PR, megumin:join-maintainers in this example. This points to your forked repo in github.
  2. Respond to feedback from the reviewers. They’re happy to have you, but they want a clean git history.
  3. If all’s good, you’ll get merged and be a part of the NixOS organization. Congratulations, and have fun making nix just a bit better.

*Special thanks to Dan Baker for encouraging me to sign up and walking me through the etiquette/practices!

Reply to this post by email ↪