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

Add support for burp client/server services #48762

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Conversation

unode
Copy link
Member

@unode unode commented Oct 20, 2018

Motivation for this change

BURP is currently available in nixpkgs but provides no services

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

This is a reiteration of #30553 but basing on unode/nixpkgs:burp instead of unode/nixpkgs:master to avoid accidental mixing of work. Unfortunately GitHub doesn't allow editing the head branch.

This setup is mostly functional but there is currently a problem with validity of the SSL certificates after pairing - see grke/burp#769. If anyone wants to give this a try feedback is welcome.

@unode
Copy link
Member Author

unode commented Nov 4, 2018

Rebased to fix conflicts with master.

Pinging @tokudan @fpletz @ryantm as potential reviewers based on maintenance of burp.

type = types.str;
default = "burp";
description = ''
Run server as user
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the client or the server config?

Copy link
Member Author

Choose a reason for hiding this comment

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

The server but I'm not sure I understand what the question is getting at.


preStart = ''
if [ ! -f "${cfg.server.ssl_cert}" ]; then
mkdir -m 0750 -p ${cfg.server.libDir}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why allow group read access to that directory?

# See also https://github.com/grke/burp/issues/620
cp -f ${burp_conf} ${cfg.client.libDir}/burp.conf

# This may fail so keep trying until we get ${cfg.client.ssl_cert} from the server
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 may fail there should be some kind of throttle on it. Having this fail more than once a minute probably doesn't make any sense.

Copy link
Member Author

Choose a reason for hiding this comment

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

Any suggestion on how to achieve that? I've seen this pattern used in other services but didn't notice a throttling mechanism.

@unode
Copy link
Member Author

unode commented Nov 13, 2018

All points but the throttling have been addressed. I'm unsure how to proceed on that front.
By default systemd already gives up after repeated unsuccessful starts.

@tokudan
Copy link
Contributor

tokudan commented Nov 13, 2018

If systemd gives up or throttles on its own after a few attempts, that's probably good enough.
I wasn't aware that systemd does that, if the service is set to restart automatically.

Looks good to me. I think it's ready for merge.

@infinisil
Copy link
Member

infinisil commented Jan 28, 2019

Not sure what I think of adding another 50+ options. Every options currently deincreases evaluation time for all NixOS users (whether they use the options or not), lots of options aren't very maintainable (upstream defaults and options change).

As an alternative, check out what I did in #45470, and try to apply the same strategy to this PR. This can reduce the option count to a minimum while still being able to set all current and future config values conveniently, but giving up having them all documented and type checked by the module system.

@unode
Copy link
Member Author

unode commented Jan 28, 2019

Every options currently decreases evaluation time for all NixOS users

I'm guessing you mean "increases" there 😀 otherwise this would actually be a good thing.

I was not aware of this being an issue. Most of the options aren't actually required to start the service.
I could very easily move everything non-essential to extraConfig.

As for the solution you linked, was that a one-off or is this a pattern that is growing in popularity?

@infinisil
Copy link
Member

I'm guessing you mean "increases" there grinning otherwise this would actually be a good thing.

Yes thanks, fixed now :)

I could very easily move everything non-essential to extraConfig.

That would be fine too by me

As for the solution you linked, was that a one-off or is this a pattern that is growing in popularity?

Well, I'm very much a favor of this approach, but I've only seen it used a couple other times, it's not very popular. I'm encouraging people to use it though. I'm thinking about writing some nixpkgs tooling to make writing such config options easier, by providing standard types and converters for common config file formats like JSON/YAML/INI. I've also started writing some general guidelines for writing NixOS services which should limit the amount of options one needs to use and increase code reuse.

@pstn
Copy link
Contributor

pstn commented Jul 18, 2019

@infinisil What pattern are you talking off exactly? Is it documented? I'm willing to put some time in to get this merged.

@tokudan
Copy link
Contributor

tokudan commented Jul 18, 2019

I believe one of the issues is that burp's config looks like an INI file, but isn't. It must support multiple lines with the same key for some options like "keep". So this would need a special converter.
So the question is actually: Do we want a module that's basically ready to merge or do we reject it and ask for a rewrite of a special converter that's a lot more complicated than just having some additional options.
I think merging the options is better.

@infinisil
Copy link
Member

I've since opened an RFC for this, see NixOS/rfcs#42. I'm currently in the process of rewriting it to address the discussions.

The second part of it is that it encourages people to keep option counts low. I think it's always a good idea to start with options that make sense for most people and tell users to use a structural config/settings option with a flexible type for when they need more (that's the first part of the RFC). More options can always be added later if they're really needed, in contrast options can't really be removed once added. See also here: NixOS/rfcs#42 (comment)

And while yes, the RFC isn't accepted yet (although it most likely will be eventually), and the general convenience functions aren't yet written, I'm still encouraging that approach, because it just makes so much sense. Every module I merge that doesn't adhere to that approach is a module that can't really be changed to that approach ever. So I'm not really feeling comfortable merging ones like this (which use extraConfig and have loads of options).

@unode
Copy link
Member Author

unode commented Oct 7, 2019

I've removed some non-essential options. Didn't yet manage to implement @infinisil 's suggestion above.

2 checks are now failing but this seems to be unrelated, at least the previous commit fails locally as well.

@tokudan
Copy link
Contributor

tokudan commented Mar 8, 2020

It's been some time, but with 20.03 split off, maybe this could be merged if it still works?

@unode
Copy link
Member Author

unode commented Mar 9, 2020

I've been using it on my laptop without issues ever since I opened the PR.

@stale
Copy link

stale bot commented Jun 9, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 9, 2021
@unode
Copy link
Member Author

unode commented Jun 13, 2021

I'm still using the original recipe and would like to get it merged at some point.
Will revisit once 21.05 lands on my system.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 13, 2021
@@ -346,6 +346,7 @@ in
zoneminder = 314;
paperless = 315;
#mailman = 316; # removed 2019-08-30
burp = 317;
Copy link
Member

Choose a reason for hiding this comment

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

Can we use dynamic users?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not familiar with this feature. Do you have a link I could read up on? Thanks!

Copy link
Contributor

@tokudan tokudan Jun 14, 2021

Choose a reason for hiding this comment

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

IIRC dynamic users potentially requires a chown run on start of the service, which is not practical on a big data store with potentially millions of files, so I don't think using dynamic users feasable for burp.
http://0pointer.net/blog/dynamic-users-with-systemd.html

nixos/modules/services/backup/burp.nix Outdated Show resolved Hide resolved
enable = mkEnableOption "BURP client";

frequency = mkOption {
type = types.str;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an enum?

Copy link
Member Author

@unode unode Jun 14, 2021

Choose a reason for hiding this comment

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

This translates to systemd OnCalendar time specifications. A enum may restrict more than desired.

nixos/modules/services/backup/burp.nix Outdated Show resolved Hide resolved
nixos/modules/services/backup/burp.nix Outdated Show resolved Hide resolved
nixos/modules/services/backup/burp.nix Outdated Show resolved Hide resolved
@stale
Copy link

stale bot commented Jan 9, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md and removed 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md labels Jan 9, 2022
@unode
Copy link
Member Author

unode commented Jan 9, 2022

Addressed the conflict, which is likely to reappear if new services are added.

Working fine on 21.05.

unode and others added 6 commits January 9, 2022 16:16
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
@@ -353,6 +353,7 @@ in
distcc = 321;
webdav = 322;
pipewire = 323;
burp = 324;
Copy link
Member

Choose a reason for hiding this comment

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

Static ids shouldn't be used anymore, see NixOS/rfcs#52. This was also previously discussed in #48762 (comment), but I don't think that's a problem, because no chown needs to be run in normal circumstances, since systemd reuses the same dynamic uids for users if possible.

@@ -281,6 +281,8 @@
./services/backup/btrbk.nix
./services/backup/duplicati.nix
./services/backup/duplicity.nix
./services/backup/burp.nix
./services/backup/crashplan.nix
Copy link
Member

Choose a reason for hiding this comment

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

That looks wrong

Comment on lines +9 to +13
burp_conf = pkgs.writeText "burp.conf" ''
mode = client
pidfile = /run/burp/burp.pid

port = ${toString cfg.client.port}
Copy link
Member

Choose a reason for hiding this comment

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

Already mentioned this in #48762 (comment), but by now we should really be using the approach from NixOS/rfcs#42 for this, see also #144575. By now there are a lot of NixOS modules which make use of that approach which you can use for reference. Grep for freeformType in nixpkgs to see them. You can also check out the documentation.

};
};

config = mkIf cfg.client.enable or cfg.server.enable {
Copy link
Member

Choose a reason for hiding this comment

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

or isn't a boolean operator in Nix, check out the list of operators. You meant to use || here instead. Also needs parenthesis.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 21, 2022
@arjan-s
Copy link
Contributor

arjan-s commented Dec 26, 2022

Are you still planning to work on this. @unode ? I could really use it. :)

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 26, 2022
@unode
Copy link
Member Author

unode commented Dec 29, 2022

I'm still using the original recipe and didn't get to implement the suggested approach.
Feel free to push or suggest changes. I don't think I'll be able to get to it anytime soon.

@Artturin Artturin marked this pull request as draft February 2, 2023 18:52
@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
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

9 participants