Should I upstream a flake.nix or add to nixpkgs

When I find a great new tool - I often find myself in this dilemma:
Should I add a flake.nix to the tool’s repo, or do I contribute a package to nixpkgs?

flake.nix

  • would be easily discoverable in the repo
  • set the stage for a nice devshell
  • allow to build derivation from cutting-edge main branch (or feature branch)
  • would be always up to date with the tool’s latest
  • full control for tool maintainers

nixpkgs

  • it’s easier to find for people that search the repos
  • has versioning (you would only update to releases, and not commits - or is this possible with flakes too?)
  • has some form of testing before it’s released
  • it’s a shorter command to install 🤷
  • no dependency on tool maintainers to merge (or even know about it)

Am I getting some parts wrong here?
Is there a nice trick to get out of this dilemma?

Or at least a nice way to write a flake.nix and easily add that to nixpkgs to have the best of both worlds with less effort?

I’d be greatful for any tips :slight_smile:

3 Likes

TL’DR: Contribute to nixpkgs.

If I was a FOSS maintainer, using a certain OS, probably never having heard of nix, nixpkgs, and NixOS, I would decline any PR to my software that adds any kind of nix expression, be it flake or channel based. It puts the burden of maintaining this on me, and I have no clue what it actually is. And there are many maintainers thinking like this.

The only contrib flakes that actually seem to work out are hyprland and neovim. About all other contribs are happily bitrotting along the code and make it everything but easy to just build it using nix.

10 Likes

They might be welcoming if the project uses Nix but doesn’t have a flake, but I agree on it likely not being productive to try to PR a flake to a random upstream.

That said, you can also use the flake as a stopping-off point on your way to packaging it.

For example, this December I opened up a PR that may never get triaged or merged. I went ahead and made a flake for my own use (add nix flake · abathur/multi-git-status@de0ba4d · GitHub) and put it up on a branch alongside the commit in my PR. I haven’t really decided if I want to PR it to nixpkgs or not, but I structured the flake with that in mind so that most of the work is already done if I decide to do it.

Edit: I think the situation’s a little different if you regularly contribute to the project. You can make the case that it’d make you more productive and would presumably be around to maintain it.

5 Likes

In theory this is correct, but to verify this with data I found that wasn’t quite the case by searching for PR’s adding a flake.nix and reading commentary.

Most maintainers say “I’ll add it, but you’ll have to maintain it”, at least on github.

It does seem more likely it gets maintained in nixpkgs… maybe?

2 Likes