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/flood: init #269726

Closed
wants to merge 1 commit into from
Closed

Conversation

3JlOy-PYCCKUi
Copy link
Contributor

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/)
  • 23.11 Release Notes (or backporting 23.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.

Priorities

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 Nov 24, 2023
@3JlOy-PYCCKUi 3JlOy-PYCCKUi added the 8.has: module (new) This PR adds a module in `nixos/` label Nov 24, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 labels Nov 24, 2023
@3JlOy-PYCCKUi 3JlOy-PYCCKUi marked this pull request as draft December 1, 2023 19:43
@3JlOy-PYCCKUi 3JlOy-PYCCKUi marked this pull request as ready for review December 2, 2023 14:23
@3JlOy-PYCCKUi
Copy link
Contributor Author

@ofborg eval

Copy link
Member

@azahi azahi left a comment

Choose a reason for hiding this comment

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

If you have included tests, they also need to be specified in the package's passthru.tests attribute.

Also, Flood requires mediainfo to be present on runtime. However, I'm not sure how to properly handle this: you can try to find the call to it in the source code and patch it out there (or wrap the executable with PATH), or just add it to Path= in the systemd service.

Lastly, we probably should add asserts so that only one type of connection is specified at once, i.e. only rtorrent is allowed, not rtorrent and deluge etc. This can also be solved by adding an enable flag on each of these.

nixos/modules/services/torrent/flood.nix Outdated Show resolved Hide resolved
nixos/modules/services/torrent/flood.nix Outdated Show resolved Hide resolved
nixos/modules/services/torrent/flood.nix Outdated Show resolved Hide resolved
@azahi
Copy link
Member

azahi commented Dec 4, 2023

Oh, and you should also mention this module in the release notes for 24.05. See CONTRIBUTING.md

@3JlOy-PYCCKUi 3JlOy-PYCCKUi added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Dec 5, 2023
@rasmus-kirk
Copy link
Contributor

rasmus-kirk commented Dec 30, 2023

Just a suggestion, but maybe add a dataDir or option like with services.rtorrent.dataDir? If I have lots of services running, I much prefer configuring the stateful directories myself. Take a look at #277220 for this.

Also, do we not need to create the flood user and group in this module? Something like:

    users.users = mkIf (cfg.user == "flood") {
      flood = {
        group = cfg.group;
        isSystemUser = true;
      };
    };

    users.groups = mkIf (cfg.group == "flood") {
      flood = {};
    };

delugeAuth = addAuthOpt "de" cfg.auth.deluge;
rtorrentAuth = addAuthOpt "rt" cfg.auth.rtorrent;
qbittorrentAuth = addAuthOpt "qb" cfg.auth.qbittorrent;
transmissionAuth = addAuthOpt "tr" cfg.auth.transmission;
Copy link
Contributor

@rasmus-kirk rasmus-kirk Jan 2, 2024

Choose a reason for hiding this comment

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

Passing in secret values through options is bad practice, as they will leak out into the nix store. So this is not really ideal. Unfortunately, Flood does not seem to have any way of loading in these options declaratively without using the command line options. I am currently trying to ask on the Flood Discord if there is a current way or how a PR that addresses this would be structured.

wantedBy = [ "multi-user.target" ];
path = [ pkgs.mediainfo ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/flood ${lib.concatStringsSep " " args}";
Copy link
Contributor

Choose a reason for hiding this comment

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

The technically correct one:

Suggested change
ExecStart = "${cfg.package}/bin/flood ${lib.concatStringsSep " " args}";
ExecStart = "${cfg.package}/bin/flood ${lib.escapeShellArgs " " args}";

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I now know that the correct one is utils.escapeSystemdExecArgs.

Copy link
Contributor

@ambroisie ambroisie left a comment

Choose a reason for hiding this comment

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

Flood also supports stateful configuration of its auth/client configuration, which I might encourage using instead of creating options which leak secrets to the Nix store (though that is a very weak argument...).

@rasmus-kirk
Copy link
Contributor

Flood also supports stateful configuration of its auth/client configuration, which I might encourage using instead of creating options which leak secrets to the Nix store (though that is a very weak argument...).

Added a PR for Flood for being able to pass the command line options as a JSON as well. They also compose, so you can set qbittorrent.user = qbuser and extraConfig = ./path/to/config.json where config.json contains:

{
  "qbpass": "qbpassword"
}

options = {
services = {
flood = {
enable = lib.mkEnableOption (lib.mdDoc "Flood daemon");
Copy link
Member

Choose a reason for hiding this comment

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

lib.mdDoc is now just an alias and can be safely removed everywhere.
see d36f950 and #237557

wantedBy = [ "multi-user.target" ];
path = [ pkgs.mediainfo ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/flood ${lib.concatStringsSep " " args}";
Copy link
Member

Choose a reason for hiding this comment

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

${lib.getExe cfg.package} would be nice.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 20, 2024
@thiagokokada
Copy link
Contributor

#317530 was merged, and while this PR does brings some more features it will need to be redone based in #317530 anyway.

So closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: tests This PR has tests 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 1-10 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants