Skip to content
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/mattermost: Clean up and modernize #208181

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

numinit
Copy link
Contributor

@numinit numinit commented Dec 29, 2022

Description of changes

Taking ideas from #198040, support more complex database configurations and better defaults like peer authentication.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@numinit
Copy link
Contributor Author

numinit commented Dec 29, 2022

See the tests for an example of how to add and enable a plugin.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-ready-for-review/3032/1619

@Kranzes
Copy link
Member

Kranzes commented Dec 29, 2022

To have a truly immutable plugins install & enable functionality we will need to patch Mattermost's source code. But for now this is fine I guess...

Comment on lines 92 to 94
(mkRemovedOptionModule [ "services" "mattermost" "matterircd" "enable" ] "This option has been removed as it shouldn't be part of the Mattermost module.")
(mkRemovedOptionModule [ "services" "mattermost" "matterircd" "package" ] "This option has been removed as it shouldn't be part of the Mattermost module.")
(mkRemovedOptionModule [ "services" "mattermost" "matterircd" "parameters" ] "This option has been removed as it shouldn't be part of the Mattermost module.")
Copy link
Member

Choose a reason for hiding this comment

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

We should move those to its own module instead.

@numinit numinit marked this pull request as draft March 5, 2023 00:43
@numinit
Copy link
Contributor Author

numinit commented Mar 5, 2023

Haven't forgotten about this. I think the strategy will be to use the current Mattermost module as a reference to re-add the missing features.

@SuperSandro2000 SuperSandro2000 removed their assignment Feb 3, 2024
@numinit numinit mentioned this pull request Feb 26, 2024
13 tasks
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 22, 2024
@numinit numinit changed the title nixos/mattermost: Refactor, support plugins nixos/mattermost: Clean up and modernize Oct 22, 2024
Based on NixOS#198040. Prioritizes backwards compatibility, including
database and plugin compatibility, while adding more sensible
defaults like database peer auth.
Comment on lines 49 to 55
userPart =
if user == null && password == null then
""
else if user != null && password != null then
escapeURL user + ":" + escapeURL password
else
escapeURL (if password != null then password else user);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is correct. This logic could produce password@host, but that would be interpreted as a username. Is it even valid to have a password and no username?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically a username (without a password) is valid. I'm interpreting a password without a username as a sort of API key usecase, though this is more for URIs in general even though not necessarily Postgres ones.

Copy link
Contributor

Choose a reason for hiding this comment

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

In a URL with apikey@host, apikey is parsed as a username, even if its function is closer to a password. If someone wants to connect to their postgres with an API key, they probably know enough about URLs to know they should use the username field.

Comment on lines 264 to 434
users.users = optionalAttrs (cfg.user == "mattermost") {
mattermost = {
group = cfg.group;
uid = config.ids.uids.mattermost;
home = cfg.statePath;
};
users.users.${cfg.user} = {
group = cfg.group;
uid = config.ids.uids.mattermost;
home = cfg.dataDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bit cleaner, but if someone did reconfigure cfg.user from the default, this isn't functionally identical. Do we just not expect anyone to have used cfg.users — in which case, why is it even an option — or is this more correct than the previous behavior?

Copy link
Contributor Author

@numinit numinit Oct 23, 2024

Choose a reason for hiding this comment

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

Thanks, I think there was a reason this was added from the blame and I'll change it back.

Edit: I'm actually not sure. It's in this diff:

7c6d253#diff-3517cc8e7468615ccea52f1b8fb62377b14733d2e0a08ae5c7d390650402b57eR149

@fpletz do you think we need this still?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I figured it out. The secret is to use uid = mkIf (cfg.user == "mattermost") config.ids.uids.mattermost; since then we auto-assign a UID if and only if the username is nonstandard. Same with gid. Without this, my tests with a nonstandard username failed because there was no user created.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how many NixOS Mattermost deployments there are or how many of them are changing the user, but suppose someone was running it as their own personal user. With the previous behavior, no user configuration is done. With the current behavior, this would cause a conflict on group and home requiring mkForce or similar.

Maybe there needs to be a release notes item to the effect of "if you run mattermost with a nonstandard user, you should watch out/review the changes"? I still have no idea whether we're breaking anyone with this or just fixing a potential bug.

nixos/modules/services/web-apps/mattermost.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/mattermost.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/mattermost.nix Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants