-
-
Notifications
You must be signed in to change notification settings - Fork 16.7k
Factor out the NixOS meta.maintainers
module
#431450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
`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.
5c61d61
to
0c156a7
Compare
There was a problem hiding this 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.
modules/generic/meta-maintainers.nix
Outdated
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)); |
There was a problem hiding this comment.
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.
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?
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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>
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.
Yes, a service module can be portable by making its systemd definitions conditional on
Correct. I don't think nix-darwin has an implementation yet, but that is an RFC 163 goal, yes.
Correct. The directory nested inside is meant to reflect the module class, where
If we want to pull an RFC 140 by-name, then that would be a contender. Speaking of - would could use 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.
Maybe not material for this PR, but something to consider: Is |
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. Some of it definitely belongs in NixOS though, as it is one of the configuration systems that supports those service modules. |
48fff58
to
e9f9e2d
Compare
Nixpkgs manual hint taken, because if it's not documented, it doesn't exist. I don't want to commit scope creep, but I could add |
Q: How does this maintainer module relate to the maintainer module in |
Those files check the maintainers list in |
But shouldn't those two use the same data structure? Thus, wouldn't it make sense to re-use code to ensure they match? |
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. |
The only remaining points are significant changes to the module, which I believe should not be part of this PR.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff LGTM
Thanks! |
This comment has been minimized.
This comment has been minimized.
Label added by |
All changes in the The "modules" folder addition in |
I'll do that |
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.
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 asnixosTest
(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
passthru.tests
.nixpkgs-review
on this PR. See nixpkgs-review usage../result/bin/
.Add a 👍 reaction to pull requests you find important.