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

slskd: init module #233648

Merged
merged 4 commits into from
Jul 17, 2023
Merged

slskd: init module #233648

merged 4 commits into from
Jul 17, 2023

Conversation

ppom0
Copy link
Contributor

@ppom0 ppom0 commented May 23, 2023

Description of changes

Add module for the slskd web-app. Following of #227059

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

@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 May 23, 2023
@ppom0
Copy link
Contributor Author

ppom0 commented May 23, 2023

ping @turlando @SuperSandro2000 @NickCao who already worked on slskd :)

@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/2262

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels May 23, 2023
nixos/modules/services/web-apps/slskd.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/slskd.nix Outdated Show resolved Hide resolved
nixos/modules/services/web-apps/slskd.nix Outdated Show resolved Hide resolved
@ppom0 ppom0 force-pushed the slskd-module branch 2 times, most recently from ce93d8d to 29919f8 Compare June 1, 2023 14:52
@SuperSandro2000
Copy link
Member

please fix the manual build erros

 error: option services.slskd.nginx has no description
error: option services.slskd.settings.web.url_base has no description
Treating warnings as errors. Set documentation.nixos.options.warningsAreErrors to false to ignore these warnings.
error: builder for '/nix/store/k2zr66zmg7k9spq0i59411q8mmr9amwz-options.json.drv' failed with exit code 1;

@ppom0
Copy link
Contributor Author

ppom0 commented Jul 17, 2023

fixed!

@SuperSandro2000 SuperSandro2000 merged commit 139259a into NixOS:master Jul 17, 2023
@ppom0
Copy link
Contributor Author

ppom0 commented Jul 17, 2023

damn 😍

};

# Reverse proxy configuration
services.nginx.enable = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The nginx configuration here seems very problematic: even if services.slskd.nginx.enable is false, the vhost will be created and an ACME cert attempted! These vhost settings should probably be mkDefault or maybe mkForce so that users can override them, and ACME support should definitely be an option disabled by default.

As is I cannot enable this module without unintentionally generating a new unwanted certificate for a vhost I am not using.

Copy link
Member

Choose a reason for hiding this comment

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

dolibarr has a nice way of handling nginx options that could probably fit here. values like forceSSL and enableACME can also be set to true by default, similar to the current implementation - just with a better way of changing these options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, that's problematic indeed, didn't think of it. I'll look for a fix, thanks for linking.

wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = "slskd";
Copy link
Contributor

Choose a reason for hiding this comment

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

Having configurable user/group support would be helpful for managing permissions. A good example (IMO) is netadata: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/monitoring/netdata.nix#L344-L353

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 didn't implement this, because I figured someone who'd need it would do it.

Anyway, this netdata's way of doing is very straight forward, we can include this in the next PR.

StateDirectory = "slskd";
ExecStart = "${cfg.package}/bin/slskd --app-dir /var/lib/slskd --config ${configurationYaml}";
Restart = "on-failure";
ReadOnlyPaths = map (d: builtins.elemAt (builtins.split "[^/]*(/.+)" d) 1) cfg.settings.shares.directories;
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing ReadWritePaths for downloads and incomplete folders, e.g.:

ReadWritePaths =
  (lib.optional (cfg.settings.directories.incomplete != null) cfg.settings.directories.incomplete) ++
  (lib.optional (cfg.settings.directories.downloads != null) cfg.settings.directories.downloads);

};
};

web = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing frontend authentication options? (authentication.username and authentication.password)
They can be manually entered by the users but really should be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As it's considered bad practice to save credentials into the nix store, the module provides an environmentFile option for secrets.
Can be for example

SLSKD_USERNAME=foo
SLSKD_PASSWORD=bar

I'd say if they are added, that would mainly be to document what to put in the environmentFile instead. what do you think?

description = lib.mdDoc ''
Configuration for slskd, see
[available options](https://github.com/slskd/slskd/blob/master/docs/config.md)
`APP_DIR` is set to /var/lib/slskd, where default download & incomplete directories,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason the application directory isn't configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As for slskd user, I preferred to do things incrementally, and let someone with particular needs like you make a new PR. I encourage you to do so :)

On my setup, which serves a lot of files, APP_DIR/data weights ~250 MB. I didn't think of which use cases would need this somewhere else, so I let this not configurable. However I encourage you to add more flexibility to the module.

I don't have time to address your issues in the following days. I will may be address them in ~10 days, but I'll welcome a PR instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's alright, it's not a particular issue for me. I just wondered why it was referred like a variable when it wasn't (yet). I might make a PR for these fixes this week, it was just easiest for me to share my thoughts here beforehand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. Oh, right, APP_DIR is an environment variable read by slskd, but it's hardcoded, not "variabilized", in the nix module.

It's nice to express your thoughts before making a PR, thanks. If you PR and want to add yourself to the maintainers list, you're welcome to do so.

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: 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