Skip to content
Permalink
Browse files

dbus

  • Loading branch information
peterhoeg committed May 15, 2018
1 parent 6db7f92 commit ff571e4198689b2d42a11bd54d31328c8eba5534
@@ -4,11 +4,12 @@
akonadi-contacts, gnupg1, karchive, kcodecs, kcontacts, kcoreaddons,
kcrash, kdbusaddons, kiconthemes, kjobwidgets, kio, knotifications, kservice,
ktextwidgets, kxmlgui, kwidgetsaddons, kwindowsystem, qgpgme,
makeUserService, userServiceHook
}:

mkDerivation {
name = "kgpg";
nativeBuildInputs = [ extra-cmake-modules kdoctools makeWrapper ];
nativeBuildInputs = [ extra-cmake-modules kdoctools makeWrapper userServiceHook ];
buildInputs = [
akonadi-contacts gnupg1 karchive kcodecs kcontacts kcoreaddons kcrash
kdbusaddons ki18n kiconthemes kjobwidgets kio knotifications kservice
@@ -1,4 +1,5 @@
{ stdenv, fetchurl }:
{ stdenv, fetchurl,
makeUserService, userServiceHook }:

stdenv.mkDerivation rec {
name = "hello-2.10";
@@ -8,17 +9,26 @@ stdenv.mkDerivation rec {
sha256 = "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i";
};

nativeBuildInputs = [ userServiceHook ];

userService = makeUserService {
name = "hello";
dbus = "org.gnu.hello";
exec = "bin/hello";
description = "Hello World!";
};

doCheck = true;

meta = {
meta = with stdenv.lib; {
description = "A program that produces a familiar, friendly greeting";
longDescription = ''
GNU Hello is a program that prints "Hello, world!" when you run it.
It is fully customizable.
'';
homepage = http://www.gnu.org/software/hello/manual/;
license = stdenv.lib.licenses.gpl3Plus;
maintainers = [ stdenv.lib.maintainers.eelco ];
platforms = stdenv.lib.platforms.all;
license = licenses.gpl3Plus;
maintainers = with maintainers; [ eelco ];
platforms = platforms.all;
};
}
@@ -16,6 +16,7 @@
, sshfs
, makeWrapper
, kwayland
, makeUserService, userServiceHook
}:

stdenv.mkDerivation rec {
@@ -34,10 +35,19 @@ stdenv.mkDerivation rec {
qca-qt5 qtx11extras makeWrapper kwayland
];

nativeBuildInputs = [ extra-cmake-modules kdoctools ];
nativeBuildInputs = [ extra-cmake-modules kdoctools userServiceHook ];

userService = makeUserService {
name = "kdeconnect";
description = "KDE Connect";
dbus = "org.kde.kdeconnectd";
exec = "@out@/lib/libexec/kdeconnectd";
};

postInstall = ''
wrapProgram $out/lib/libexec/kdeconnectd --prefix PATH : ${lib.makeBinPath [ sshfs ]}
for f in ${userService}/* ; do
install -Dm644 $f $out/lib/systemd/user/$(basename $f .service).service
'';

enableParallelBuilding = true;
@@ -0,0 +1,45 @@
{ stdenv, lib, systemd, writeScript, procps ? null, qt5 ? null }:

{ name
, description
, dbus ? ""
, exec
, environment ? {}
, kdeApp ? false
}:

let
preKde = name: dbus: exec: writeScript "pre-kde-service.sh" ''
#!${stdenv.shell} -eu
# ${lib.getBin systemd}/bin/systemctl --user import-environment QT_SCREEN_SCALE_FACTORS QT_QUICK_CONTROLS_STYLE
# kill non-dbus/service spawned binaries
${lib.getBin qt5.qttools}/bin/qdbus ${dbus} / ${dbus}.main.quit || true
${lib.optionalString stdenv.isLinux ''
${lib.getBin procps}/bin/pkill ${exec} || true
''}
'';

in stdenv.mkDerivation {
name = "${name}.services";
buildCommand = ''
mkdir -p $out
cat > $out/${name}.service <<EOF
[Unit]
Description=${description}
[Service]
${lib.optionalString kdeApp ''
Environment="QT_PLUGIN_PATH="/run/current-system/sw/${qt5.qtbase.qtPluginPrefix}"
Environment="QML2_IMPORT_PATH="/run/current-system/sw/${qt5.qtbase.qtQmlPrefix}"
ExecStartPre=-${preKde name dbus exec}
''}
${lib.optionalString (!(dbus == "")) ''
Type=${if (dbus == "") then "simple" else "dbus"}
BusName=${dbus}
''}
ExecStart=@out@/${exec}
EOF
'';
}
@@ -0,0 +1,26 @@
preInstallPhases+=" userServicePhase"

patchService() {
mkdir -p $out/lib/systemd/user
for f in $out/*.service ; do
substitute $f $out/lib/systemd/user/$(basename $f .service).service \
--subst-var out
done
}

userServicePhase() {
runHook preUserService

if [[ ${#userServices[@]} -gt 0 ]]; then
echo "multiple services defined"
for f in ${userServices[@]} ; do
patchService $f
done
fi
if [[ -n "${userService}" ]]; then
echo "single service defined"
patchService $userService
fi

runHook postUserService
}
@@ -1,17 +1,29 @@
{
mkDerivation,
extra-cmake-modules, kdoctools,
libpthreadstubs,
bluez-qt, kactivities, kauth, kconfig, kdbusaddons, kdelibs4support,
kglobalaccel, ki18n, kidletime, kio, knotifyconfig, kwayland, libkscreen,
networkmanager-qt, plasma-workspace, qtx11extras, solid, udev
networkmanager-qt, plasma-workspace, qtx11extras, solid, udev,
makeUserService, userServiceHook
}:

mkDerivation {
mkDerivation rec {
name = "powerdevil";
nativeBuildInputs = [ extra-cmake-modules kdoctools ];

nativeBuildInputs = [ extra-cmake-modules kdoctools userServiceHook ];

buildInputs = [
kconfig kdbusaddons knotifyconfig solid udev bluez-qt kactivities kauth
kdelibs4support kglobalaccel ki18n kio kidletime kwayland libkscreen
networkmanager-qt plasma-workspace qtx11extras
libpthreadstubs
];

userService = makeUserService {
name = "woot";
dbus = "fef.fefe.fefe";
exec = "@out@/bin/woot";
description = "fefef";
};
}
@@ -83,6 +83,10 @@ with pkgs;
{ name = "auto-patchelf-hook"; deps = [ file ]; }
../build-support/setup-hooks/auto-patchelf.sh;

userServiceHook = makeSetupHook
{ name = "user-service-hook"; deps = [ ]; }
../build-support/setup-hooks/user-service.sh;

ensureNewerSourcesHook = { year }: makeSetupHook {}
(writeScript "ensure-newer-sources-hook.sh" ''
postUnpackHooks+=(_ensureNewerSources)
@@ -321,6 +325,8 @@ with pkgs;

makeDesktopItem = callPackage ../build-support/make-desktopitem { };

makeUserService = callPackage ../build-support/make-userservice { };

makeAutostartItem = callPackage ../build-support/make-startupitem { };

makeInitrd = { contents, compressor ? "gzip -9n", prepend ? [ ] }:

0 comments on commit ff571e4

Please sign in to comment.
You can’t perform that action at this time.