Patch D: install beside COSMIC, not over it

The binary went to $(bindir)/cosmic-comp, which is the distro's own
cosmic-comp. Installing this fork there replaces the compositor the stock
COSMIC session runs, and that makes installing HyprCosmic a one-way door: if
the fork fails to start, the session you would log into to fix it is now
running the same broken binary. It goes to $(libexecdir)/hyprcosmic instead,
which is where the hand-installed copy has been living all along -- this
teaches the Makefile the layout rather than inventing one.

Both sessions are meant to coexist. /usr/share/wayland-sessions holds
cosmic.desktop and hyprcosmic.desktop side by side, and the greeter offers
both; that only stays true while the two compositors occupy different paths.

The two .ron files move out of `install` for a related reason. They are
COSMIC's shared defaults, at paths the distro's cosmic-comp package already
owns, so a HyprCosmic package installing them would conflict with that package
over two files it has no reason to change -- and `uninstall` would have deleted
the stock session's keybindings on the way out. The fork reads the stock copies,
which costs nothing: a HyprCosmic session already needs the rest of COSMIC for
the greeter, the portals and the settings daemon. `install-defaults` keeps them
reachable for anyone building this fork without a COSMIC install to borrow from.

Verified by staging into a DESTDIR: the result is byte-identical to the copy
currently running from /usr/libexec/hyprcosmic/cosmic-comp.
This commit is contained in:
2026-08-10 16:38:38 +07:00
parent 6390f85eb6
commit ce3083fad2
+26 -3
View File
@@ -2,6 +2,7 @@ export prefix ?= /usr
sysconfdir ?= /etc
bindir = $(prefix)/bin
libdir = $(prefix)/lib
libexecdir ?= $(prefix)/libexec
sharedir = $(prefix)/share
BINARY = cosmic-comp
@@ -9,7 +10,7 @@ CARGO_TARGET_DIR ?= target
TARGET = debug
DEBUG ?= 0
.PHONY = all clean install uninstall vendor
.PHONY = all clean install install-defaults uninstall vendor
ifeq ($(DEBUG),0)
TARGET = release
@@ -21,7 +22,15 @@ ifneq ($(VENDOR),0)
ARGS += --offline --locked
endif
TARGET_BIN="$(DESTDIR)$(bindir)/$(BINARY)"
# HyprCosmic installs *beside* the distro's COSMIC rather than over it. Both
# sessions stay on the greeter's menu -- /usr/share/wayland-sessions holds
# cosmic.desktop and hyprcosmic.desktop at the same time -- which only works
# while this binary stays out of $(bindir)/cosmic-comp, where it would replace
# the compositor the stock session runs. A private directory is what keeps
# installing HyprCosmic from being a one-way door: if the fork misbehaves, the
# stock session is still there to log into and fix it from.
compdir ?= $(libexecdir)/hyprcosmic
TARGET_BIN="$(DESTDIR)$(compdir)/$(BINARY)"
KEYBINDINGS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.Shortcuts/v1/defaults"
TILING_EXCEPTIONS_CONF="$(DESTDIR)$(sharedir)/cosmic/com.system76.CosmicSettings.WindowRules/v1/tiling_exception_defaults"
@@ -48,8 +57,19 @@ ifeq ($(VENDOR),1)
rm -rf vendor; tar pxf vendor.tar
endif
# The binary only. The two .ron files are COSMIC's *shared* defaults, and they
# sit at paths the distro's own cosmic-comp package already owns, so installing
# them from here would make a HyprCosmic package conflict with that one over two
# files it has no reason to change. The fork reads the stock copies instead --
# which is honest, because a HyprCosmic session needs the rest of COSMIC present
# anyway for the greeter, the portals and the settings daemon.
#
# `install-defaults` keeps them reachable for anyone building this fork on its
# own, without a COSMIC install to borrow them from.
install:
install -Dm0755 "$(CARGO_TARGET_DIR)/$(TARGET)/$(BINARY)" "$(TARGET_BIN)"
install-defaults:
install -Dm0644 "data/keybindings.ron" "$(KEYBINDINGS_CONF)"
install -Dm0644 "data/tiling-exceptions.ron" "$(TILING_EXCEPTIONS_CONF)"
@@ -60,8 +80,11 @@ install-bare-session: install
install -Dm0644 "data/cosmic-comp.service" "$(DESTDIR)$(libdir)/systemd/user/cosmic-comp.service"
install -Dm0755 "data/cosmic-service" "$(DESTDIR)/$(bindir)/cosmic-service"
# Only what `install` placed. Removing KEYBINDINGS_CONF here would delete a file
# belonging to the distro's cosmic-comp, breaking the stock session on the way
# out -- the exact failure the private compdir above exists to prevent.
uninstall:
rm "$(TARGET_BIN)" "$(KEYBINDINGS_CONF)"
rm "$(TARGET_BIN)"
uninstall-bare-session:
rm "$(DESTDIR)$(sharedir)/wayland-sessions/cosmic.desktop"