chromium: fix unsubstituted placeholders in .desktop

like `@@EXTRA_DESKTOP_ENTRIES@@` and `@@URI_SCHEME@@` and add a simple
check to prevent this from happening again.
This commit is contained in:
emilylange
2026-01-18 22:45:25 +01:00
parent ef696c6a60
commit c993742d9d
@@ -62,19 +62,20 @@ mkChromiumDerivation (base: rec {
$out/share/applications/chromium-browser.desktop
substituteInPlace $out/share/applications/chromium-browser.desktop \
--replace "@@MENUNAME@@" "Chromium" \
--replace "@@PACKAGE@@" "chromium" \
--replace "Exec=/usr/bin/@@USR_BIN_SYMLINK_NAME@@" "Exec=chromium"
# Append more mime types to the end
sed -i '/^MimeType=/ s,$,x-scheme-handler/webcal;x-scheme-handler/mailto;x-scheme-handler/about;x-scheme-handler/unknown,' \
$out/share/applications/chromium-browser.desktop
--replace-fail "@@MENUNAME@@" "Chromium" \
--replace-fail "@@PACKAGE@@" "chromium" \
--replace-fail "/usr/bin/@@USR_BIN_SYMLINK_NAME@@" "chromium" \
--replace-fail "@@URI_SCHEME@@" "x-scheme-handler/chromium;" \
--replace-fail "@@EXTRA_DESKTOP_ENTRIES@@" ""
# See https://github.com/NixOS/nixpkgs/issues/12433
sed -i \
-e '/\[Desktop Entry\]/a\' \
-e 'StartupWMClass=chromium-browser' \
$out/share/applications/chromium-browser.desktop
substituteInPlace $out/share/applications/chromium-browser.desktop \
--replace-fail "[Desktop Entry]" "[Desktop Entry]''\nStartupWMClass=chromium-browser"
if grep -F '@@' $out/share/applications/chromium-browser.desktop ; then
echo "error: chromium-browser.desktop contains unsubstituted placeholders" >&2
exit 1
fi
'';
passthru = { inherit sandboxExecutableName; };