Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters