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
nixos gerrit module #82929
nixos gerrit module #82929
Conversation
lib/generators.nix
Outdated
toGitINI = attrs: | ||
with builtins; | ||
let | ||
# create [section "subsection"] keys from "section.subsection" attrset names |
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 don't particularly approve of the in-band signalling here. I'd rather have #82137's style of section generation.
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 wasn't sure if there would be other sections with that type of notation. At the moment the nixos module only configures gerrit.config. I had in mind that it could also be used to generate the other config files. For example I have this one:
its/actions-its-jira.config
# https://gerrit.googlesource.com/plugins/its-base/+/master/src/main/resources/Documentation/config-rulebase-common.md
[rule "open"]
event-type = patchset-created
action = add-standard-comment
[rule "merged"]
event-type = change-merged
action = add-standard-comment
[rule "abandoned"]
event-type = change-abandoned
action = add-standard-comment
[rule "restored"]
event-type = change-restored
action = add-standard-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.
Note that I'm not complaining about the module options themselves — I'm quite happy with the new input format, and had been intending to refactor pluginSettings
away myself. My problem here is with the in-band signalling inside the formatting 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.
My bad, I am not familiar with the meaning of "in-band signalling". Did you mean that the comment should be moved up to the function definition? If yes then I agree :)
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.
fixed
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.
By "in-band signalling", I mean that data and framing information aren't kept separate — I should be able to express an attribute named "foo.bar"
distinctly from a nested attribute set foo.bar
. Just joining and splitting the strings without an escaping mechanism doesn't work for that. My prior implementation did not have this issue.
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.
Hmm ok. I will take another look on monday then and make another PR
@edef1c what do you think of the state of this PR? I think it needs some more documentation but am afraid to touch the XML :) |
I added a NixOS vm test which pokes both HTTP and SSH ports. It'd be really nice if we could exercise the API a bit and actually run some commands through the ssh CLI, but other than setting |
This code was taken from the home-manager project.
Co-authored-by: edef <edef@edef.eu> Co-authored-by: Florian Klink <flokli@flokli.de>
multipleType = either primitiveType (listOf primitiveType); | ||
sectionType = lazyAttrsOf multipleType; | ||
supersectionType = lazyAttrsOf (either multipleType sectionType); | ||
in lazyAttrsOf supersectionType; |
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.
lazyAttrsOf
should ideally only be used if either mkIf false
definitions don't make sense (which isn't the case here), or if such definitions are handled with an emptyValue
that then gets filtered out (e.g. by using lazyAttrsOf (nullOr ...)
, then filtering out null
's before generating the file). Because this isn't done here, the following will error:
{
services.gerrit.settings.foo.bar = mkIf false 10;
}
error: The option `services.gerrit.settings.foo.bar' is used but not defined.
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.
Or alternatively just using attrsOf
instead (which then doesn't support values to depend on other values, which is probably fine here)
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.
So just replace all the lazyAttrsOf
with attrsOf
? I must admit that I cargo-culted this and don't have a good understanding of these distinctions even after your explanation.
Motivation for this change
A convenient way to manage gerrit on a NixOS machine.
This PR also adds a git config generator in the lib/ folder.
This PR was highly inspired by #82137
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)