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/quickwit: init #307808

Closed
wants to merge 9 commits into from
Closed

Conversation

tcheronneau
Copy link
Contributor

@tcheronneau tcheronneau commented Apr 29, 2024

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Contributor

@nh2 nh2 left a comment

Choose a reason for hiding this comment

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

@tcheronneau Great!

It needs some minor changes though, most importantly that the test actually works. The goal for that is that one can run:

NIX_PATH=nixpkgs=. nix-build --no-out-link -A quickwit.tests

To get that to work, your PR was missing a couple entries, such as in the global list of services, and the global list of tests.

I've pushed a commit for that, please take a look. (You need to squash it before final merge.)

For me the test doesn't pass yet though.

users.groups.quickwit = {};
system.activationScripts.makeQuickwitDir = ''
mkdir -p ${cfg.settings.data_dir}
chown -R quickwit:quickwit ${cfg.settings.data_dir}
Copy link
Contributor

Choose a reason for hiding this comment

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

Both paths above need quoting.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This works.
I'm testing the full setup each time (with nixos-vm).

Copy link
Contributor

@nh2 nh2 May 5, 2024

Choose a reason for hiding this comment

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

@tcheronneau The fact that it works for you doesn't make it correct.

The path needs quoting because it is incorrect otherwise.

If you set (do not try this) data_dir = "/ my folder containing a space";, the above will chown / due to lack of quoting; if the command was rm -r, this would delete your whole computer.

nixos/modules/services/search/quickwit.nix Show resolved Hide resolved
nixos/modules/services/search/quickwit.nix Outdated Show resolved Hide resolved
nixos/tests/quickwit.nix Outdated Show resolved Hide resolved
@nh2
Copy link
Contributor

nh2 commented May 4, 2024

@tcheronneau I pushed some more fixes, please take a look.

environmentFile = mkOption {
type = types.nullOr types.path;
default = null;
description = "Environment file to pass to the systemd service.";
Copy link
Contributor

Choose a reason for hiding this comment

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

Expands docs the same way other environmentFile options do

group = "quickwit";
};
users.groups.quickwit = {};
system.activationScripts.makeQuickwitDir = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that the current way to do that is with systemd.tmpfiles, see e.g.

systemd.tmpfiles.rules = [
"d /run/munin 0755 munin munin -"
"d /var/log/munin 0755 munin munin -"
"d /var/www/munin 0755 munin munin -"
"d /var/lib/munin 0755 munin munin -"
];

But do it a bit better than done there: Refer to users.users.quickwit.name instead of hardcoding the user name in multiple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum this is weird to me though it's called tmpfiles.
https://search.nixos.org/options?channel=23.11&show=systemd.tmpfiles.rules&from=0&size=50&sort=relevance&type=packages&query=systemd.tmpfiles.rules it's says it's for volatile dir and data dir is everything but volatile.

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 did like that because I saw it in another package (I don't exactly remember which one though).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hum this is weird to me though it's called tmpfiles.

I find that weird, too.

Systemd docs say this about it:

StateDirectory=, CacheDirectory=, LogsDirectory=, and ConfigurationDirectory= should be used to create directories under /var/lib/, /var/cache/, /var/log/, and /etc/.
tmpfiles.d should be used for files whose lifetime is independent of any service or requires more complicated configuration.

So indeed it seems like StateDirectory= would be better than both tmpfiles and activationScripts.

@tcheronneau
Copy link
Contributor Author

Thanks for your help I'll review all your comments this evening.

@tcheronneau tcheronneau marked this pull request as draft May 4, 2024 16:35
@tcheronneau
Copy link
Contributor Author

@tcheronneau Great!

It needs some minor changes though, most importantly that the test actually works. The goal for that is that one can run:

NIX_PATH=nixpkgs=. nix-build --no-out-link -A quickwit.tests

To get that to work, your PR was missing a couple entries, such as in the global list of services, and the global list of tests.

I've pushed a commit for that, please take a look. (You need to squash it before final merge.)

For me the test doesn't pass yet though.

This works for me.

@nh2
Copy link
Contributor

nh2 commented May 5, 2024

This works for me.

@tcheronneau You mean on the current version, right? That makes sense, because the commits I pushed fixed that. But I believe your original version (on which I wrote the comment) without commit fbf98b9 because quickwit rejected that syntax.

@tcheronneau
Copy link
Contributor Author

We're good now or is there something still to fix ?

@tcheronneau tcheronneau marked this pull request as ready for review May 6, 2024 18:36
@jpds
Copy link
Contributor

jpds commented Jun 16, 2024

I think this one was largely superseded by #317152, @tcheronneau - I've moved your test here to #320342.

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.

None yet

5 participants