···11+# shellcheck shell=bash
22+33+# Setup hook that installs specified desktop items.
44+#
55+# Example usage in a derivation:
66+#
77+# { …, makeDesktopItem, copyDesktopItems, … }:
88+#
99+# let desktopItem = makeDesktopItem { … }; in
1010+# stdenv.mkDerivation {
1111+# …
1212+# nativeBuildInputs = [ copyDesktopItems ];
1313+#
1414+# desktopItems = [ desktopItem ];
1515+# …
1616+# }
1717+#
1818+# This hook will copy files which are either given by full path
1919+# or all '*.desktop' files placed inside the 'share/applications'
2020+# folder of each `desktopItems` argument.
2121+2222+postInstallHooks+=(copyDesktopItems)
2323+2424+copyDesktopItems() {
2525+ if [ "${dontCopyDesktopItems-}" = 1 ]; then return; fi
2626+2727+ if [ -z "$desktopItems" ]; then
2828+ return
2929+ fi
3030+3131+ for desktopItem in $desktopItems; do
3232+ if [[ -f "$desktopItem" ]]; then
3333+ echo "Copying '$f' into '$out/share/applications'"
3434+ install -D -m 444 -t "$out"/share/applications "$f"
3535+ else
3636+ for f in "$desktopItem"/share/applications/*.desktop; do
3737+ echo "Copying '$f' into '$out/share/applications'"
3838+ install -D -m 444 -t "$out"/share/applications "$f"
3939+ done
4040+ fi
4141+ done
4242+}