mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 22:21:26 +00:00
hooks: add moveSystemdUserUnitsHook
This hook moves systemd user service file from `lib/systemd/user` to `share/systemd/user`. This is to allow systemd to find the user services when installed into a user profile. The `lib/systemd/user` path does not work since `lib` is not in `XDG_DATA_DIRS`.
This commit is contained in:
parent
37d29394ec
commit
fbc5093649
@ -1834,6 +1834,19 @@ addEnvHooks "$hostOffset" myBashFunction
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<literal>move-systemd-user-units.sh</literal>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
This setup hook moves any systemd user units installed in the lib
|
||||
subdirectory into share. In addition, a link is provided from share to
|
||||
lib for compatibility. This is needed for systemd to find user services
|
||||
when installed into the user profile.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<literal>set-source-date-epoch-to-latest.sh</literal>
|
||||
|
@ -142,6 +142,7 @@ in
|
||||
"/share/kservices5"
|
||||
"/share/kservicetypes5"
|
||||
"/share/kxmlgui5"
|
||||
"/share/systemd"
|
||||
];
|
||||
|
||||
system.path = pkgs.buildEnv {
|
||||
|
25
pkgs/build-support/setup-hooks/move-systemd-user-units.sh
Executable file
25
pkgs/build-support/setup-hooks/move-systemd-user-units.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This setup hook, for each output, moves everything in
|
||||
# $output/lib/systemd/user to $output/share/systemd/user, and replaces
|
||||
# $output/lib/systemd/user with a symlink to
|
||||
# $output/share/systemd/user.
|
||||
|
||||
fixupOutputHooks+=(_moveSystemdUserUnits)
|
||||
|
||||
_moveSystemdUserUnits() {
|
||||
if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then return; fi
|
||||
if [ ! -e "${prefix:?}/lib/systemd/user" ]; then return; fi
|
||||
local source="$prefix/lib/systemd/user"
|
||||
local target="$prefix/share/systemd/user"
|
||||
echo "moving $source/* to $target"
|
||||
mkdir -p "$target"
|
||||
(
|
||||
shopt -s dotglob
|
||||
for i in "$source"/*; do
|
||||
mv "$i" "$target"
|
||||
done
|
||||
)
|
||||
rmdir "$source"
|
||||
ln -s "$target" "$source"
|
||||
}
|
@ -61,7 +61,10 @@ let
|
||||
]
|
||||
# FIXME this on Darwin; see
|
||||
# https://github.com/NixOS/nixpkgs/commit/94d164dd7#commitcomment-22030369
|
||||
++ lib.optional hostPlatform.isLinux ../../build-support/setup-hooks/audit-tmpdir.sh
|
||||
++ lib.optionals hostPlatform.isLinux [
|
||||
../../build-support/setup-hooks/audit-tmpdir.sh
|
||||
../../build-support/setup-hooks/move-systemd-user-units.sh
|
||||
]
|
||||
++ [
|
||||
../../build-support/setup-hooks/multiple-outputs.sh
|
||||
../../build-support/setup-hooks/move-sbin.sh
|
||||
|
Loading…
Reference in New Issue
Block a user