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

biboumi: init at 6.1 #30193

Merged
merged 3 commits into from Oct 20, 2017
Merged

biboumi: init at 6.1 #30193

merged 3 commits into from Oct 20, 2017

Conversation

woffs
Copy link
Contributor

@woffs woffs commented Oct 7, 2017

TODO: integrate config in NixOS

The config file referenced in the systemd service file is not existent atm and its options should be integrated into configuration.nix, but I am a newbie :-)

Motivation for this change

Provide my favourite XMPP IRC gateway.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • 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/)
  • Fits CONTRIBUTING.md.

description = "Modern XMPP IRC gateway";
platforms = platforms.unix;
homepage = https://lab.louiz.org/louiz/biboumi;
license = licenses.zlib;
Copy link
Member

Choose a reason for hiding this comment

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

Do you want to maintain this?

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'll add a maintainer line. Would be fine if I'd find a mate here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes and also take a look at lib/maintainers.nix

preConfigure = ''
grep -lr /etc/biboumi . | while read f
do
substituteInPlace $f --replace /etc/biboumi $out/etc/biboumi
Copy link
Member

Choose a reason for hiding this comment

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

Does makes biboumi reading its configuration always from $out or can this be overwritten via command line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the config file is a cmdline argument, but "make install" fails without this adjustment.

};

buildInputs = [ cmake libuuid expat sqlite git libiconv libidn botan2
systemd pkgconfig udns ];
Copy link
Member

Choose a reason for hiding this comment

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

How is git used during the build?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently a test suite is fetched. I don't like this, too.

Copy link
Member

Choose a reason for hiding this comment

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

It will also fail to build in sandbox builds, which is what we use on hydra. So this behavior has to be prevented.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

almost done :)

Copy link
Member

@Mic92 Mic92 Oct 7, 2017

Choose a reason for hiding this comment

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

It seems not to download anything during build. So this having git in buildInputs is fine here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine, but I already had decided to patch it away so I can enable tests. :-)

TODO: integrate config in NixOS
- fetch catch.hpp in a reproducible way
- add maintainer
- enable tests
- remove git dep
- enable parallel building
- add pandoc dep for man page
- nitpicks
@Mic92
Copy link
Member

Mic92 commented Oct 8, 2017

Only a minor thing: /bin/kill can be replaced here by ${pkgs.procps}/bin/kill

$ cat lib/systemd/system/biboumi.service
[Unit]
Description=Biboumi, XMPP to IRC gateway
Documentation=man:biboumi(1) https://biboumi.louiz.org
After=network.target
[Service]
Type=notify
ExecStart=/nix/store/8gk42zf0pd2k3p6xbd1yfglv2jqrfl4z-biboumi-6.1/bin/biboumi /nix/store/8gk42zf0pd2k3p6xbd1yfglv2jqrfl4z-biboumi-6.1/etc/biboumi/biboumi.cfg
ExecReload=/bin/kill -s USR1 $MAINPID
WatchdogSec=20
Restart=always
User=nobody
Group=nobody
[Install]
WantedBy=multi-user.target

This service could be also changed to use the new DynamicUser, but this could actually proposed to upstream.

@louiz
Copy link

louiz commented Oct 8, 2017

This service could be also changed to use the new DynamicUser, but this could actually proposed to upstream.

Would that also work for the case where the process needs to read and write into /var/lib/biboumi, to save its database?
And what are the advantages of DynamicUser?

@Mic92
Copy link
Member

Mic92 commented Oct 8, 2017

@louiz no it is not suitable, if a service stores persistent data. I had the intention that biboumi was a pure network service. DynamicUser has the advantage over using nobody, that no other service/user will have the same uid/gid. Hence you cannot expose data/resources by accident. I would not recommend nobody as user, if the service stores persistent data because a different service might be able to read/write to /var/lib/biboumi.

@Mic92
Copy link
Member

Mic92 commented Oct 8, 2017

For nixos it might be also interesting how many files, the daemon would store in this directory.
We chmod on startup the database directory and allocate static uid/gids for the username, if a services stores many files (to avoid recursive chmod).

@louiz
Copy link

louiz commented Oct 8, 2017

At the moment, biboumi only store one file here: /var/lib/biboumi/biboumi.sqlite

It’s a file created by sqlite3, storing the whole database.

This is optional (if biboumi is compiled without the sqlite3 support), that’s why it’s nobody:nobody by default, in the case where biboumi doesn’t use any database.

In the future, biboumi might also be able to use postgresql too.

- only CMakeLists.txt has to be patched regarding /etc/biboumi
- substitute /bin/kill in systemd service file
- prepare for configuring policy_directory in a future cfg file
@Mic92
Copy link
Member

Mic92 commented Oct 10, 2017

@louiz I just read that systemd can also change owners of directories with DynamicUser http://0pointer.net/blog/dynamic-users-with-systemd.html

@louiz
Copy link

louiz commented Oct 10, 2017

Thank you, that’s very interesting! I’ll probably use that in the upstream biboumi.service file.

@joachifm joachifm merged commit 916c0a6 into NixOS:master Oct 20, 2017
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.

None yet

4 participants