Skip to content

Fix systemd unit install directory#56

Merged
fufexan merged 1 commit intohyprwm:mainfrom
peppapig450:correct-systemd-unit-install-dir
Aug 24, 2025
Merged

Fix systemd unit install directory#56
fufexan merged 1 commit intohyprwm:mainfrom
peppapig450:correct-systemd-unit-install-dir

Conversation

@peppapig450
Copy link
Contributor

Summary

This PR fixes the installation path of the hyprsunset.service systemd user unit. Previously the build used:

install(FILES ${CMAKE_BINARY_DIR}/systemd/hyprsunset.service DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/user)

This relies on ${CMAKE_INSTALL_LIBDIR}, which on multilib systems expands to lib64. However, systemd does not look in /usr/lib64/systemd/user for user units. It only searches /usr/lib/systemd/user. This means the installed unit file would not be picked up by systemd on such systems.

This is demonstrated when building hyprsunset on Gentoo here:
attached build.log

The Fix

Instead of guessing the correct path,This PR uses the value provided by systemd’s pkg-config file, with a fallback to ${CMAKE_INSTALL_PREFIX}/lib/systemd/user if the variable is unavailable, which is the recommended approach upstream:

"At the build installation time (e.g. make install during package build), packages are recommended to install their systemd unit files in the directory returned by pkg-config systemd --variable=systemdsystemunitdir (for system services) or pkg-config systemd --variable=systemduserunitdir (for user services). "
systemd documentation


If you'd like me to tweak the commit message, provide further build logs, adjust style or do anything differently just let me know!

Installing to ${CMAKE_INSTALL_LIBDIR}/systemd/user can end up in
/usr/lib64/systemd/user on multilib systems, which systemd does not
search. Use pkg-config's systemduserunitdir instead (with a fallback
to /usr/lib/systemd/user) so the unit is always installed in the
correct location.
@vaxerski vaxerski requested a review from fufexan August 24, 2025 07:56
Copy link
Member

@fufexan fufexan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I like the extra configurable variable, we should use it in other hyprapps' CMakeLists.

@fufexan fufexan merged commit fa2f7dd into hyprwm:main Aug 24, 2025
1 check passed
@peppapig450
Copy link
Contributor Author

Glad you like it! I can go ahead and open PRs to add this to the other Hyprapps’ CMakeLists as well if that works.

@peppapig450 peppapig450 deleted the correct-systemd-unit-install-dir branch August 24, 2025 20:09
@fufexan
Copy link
Member

fufexan commented Aug 24, 2025

Would be nice if you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants