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

opentracker: init module #19176

Merged
merged 1 commit into from
Oct 3, 2016
Merged

opentracker: init module #19176

merged 1 commit into from
Oct 3, 2016

Conversation

makefu
Copy link
Contributor

@makefu makefu commented Oct 2, 2016

Motivation for this change

Implements services.opentracker for easy enabling of an opentracker service via systemd.
Main motivation for the change is that the current torrent tests simply run opentracker & before starting torrent clients which is pretty crude.

Things done

@mention-bot
Copy link

@makefu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @joachifm and @offlinehacker to be potential reviewers.

let
cfg = config.services.opentracker;

out = {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the motivation for this unusual construct?

Copy link
Contributor Author

@makefu makefu Oct 3, 2016

Choose a reason for hiding this comment

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

You are right, this pattern is not as widespread in nixpkgs as i have in mind. i will change it to match the general pattern. But generally this implementation gives a better overview about the Options and Implementation which are needed both for every nixos module at the very top of the file

api = {
enable = mkEnableOption "opentracker";

package = mkOption {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To override the default opentracker package? This seems to be a general pattern in a lot of nixos modules.

Copy link
Contributor

Choose a reason for hiding this comment

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

But why would you want that in this case. That's more important than what other modules are doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To use the latest version of opentracker without the need to override the package with nixpkgs.config.packageOverrides.

Right now the nixpkgs opentracker package is 2 years (2014-08-03 vs 2016-08-02) behind the latest commit and this option provides the ability to use a more current version instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough

@@ -276,6 +276,7 @@
telegraf = 256;
gitlab-runner = 257;
postgrey = 258;
opentracker = 259;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this service need a static uid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the user

wantedBy = [ "multi-user.target" ];
restartIfChanged = true;
serviceConfig = {
Type = "simple";
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 the default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

default = "";
};

user = mkOption {
Copy link
Contributor

@joachifm joachifm Oct 2, 2016

Choose a reason for hiding this comment

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

Why would I want to run this as a different user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, the code before transfer this PR didn't use another use but i figured it would be in line with all the other modules in nixpkgs.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's probably used too much, I suspect it has proliferated mainly because it's seen in existing modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the code. It might be a good idea to have a pointer to a good sample for implementing nixos modules - https://nixos.org/nixos/manual/index.html#sec-writing-modules is pretty much the worst example tbh, it doesn't even use mkEnableOption

description = ''
Working directory of opentracker
'';
default = "/var/empty";
Copy link
Contributor

Choose a reason for hiding this comment

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

This default suggests to me that opentracker won't generate any data (it will fail/crash if it tries). Given this, why would I want to change the work directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

type = types.str;
description = ''
User which will run opentracker. by default opentracker drops all
privileges and runs in chroot after starting up as root.
Copy link
Contributor

@joachifm joachifm Oct 2, 2016

Choose a reason for hiding this comment

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

This comment indicates to me that opentracker does chrooting/privsep by itself, but that won't work with serviceConfig.User. But if it doesn't do this itself, the isolation options used below are not comparable to an ordinary chroot, making the description somewhat misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed extra user creation

@Mic92 Mic92 merged commit a9cd913 into NixOS:master Oct 3, 2016
@Mic92
Copy link
Member

Mic92 commented Oct 3, 2016

thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants