Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / desktops / gnustep / wrapGNUstepAppsHook.sh
blob8218ff1e7746c316563f35bc6847df89f6a3fdeb
1 if [[ -z "${__nix_wrapGNUstepAppsHook-}" ]]; then
2 __nix_wrapGNUstepAppsHook=1 # Don't run this hook more than once.
4 # Inherit arguments given in mkDerivation
5 gnustepWrapperArgs=(${gnustepWrapperArgs-})
7 gnustepConfigVars+=(
8 GNUSTEP_MAKEFILES
9 NIX_GNUSTEP_SYSTEM_APPS
10 NIX_GNUSTEP_SYSTEM_ADMIN_APPS
11 NIX_GNUSTEP_SYSTEM_WEB_APPS
12 NIX_GNUSTEP_SYSTEM_TOOLS
13 NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS
14 NIX_GNUSTEP_SYSTEM_LIBRARY
15 NIX_GNUSTEP_SYSTEM_HEADERS
16 NIX_GNUSTEP_SYSTEM_LIBRARIES
17 NIX_GNUSTEP_SYSTEM_DOC
18 NIX_GNUSTEP_SYSTEM_DOC_MAN
19 NIX_GNUSTEP_SYSTEM_DOC_INFO
22 wrapGNUstepApp() {
23 wrapProgram "$1" \
24 --set GNUSTEP_CONFIG_FILE "$out/GNUstep.conf" \
25 "${gnustepWrapperArgs[@]}"
28 ensureGNUstepConfig() (
29 if [[ -f "$out/GNUstep.conf" ]]; then
30 return
33 echo "writing GNUstep config file"
35 gsAddToSearchPath() {
36 if [[ -d "$2" && "${!1-}" != *"$2"* ]]; then
37 addToSearchPath "$1" "$2"
41 gsAddToIncludeSearchPath() {
42 local -n ref="$1"
44 if [[ -d "$2" && "${ref-}" != *"$2"* ]]; then
45 if [[ "${ref-}" != "" ]]; then
46 ref+=" "
49 ref+="$2"
53 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_APPS "$out/lib/GNUstep/Applications"
54 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_ADMIN_APPS "$out/lib/GNUstep/Applications"
55 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_WEB_APPS "$out/lib/GNUstep/WebApplications"
56 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_TOOLS "$out/bin"
57 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_ADMIN_TOOLS "$out/sbin"
58 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_LIBRARY "$out/lib/GNUstep"
59 gsAddToIncludeSearchPath NIX_GNUSTEP_SYSTEM_HEADERS "$out/include"
60 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_LIBRARIES "$out/lib"
61 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_DOC "$out/share/GNUstep/Documentation"
62 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_DOC_MAN "$out/share/man"
63 gsAddToSearchPath NIX_GNUSTEP_SYSTEM_DOC_INFO "$out/share/info"
65 for var in "${gnustepConfigVars[@]}"; do
66 if [[ -n "${!var-}" ]]; then
67 printf '%s="%s"\n' "$var" "${!var}"
69 done > "$out/GNUstep.conf"
72 # Note: $gnustepWrapperArgs still gets defined even if ${dontWrapGNUstepApps-} is set.
73 wrapGNUstepAppsHook() {
74 # skip this hook when requested
75 [[ -z "${dontWrapGNUstepApps-}" ]] || return 0
77 # guard against running multiple times (e.g. due to propagation)
78 [[ -z "$wrapGNUstepAppsHookHasRun" ]] || return 0
79 wrapGNUstepAppsHookHasRun=1
81 local targetDirs=("$prefix/bin")
82 echo "wrapping GNUstep applications in ${targetDirs[@]}"
84 for targetDir in "${targetDirs[@]}"; do
85 [[ -d "$targetDir" ]] || continue
87 while IFS= read -r -d '' file; do
88 ensureGNUstepConfig
89 echo "wrapping $file"
90 wrapGNUstepApp "$file"
91 done < <(find "$targetDir" ! -type d -executable -print0)
92 done
95 fixupOutputHooks+=(wrapGNUstepAppsHook)