2020-11-27 13:41:09 +01:00
|
|
|
# shellcheck shell=bash
|
|
|
|
|
|
|
|
# Setup hook that installs specified desktop items.
|
|
|
|
#
|
|
|
|
# Example usage in a derivation:
|
|
|
|
#
|
|
|
|
# { …, makeDesktopItem, copyDesktopItems, … }:
|
|
|
|
#
|
|
|
|
# let desktopItem = makeDesktopItem { … }; in
|
|
|
|
# stdenv.mkDerivation {
|
|
|
|
# …
|
|
|
|
# nativeBuildInputs = [ copyDesktopItems ];
|
|
|
|
#
|
|
|
|
# desktopItems = [ desktopItem ];
|
|
|
|
# …
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# This hook will copy files which are either given by full path
|
|
|
|
# or all '*.desktop' files placed inside the 'share/applications'
|
|
|
|
# folder of each `desktopItems` argument.
|
|
|
|
|
|
|
|
postInstallHooks+=(copyDesktopItems)
|
|
|
|
|
|
|
|
copyDesktopItems() {
|
|
|
|
if [ "${dontCopyDesktopItems-}" = 1 ]; then return; fi
|
|
|
|
|
|
|
|
if [ -z "$desktopItems" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2022-03-21 16:25:12 +01:00
|
|
|
applications="${!outputBin}/share/applications"
|
2020-11-27 13:41:09 +01:00
|
|
|
for desktopItem in $desktopItems; do
|
|
|
|
if [[ -f "$desktopItem" ]]; then
|
2022-03-21 16:25:12 +01:00
|
|
|
echo "Copying '$desktopItem' into '${applications}'"
|
|
|
|
install -D -m 444 -t "${applications}" "$desktopItem"
|
2020-11-27 13:41:09 +01:00
|
|
|
else
|
|
|
|
for f in "$desktopItem"/share/applications/*.desktop; do
|
2022-03-21 16:25:12 +01:00
|
|
|
echo "Copying '$f' into '${applications}'"
|
|
|
|
install -D -m 444 -t "${applications}" "$f"
|
2020-11-27 13:41:09 +01:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|