How to discover services?

I tried to enable Bluetooth on my system today.
The wiki had some hints and I saw that blueman-applet was available after I’ve set services.blueman.enable

I decided to try to start the blueman-applet with a systemd service as well and wrote it into my config:

However when I built it and tried to start it, it failed with the message that I had a duplicate entry for ExecStart.
I then disovered that there was already a .service file present for blueman-applet.
It wasn’t documented in man configuration.nix and I wasn’t able to find anything in the nixpkgs repo when I grepped for blueman-applet.

The question is now what the recommended way is to discover something like this?
This is not a rant or so, I’m genuinely interested in this.

Edit: In addition, how would I actually achieve to run this after login?
I was able to fix it with the following commit:

1 Like

https://search.nixos.org/options?channel=unstable&show=services.blueman.enable&from=0&size=50&sort=relevance&type=packages&query=blue

it’s quite good for seeking out services and options. I really think every service.blah.enable should have link to wiki page, or something more solid, where it has example of usage, maybe even a screenshot if it’s a GUI program.

Currently you’ll get linked to the nix definition of the service, so if you think code is documentation you’ll be fine.

sourcegraph can also be handy, for examples of other using ‘things’ in nix.

https://sourcegraph.com/search?q=context:global+lang:nix+services.blueman.enable&patternType=literal

or

https://sourcegraph.com/search?q=context:global+lang:nix+blueman&patternType=literal

make sure to use sourcegraphs ‘lang:nix’ filter. You can also filter out nixpkgs and forks , so you don’t get the definition of the service included in your search.

alos a good reference for home manager is here. Appendix A. Configuration Options

1 Like

Strong agree. There are a lot of things that come back as a package search result, with template instructions to install (by using nix-env, even worse), when really many have to be installed and enabled via the service definition.

It would be nice if a better recommendation could be given, and a list of services that use or enable the package can be linked.

The second link showed me what probably happened.
Nixos itself doesn’t have a service for blueman-applet but home-manager does.
That’s why I couldn’t find it in man configuration.nix (which is the same as using search.nixos.org AFAIK).
This can get confusing really quickly, how should one know from where a option is coming if there isn’t some sort of namespace for it.

Thanks for the help :slight_smile:

2 Likes

Yeah there could be a link to the service if one exists.

However I quickly got used to first search for options in man configuration.nix before I add packages directly to systemPackages.

There is sometimes a lack of documentation, or standard way of doing things, it’s not because we don’t care about documentation , but because nix moves so fast. A day in the nix ecosystem is like a year in others!

home-manager seems mature and well tested enough to be mainline into nixos as a first class citizen. Having users discovering it on their nix journey in a external repo , i don’t know how i feel about that.

I personally don’t mind the state of the documentation too much.
The code is often enough for me, the problem is more to find related things.
Like mentioned above when you search for a package how would you know that there is a service for it, if you don’t look at the code.
Eventually you learn that is better to look first at the options and if it doesn’t contain what you’re search then you go search for the package.
Not a pattern which is obvious when you come from other distros where the settings are only available after the user installed the package.

Integrating home-manager would be IMO a good thing since it provides a lot of features which go very well with Nixos.
I especially like the idea because when I first go started, I started with nix + home-manager which run both on unstable by default.
When I then tried to integrate it, into my Nixos setup I got an error from home-manager which complained about wrong package versions.

Hosted by Flying Circus.