Nixpkgs: override systemd unit file execstart for bluetooth

Created on 23 Jun 2019  Â·  3Comments  Â·  Source: NixOS/nixpkgs

Issue description

hello, I'm trying to disable a bluez plugin by appending an extra option for the execStart command for bluetooth.service, what would be correct way to do this?

I've tried something along the lines of:

  systemd.user.services.bluetooth = {
      description = "Bluetooth Service";
      serviceConfig = {
        Type = "dbus";
        BusName = "org.bluez";
        ExecStart = "${pkgs.bluez}/libexec/bluetooth/bluetoothd --noplugin=avrcp";
      };
      wantedBy = [ "bluetooth.target" ];
  };

but after a rebuild & restart, content of /etc/systemd/system/bluetooth.service still stayed the same.

on non-nix systems I am able to do this via systemctl edit --full bluetooth.service and edit the unit files directly,

any examples is appreciated!

Technical details

- system: `"x86_64-linux"`
 - host os: `Linux 5.1.11, NixOS, 19.09pre183392.83ba5afcc96 (Loris)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.2.2`
 - channels(michael): `"home-manager"`
 - channels(root): `"nixos-19.09pre183392.83ba5afcc96, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
question

Most helpful comment

We use systemd overrides for serviceConfig. If the service already has an ExecStart field, you need to clear it first, as per systemd.unit(5).

In Nix, you can achieve that by using a list

  …
  systemd.user.services.bluetooth.serviceConfig.ExecStart = [
    ""
    "${pkgs.bluez}/libexec/bluetooth/bluetoothd --noplugin=avrcp"
  ];
  …

which will result in the expected override.conf file:

…
ExecStart=
ExecStart=/nix/store/…/libexec/bluetooth/bluetoothd --noplugin=avrcp
…

All 3 comments

We use systemd overrides for serviceConfig. If the service already has an ExecStart field, you need to clear it first, as per systemd.unit(5).

In Nix, you can achieve that by using a list

  …
  systemd.user.services.bluetooth.serviceConfig.ExecStart = [
    ""
    "${pkgs.bluez}/libexec/bluetooth/bluetoothd --noplugin=avrcp"
  ];
  …

which will result in the expected override.conf file:

…
ExecStart=
ExecStart=/nix/store/…/libexec/bluetooth/bluetoothd --noplugin=avrcp
…

This sadly doesn't work for me, I keep running into either already define
or infinite recursion errors as explained here:
https://stackoverflow.com/questions/50678639/how-to-change-the-serviceconfig-of-a-service-defined-in-nixpkgs-from-configurati

There's also this PR that fixes this: #41446 but I'm stuck whilst waiting
for this to be released..

bluetooth is not a user service - it's a system service, so any kind of overrides should happen on systemd.services.bluetooth and not systemd.user.services.bluetooth.

Hi,

I deleted my comment since I managed to work around it, see here https://github.com/NixOS/nixpkgs/pull/41446

Thans for your quick reply!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-martin picture chris-martin  Â·  3Comments

lverns picture lverns  Â·  3Comments

edolstra picture edolstra  Â·  3Comments

ghost picture ghost  Â·  3Comments

spacekitteh picture spacekitteh  Â·  3Comments