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/rustic: init module #372935

Merged
merged 3 commits into from
Jan 11, 2025
Merged

nixos/rustic: init module #372935

merged 3 commits into from
Jan 11, 2025

Conversation

Ekleog
Copy link
Member

@Ekleog Ekleog commented Jan 11, 2025

This has been running smoothlessly on my 4 systems for quite a while, on both aarch64 and x86-64 linux.

Considering the complexity of the module, I'll wait for (either a very long time or) a review from another committer before landing. But I can already say I'm very happy with it personally :)

The only future work I'd see on it would be to add easy toggles to automatically run a FS-level snapshot before backing up, which I'd likely implement for ZFS and maybe BTRFS. Or maybe I'd PR that upstream directly, idk, it's not on the short-term todo-list anyway.

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/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 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.

@github-actions github-actions bot added 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/` labels Jan 11, 2025
@Ekleog Ekleog mentioned this pull request Jan 11, 2025
13 tasks
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 11, 2025
@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog labels Jan 11, 2025
@happysalada happysalada merged commit 989cafe into NixOS:master Jan 11, 2025
23 checks passed
@happysalada
Copy link
Contributor

I hope you dont mind that i merged.
Only with more usage will we get more feedback. Having had a look at the PR this looks really good, thank you for putting work into this !

@Ekleog
Copy link
Member Author

Ekleog commented Jan 11, 2025

Not at all, thank you for having reviewed and landed, and happy to see it undergo greater use than just my own! :)

@Ekleog Ekleog deleted the rustic-module branch January 11, 2025 18:22
@emilylange
Copy link
Member

Wait a minute.

This implementation calls pkgs.sudo from within units to auth against PostgreSQL, voilates primitives by calling systemctl also from within units, has fragile shell escaping and argument handling, is missing tests, wasn't done in consultation with the rustic.meta.maintainers (@NobbZ and @philipmw) and merged after ~4 hours on a "Only with more usage will we get more feedback."-basis.

Reverting.

@Ekleog
Copy link
Member Author

Ekleog commented Jan 11, 2025

For anyone looking at this, this was reverted with consensus, and will be going through a deeper review, leaving enough time for all stakeholders to comment. The new PR is at #373042

@emilylange Can you voice again your concerns on #373042, ideally pointing out specific parts of the code? I thought I had done a fine job wrt. eg. shell escaping, but I may have missed some parts of it.

Comment on lines +20 to +21
else if v ? postgres then
v.postgres
Copy link
Contributor

Choose a reason for hiding this comment

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

The integration with PostgreSQL seems overly specific. Nixpkgs has 20+ database packages; should this module grow to include them all? To me, it would make more sense for the operator to compose this module with the existing postgresqlBackup module. The latter would dump the databases on a schedule, then this one would back them up. Wdyt?

Comment on lines +57 to +60
else if o.pipeJsonInto ? command then
" --json | ${o.pipeJsonInto.command} \"$1\""
else if o.pipeJsonInto ? prometheus then
" --json | ${prometheusWriteScript o.pipeJsonInto.prometheus.nodeExporterCollectorFolder} \"$1\""
Copy link
Contributor

Choose a reason for hiding this comment

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

As with PostgreSQL, in my opinion the integration with Prometheus is overly specific for this module. There are other observability clients, such as Amazon CloudWatch Agent added after 24.11; should this module know about them all?

How easy would it be for the operator to integrate this module with Prometheus themselves using the generic constructs?

#!${pkgs.bash}/bin/bash
set -euo pipefail

TZ="" ${cfg.package}/bin/rustic backup${ifFilesArgs + ifCommandArgs + genericArgs + pipeJsonIntoCmd}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why clear TZ?

Comment on lines +217 to +221
checkProfiles = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
If enabled, checks that the generated rustic profiles are valid.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would the operator not want this?

Comment on lines +248 to +249
backups = lib.mkOption {
default = { };
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the idea that the operator can specify profiles and/or backups, with profiles being files the operator writes himself while backups is generated from a config?

@@ -99,6 +99,8 @@

- [git-worktree-switcher](https://github.com/mateusauler/git-worktree-switcher), switch between git worktrees with speed. Available as [programs.git-worktree-switcher](#opt-programs.git-worktree-switcher.enable)

- [rustic](https://github.com/rustic-rs/rustic), a Rust-based backup tool. Available as [services.rustic](#opt-services.rustic.enable).
Copy link
Contributor

Choose a reason for hiding this comment

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

As this module is quite complex, IMO it necessitates some unit tests.

@philipmw
Copy link
Contributor

Oops, I added my comments on the older PR. I copied them to the new PR.

@h7x4 h7x4 added the 8.has: module (new) This PR adds a module in `nixos/` label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants