pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / build-support / setup-hooks / copy-desktop-items.sh
blob313ebc98034457c694778127a317fc05fa0018e7
1 # shellcheck shell=bash
3 # Setup hook that installs specified desktop items.
5 # Example usage in a derivation:
7 # { …, makeDesktopItem, copyDesktopItems, … }:
9 # let desktopItem = makeDesktopItem { … }; in
10 # stdenv.mkDerivation {
11 # …
12 # nativeBuildInputs = [ copyDesktopItems ];
14 # desktopItems = [ desktopItem ];
15 # …
16 # }
18 # This hook will copy files which are either given by full path
19 # or all '*.desktop' files placed inside the 'share/applications'
20 # folder of each `desktopItems` argument.
22 postInstallHooks+=(copyDesktopItems)
24 copyDesktopItems() {
25 if [ "${dontCopyDesktopItems-}" = 1 ]; then return; fi
27 if [ -z "$desktopItems" ]; then
28 return
31 applications="${!outputBin}/share/applications"
32 for desktopItem in $desktopItems; do
33 if [[ -f "$desktopItem" ]]; then
34 echo "Copying '$desktopItem' into '${applications}'"
35 install -D -m 444 -t "${applications}" "$desktopItem"
36 else
37 for f in "$desktopItem"/share/applications/*.desktop; do
38 echo "Copying '$f' into '${applications}'"
39 install -D -m 444 -t "${applications}" "$f"
40 done
42 done