Skip to content

Conversation

roberth
Copy link
Member

@roberth roberth commented Aug 6, 2025

Turn the NixOS meta.maintainers module into an independent subproject, as it is useful beyond the NixOS module class.

This will allow it to be used in Modular Services (tracking) and other places.

The new /modules directory hosts this class-generic module, and it could also host specific classes such as nixosTest (VM test mix-ins) as well, though that's not part of this PR.

It also makes the option visible in the documentation and NixOS search.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

roberth added 3 commits August 6, 2025 14:40
`maintainers.all` does not exist, and should not exist.

Neither does `alice`, but she's a metavariable.
This factors out `meta.maintainers` from NixOS `misc/meta.nix` for use in arbitrary
Module System applications.

It is useful beyond NixOS and not coupled to it, although it is currently coupled to Nixpkgs'
`lib.maintainers`.
That restriction could be lifted optionally if there's future demand.
@roberth roberth force-pushed the generic-meta-maintainers branch from 5c61d61 to 0c156a7 Compare August 6, 2025 13:03
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions backport release-25.05 Backport PR automatically labels Aug 6, 2025
@roberth roberth requested a review from nbp August 6, 2025 13:40
Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Is the intended use case to allow out-of-tree module configurations (flake-parts, home-manager, nix-darwin, treefmt-nix, nixvim, etc) to use nixpkgs' maintainer module without having to implement their own?

I'm not really familiar with modular services. Are they also a non-nixos module configuration? EDIT: it seems these modules are intended to be imported into a services submodule hosted by NixOS, nix-darwin, etc?


Q: I assume modules/ is intended to house all kinds of generic and/or non-nixos modules that end up being maintained in nixpkgs?

Without wanting to get ahead of ourselves, would it ever make sense to move the nixos modules to modules/nixos?


FYI: your "modular services" tracking link is broken. It should point to #428084 but currently points to this PR.

check = email: lib.elem email (lib.attrValues lib.maintainers);
merge =
loc: defs:
lib.listToAttrs (lib.singleton (lib.nameValuePair (lib.last defs).file (lib.last defs).value));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: this feels unnecessarily complex just to get it formatted on a single line?

Or at least, using listToAttrs with an explicit singleton feels like a code smell.

Suggested change
lib.listToAttrs (lib.singleton (lib.nameValuePair (lib.last defs).file (lib.last defs).value));
{
${(lib.last defs).file} = (lib.last defs).value;
}

I also feel like the merge function only looking at the last definition requires some explanation and/or justification, perhaps as a comment?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking closer, I see this is copied as-is from the existing impl. So this isn't really feedback on your PR, but on the existing code 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done that countless times, but thanks, it works!


maintainer = mkOptionType {
name = "maintainer";
check = email: lib.elem email (lib.attrValues lib.maintainers);
Copy link
Contributor

@MattSturgeon MattSturgeon Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already hinted at in your PR description, but having the check function tightly coupled to lib.maintainers means this option-type isn't useful to projects that have their own maintainers set.

Perhaps this should be designed similarly to mkPackageOption, such that it takes a maintainers set as a function argument?

EDIT: as you already implied, this can also be tackled later in another PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check function could be provided through an option then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Are you thinking of a meta.isMaintainer (functionTo bool) option?

Easily tested now.
Thank you Matt for this suggestion!

Co-Authored-By: Robert Hensing <robert@roberthensing.nl>
@roberth
Copy link
Member Author

roberth commented Aug 10, 2025

Q: Is the intended use case to allow out-of-tree module configurations (flake-parts, home-manager, nix-darwin, treefmt-nix, nixvim, etc) to use nixpkgs' maintainer module without having to implement their own?

They could if they wish. In flake-parts, we use a division into repositories instead, but the other projects could choose to do so if it suits them, but they are of course free to implement their own / continue to user their own.
The real reason is Modular Services.

Are they also a non-nixos module configuration?

Yes, a service module can be portable by making its systemd definitions conditional on options?systemd.

it seems these modules are intended to be imported into a services submodule hosted by NixOS, nix-darwin, etc?

Correct. I don't think nix-darwin has an implementation yet, but that is an RFC 163 goal, yes.

Q: I assume modules/ is intended to house all kinds of generic and/or non-nixos modules that end up being maintained in nixpkgs?

Correct. The directory nested inside is meant to reflect the module class, where generic/ is just a less alarming representation of the null class whose modules fit anywhere.

would it ever make sense to move the nixos modules to modules/nixos?

If we want to pull an RFC 140 by-name, then that would be a contender.
I feel like the nixos directory doesn't have quite the same degree of unnecessary chaos that pkgs did, and let's only really open that discussion after we have learned from Modular Services.

Speaking of - would could use modules/service as an alternate location for those, if tying them to a (single) package doesn't make sense.

The modules directory is based loosely on the conversation in

I'll put a little README in it.

Explain the purpose and usage of this new directory.
@wolfgangwalther
Copy link
Contributor

Maybe not material for this PR, but something to consider: Is modules/ part of NixOS or not? It sounds like it is more generic than that. As such, any documentation about it, should probably not be in the NixOS manual, but in the Nixpkgs manual instead? I guess the same applies to Modular Services in general (?).

@roberth
Copy link
Member Author

roberth commented Aug 10, 2025

Slightly off-topic, but that's ok!

You're right. I don't want to bother the docs and website folks with this yet, but in principle I agree and we should move in that direction.
For now afaict the main implementation is in NixOS so it makes sense from a UX perspective, but that should change.
We do have some wave-particle duality going on here, whether the main value is in modularity/composition or portability. If we were to widely disagree on portability, we could skip that aspect and document everything in the NixOS manual, but I don't think that's where we're heading.

Some of it definitely belongs in NixOS though, as it is one of the configuration systems that supports those service modules.

@roberth roberth force-pushed the generic-meta-maintainers branch from 48fff58 to e9f9e2d Compare August 17, 2025 18:46
@roberth
Copy link
Member Author

roberth commented Aug 17, 2025

Nixpkgs manual hint taken, because if it's not documented, it doesn't exist.
I've added a Modules section towards the bottom, after Build Helpers, but before Development.
I couldn't put them near the Module System docs, because that's in lib near the start, and I feel this should come after the bulk of package/packaging docs.

I don't want to commit scope creep, but I could add modules.generic.meta-maintainers to the flake as well?

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. labels Aug 17, 2025
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 8.has: documentation This PR adds or changes documentation labels Aug 17, 2025
@wolfgangwalther
Copy link
Contributor

Q: How does this maintainer module relate to the maintainer module in lib/tests/maintainer{s,-module}.nix? Can the latter be replaced with the former?

@roberth
Copy link
Member Author

roberth commented Aug 18, 2025

Those files check the maintainers list in lib.maintainers, but not the meta.maintainers module.

@wolfgangwalther
Copy link
Contributor

But shouldn't those two use the same data structure? Thus, wouldn't it make sense to re-use code to ensure they match?

@roberth
Copy link
Member Author

roberth commented Aug 18, 2025

Perhaps the maintainer type could be moved from test code to main code and serve a role there, but the existing checking solution works well enough for now.

@roberth
Copy link
Member Author

roberth commented Aug 20, 2025

The only remaining points are significant changes to the module, which I believe should not be part of this PR.

  • Customizing the maintainer validity check
  • Perhaps unifying this with the lib.maintainers test somehow

This suggests that the PR is ready, or do you wish to perform another round of review?

@wolfgangwalther
Copy link
Contributor

This suggests that the PR is ready, or do you wish to perform another round of review?

Note: I did not actually perform any review, I just asked myself (and you) these higher level questions. I do agree they don't have to be solved in this PR at all. I'll defer to @MattSturgeon who reviewed the code for whether it's ready or not.

Copy link
Contributor

@MattSturgeon MattSturgeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff LGTM

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 20, 2025
@roberth roberth merged commit 4d3eb94 into NixOS:master Aug 21, 2025
30 of 32 checks passed
@roberth
Copy link
Member Author

roberth commented Aug 21, 2025

Thanks!

@nixpkgs-ci

This comment has been minimized.

@roberth
Copy link
Member Author

roberth commented Aug 21, 2025

Backport failed

Label added by nixpkgs-ci account, surprisingly, but probably for some potentially valid reason.
I don't think we need a backport of this, although I wouldn't be opposed if someone did it in a month from now.

@wolfgangwalther
Copy link
Contributor

All changes in the ci/ folder should be backported, so that we can easily backport all other changes, too, without hitting conflicts.

The "modules" folder addition in ci/eval/default.nix should not be a problem to backport, even without anything else.

@roberth
Copy link
Member Author

roberth commented Aug 21, 2025

I'll do that

wolfgangwalther pushed a commit that referenced this pull request Aug 21, 2025
Reason: keep ci directory in sync
- #431450 (comment)

This requires that we have a modules directory, in which case the
easy and robust solution is to only port the addition parts of the refactor.
It's about as easy as a .keep file, but more useful.

This means that some duplication is created, but we avoid backporting the
changes to the documentation generation, which is a somewhat complex
component I'd rather not touch until these changes have been proven out
on unstable.
@mdaniels5757 mdaniels5757 added 8.has: port to stable This PR already has a backport to the stable release. and removed backport release-25.05 Backport PR automatically labels Aug 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: continuous integration Affects continuous integration (CI) in Nixpkgs, including Ofborg and GitHub Actions 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: port to stable This PR already has a backport to the stable release. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants