From 8ef14f80e3d4d27644dec3d6d47152ae4b40ab07 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 2 Feb 2017 00:51:16 +0300 Subject: [PATCH 1/3] systemd service: add aliases option --- nixos/modules/system/boot/systemd-lib.nix | 8 +++++++- .../modules/system/boot/systemd-unit-options.nix | 6 ++++++ nixos/modules/system/boot/systemd.nix | 16 ++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/nixos/modules/system/boot/systemd-lib.nix b/nixos/modules/system/boot/systemd-lib.nix index 997770b8bec..7dbf3b25cdb 100644 --- a/nixos/modules/system/boot/systemd-lib.nix +++ b/nixos/modules/system/boot/systemd-lib.nix @@ -159,7 +159,13 @@ rec { fi done - # Created .wants and .requires symlinks from the wantedBy and + # Create service aliases from aliases option. + ${concatStrings (mapAttrsToList (name: unit: + concatMapStrings (name2: '' + ln -sfn '${name}' $out/'${name2}' + '') unit.aliases) units)} + + # Create .wants and .requires symlinks from the wantedBy and # requiredBy options. ${concatStrings (mapAttrsToList (name: unit: concatMapStrings (name2: '' diff --git a/nixos/modules/system/boot/systemd-unit-options.nix b/nixos/modules/system/boot/systemd-unit-options.nix index 69af2398148..904e41b019f 100644 --- a/nixos/modules/system/boot/systemd-unit-options.nix +++ b/nixos/modules/system/boot/systemd-unit-options.nix @@ -52,6 +52,12 @@ in rec { description = "Units that want (i.e. depend on) this unit."; }; + aliases = mkOption { + default = []; + type = types.listOf types.str; + description = "Aliases of that unit."; + }; + }; concreteUnitOptions = sharedOptions // { diff --git a/nixos/modules/system/boot/systemd.nix b/nixos/modules/system/boot/systemd.nix index a2ee5166971..79779d3b42f 100644 --- a/nixos/modules/system/boot/systemd.nix +++ b/nixos/modules/system/boot/systemd.nix @@ -301,7 +301,7 @@ let ''; targetToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = '' [Unit] @@ -310,7 +310,7 @@ let }; serviceToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Service] @@ -330,7 +330,7 @@ let }; socketToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Socket] @@ -340,7 +340,7 @@ let }; timerToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Timer] @@ -349,7 +349,7 @@ let }; pathToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Path] @@ -358,7 +358,7 @@ let }; mountToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Mount] @@ -367,7 +367,7 @@ let }; automountToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Automount] @@ -376,7 +376,7 @@ let }; sliceToUnit = name: def: - { inherit (def) wantedBy requiredBy enable; + { inherit (def) aliases wantedBy requiredBy enable; text = commonUnitText def + '' [Slice] From 496476be4ed3d8e81213ccb7240fd91fdcf83e15 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 2 Feb 2017 00:51:39 +0300 Subject: [PATCH 2/3] bluez4: reintroduce to nixpkgs It's still needed by KDE4. It was there, just unreferenced from all-packages. --- pkgs/os-specific/linux/bluez/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/bluez/default.nix b/pkgs/os-specific/linux/bluez/default.nix index 9943a1de6d4..d0a875516fa 100644 --- a/pkgs/os-specific/linux/bluez/default.nix +++ b/pkgs/os-specific/linux/bluez/default.nix @@ -5,8 +5,8 @@ assert stdenv.isLinux; let inherit (pythonPackages) python; - pythonpath = "${pythonPackages.dbus}/lib/${python.libPrefix}/site-packages:" - + "${pythonPackages.pygobject}/lib/${python.libPrefix}/site-packages"; + pythonpath = "${pythonPackages.dbus-python}/lib/${python.libPrefix}/site-packages:" + + "${pythonPackages.pygobject2}/lib/${python.libPrefix}/site-packages"; in stdenv.mkDerivation rec { name = "bluez-4.101"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 90e44c9819a..fcb3ec9ceec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10848,6 +10848,8 @@ with pkgs; bluez5 = callPackage ../os-specific/linux/bluez/bluez5.nix { }; + bluez4 = callPackage ../os-specific/linux/bluez { }; + # Needed for LibreOffice bluez5_28 = lowPrio (callPackage ../os-specific/linux/bluez/bluez5_28.nix { }); From 4abcef2ba19a73ea212f6812b395e8e3ac698fd5 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 2 Feb 2017 00:52:12 +0300 Subject: [PATCH 3/3] bluez service: use upstream units --- nixos/modules/services/hardware/bluetooth.nix | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/nixos/modules/services/hardware/bluetooth.nix b/nixos/modules/services/hardware/bluetooth.nix index 2c271b32817..f6cf2d01d80 100644 --- a/nixos/modules/services/hardware/bluetooth.nix +++ b/nixos/modules/services/hardware/bluetooth.nix @@ -2,41 +2,9 @@ with lib; let - bluez-bluetooth = if config.services.xserver.desktopManager.kde4.enable then pkgs.bluez else pkgs.bluez5; + isBluez4 = config.services.xserver.desktopManager.kde4.enable; + bluez-bluetooth = if isBluez4 then pkgs.bluez4 else pkgs.bluez; - configBluez = { - description = "Bluetooth Service"; - serviceConfig = { - Type = "dbus"; - BusName = "org.bluez"; - ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n"; - }; - wantedBy = [ "bluetooth.target" ]; - }; - - configBluez5 = { - description = "Bluetooth Service"; - serviceConfig = { - Type = "dbus"; - BusName = "org.bluez"; - ExecStart = "${getBin bluez-bluetooth}/bin/bluetoothd -n"; - NotifyAccess="main"; - CapabilityBoundingSet="CAP_NET_ADMIN CAP_NET_BIND_SERVICE"; - LimitNPROC=1; - }; - wantedBy = [ "bluetooth.target" ]; - }; - - obexConfig = { - description = "Bluetooth OBEX service"; - serviceConfig = { - Type = "dbus"; - BusName = "org.bluez.obex"; - ExecStart = "${getBin bluez-bluetooth}/bin/obexd"; - }; - }; - - bluezConfig = if config.services.xserver.desktopManager.kde4.enable then configBluez else configBluez5; in { @@ -58,10 +26,21 @@ in config = mkIf config.hardware.bluetooth.enable { environment.systemPackages = [ bluez-bluetooth pkgs.openobex pkgs.obexftp ]; + services.udev.packages = [ bluez-bluetooth ]; + services.dbus.packages = [ bluez-bluetooth ]; - systemd.services."dbus-org.bluez" = bluezConfig; - systemd.services."dbus-org.bluez.obex" = obexConfig; + + systemd.packages = [ bluez-bluetooth ]; + + systemd.services.bluetooth = { + wantedBy = [ "bluetooth.target" ]; + aliases = [ "dbus-org.bluez.service" ]; + }; + + systemd.user.services.obex = mkIf (!isBluez4) { + aliases = [ "dbus-org.bluez.obex.service" ]; + }; };