this repo has no description

:truck: (Go) moved files from learn go with tests to a dir

+19
Go/.direnv/bin/nix-direnv-reload
···
··· 1 + #!/usr/bin/env bash 2 + set -e 3 + if [[ ! -d "/home/pedro/Projects/Languages/Go" ]]; then 4 + echo "Cannot find source directory; Did you move it?" 5 + echo "(Looking for "/home/pedro/Projects/Languages/Go")" 6 + echo 'Cannot force reload with this script - use "direnv reload" manually and then try again' 7 + exit 1 8 + fi 9 + 10 + # rebuild the cache forcefully 11 + _nix_direnv_force_reload=1 direnv exec "/home/pedro/Projects/Languages/Go" true 12 + 13 + # Update the mtime for .envrc. 14 + # This will cause direnv to reload again - but without re-building. 15 + touch "/home/pedro/Projects/Languages/Go/.envrc" 16 + 17 + # Also update the timestamp of whatever profile_rc we have. 18 + # This makes sure that we know we are up to date. 19 + touch -r "/home/pedro/Projects/Languages/Go/.envrc" "/home/pedro/Projects/Languages/Go/.direnv"/*.rc
+1
Go/.direnv/flake-inputs/97j7mjdvbxb59jnkr97qmhlkk97mnly8-source
···
··· 1 + /nix/store/97j7mjdvbxb59jnkr97qmhlkk97mnly8-source
+1
Go/.direnv/flake-inputs/bwvs5b96m5vfskwc2wxwmp3fl4xbqr2q-source
···
··· 1 + /nix/store/bwvs5b96m5vfskwc2wxwmp3fl4xbqr2q-source
+1
Go/.direnv/flake-inputs/fpr5fsl88azrdsbzjpfq2hk307bbr7cm-source
···
··· 1 + /nix/store/fpr5fsl88azrdsbzjpfq2hk307bbr7cm-source
+1
Go/.direnv/flake-inputs/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source
···
··· 1 + /nix/store/yj1wxm9hh8610iyzqnz75kvs6xl8j3my-source
+1
Go/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
···
··· 1 + /nix/store/cnxgpplhaczzqw27479hmv2abnj9sjik-nix-shell-env
+1881
Go/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
···
··· 1 + unset shellHook 2 + PATH=${PATH:-} 3 + nix_saved_PATH="$PATH" 4 + XDG_DATA_DIRS=${XDG_DATA_DIRS:-} 5 + nix_saved_XDG_DATA_DIRS="$XDG_DATA_DIRS" 6 + AR='ar' 7 + export AR 8 + AS='as' 9 + export AS 10 + BASH='/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin/bash' 11 + CC='gcc' 12 + export CC 13 + CONFIG_SHELL='/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin/bash' 14 + export CONFIG_SHELL 15 + CXX='g++' 16 + export CXX 17 + HOSTTYPE='x86_64' 18 + HOST_PATH='/nix/store/hkzgcfj86jzzpayghzvy09xpvjg4xmac-go-1.21.7/bin:/nix/store/kc58bqdmjdc6mfilih5pywprs7r7lxrw-golangci-lint-1.56.2/bin:/nix/store/x1xcjw5628crkk1pwr12y7nwbzkc3969-coreutils-9.4/bin:/nix/store/i6y16f2jzcv1g1k12qdkislh3yqk2rl7-findutils-4.9.0/bin:/nix/store/xcmwf4l5n35cislpzhbhqbnd31wwsbll-diffutils-3.10/bin:/nix/store/y1y3rml47qnh0giqd32mj07qxxqy13qg-gnused-4.9/bin:/nix/store/11b3chszacfr9liy829xqknzp3q88iji-gnugrep-3.11/bin:/nix/store/78q5np4llnqhshx72kxm7w7q31pj0v7b-gawk-5.2.2/bin:/nix/store/dxbzps4w5rikj7jdcyjcw98lk517gf0h-gnutar-1.35/bin:/nix/store/zyyb8vi6jg1swr5f34rxgi9izck2r88h-gzip-1.13/bin:/nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin/bin:/nix/store/w0q0c4jham4h0cbvi3ygydl6hrcmzn6x-gnumake-4.4.1/bin:/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin:/nix/store/8hsz6cchg5yw1wz89mab5f89k3j7l03m-patch-2.7.6/bin:/nix/store/xl7x35n2v2m398hki8q4ib235zn3hv20-xz-5.4.6-bin/bin:/nix/store/8ja6nib32kv3h9z6jwlh95b5ayma7wfx-file-5.45/bin' 19 + export HOST_PATH 20 + IFS=' 21 + ' 22 + IN_NIX_SHELL='impure' 23 + export IN_NIX_SHELL 24 + LD='ld' 25 + export LD 26 + LINENO='76' 27 + MACHTYPE='x86_64-pc-linux-gnu' 28 + NIX_BINTOOLS='/nix/store/cc92grinhsyp2mq5sxlmz06z68gz1h98-binutils-wrapper-2.40' 29 + export NIX_BINTOOLS 30 + NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' 31 + export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu 32 + NIX_BUILD_CORES='6' 33 + export NIX_BUILD_CORES 34 + NIX_CC='/nix/store/ln6zld1ia7rxddmxgbpfhrmb42rbxdw8-gcc-wrapper-13.2.0' 35 + export NIX_CC 36 + NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1' 37 + export NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu 38 + NIX_CFLAGS_COMPILE=' -frandom-seed=cnxgpplhac' 39 + export NIX_CFLAGS_COMPILE 40 + NIX_ENFORCE_NO_NATIVE='1' 41 + export NIX_ENFORCE_NO_NATIVE 42 + NIX_HARDENING_ENABLE='bindnow format fortify fortify3 pic relro stackprotector strictoverflow' 43 + export NIX_HARDENING_ENABLE 44 + NIX_LDFLAGS='-rpath /home/pedro/Projects/Languages/Go/outputs/out/lib ' 45 + export NIX_LDFLAGS 46 + NIX_NO_SELF_RPATH='1' 47 + NIX_STORE='/nix/store' 48 + export NIX_STORE 49 + NM='nm' 50 + export NM 51 + OBJCOPY='objcopy' 52 + export OBJCOPY 53 + OBJDUMP='objdump' 54 + export OBJDUMP 55 + OLDPWD='' 56 + export OLDPWD 57 + OPTERR='1' 58 + OSTYPE='linux-gnu' 59 + PATH='/nix/store/xwsq5dj63439l1pphrb76zjrididi3vn-patchelf-0.15.0/bin:/nix/store/ln6zld1ia7rxddmxgbpfhrmb42rbxdw8-gcc-wrapper-13.2.0/bin:/nix/store/cmr8qd8w64w8q0cbfc30p98z2pydc1k7-gcc-13.2.0/bin:/nix/store/ssarggxx3laydmfkq1dlv4ilcsw7phfq-glibc-2.38-44-bin/bin:/nix/store/x1xcjw5628crkk1pwr12y7nwbzkc3969-coreutils-9.4/bin:/nix/store/cc92grinhsyp2mq5sxlmz06z68gz1h98-binutils-wrapper-2.40/bin:/nix/store/p0p56gzz837fgmfd7lyisghcd7x2fdlc-binutils-2.40/bin:/nix/store/hkzgcfj86jzzpayghzvy09xpvjg4xmac-go-1.21.7/bin:/nix/store/kc58bqdmjdc6mfilih5pywprs7r7lxrw-golangci-lint-1.56.2/bin:/nix/store/x1xcjw5628crkk1pwr12y7nwbzkc3969-coreutils-9.4/bin:/nix/store/i6y16f2jzcv1g1k12qdkislh3yqk2rl7-findutils-4.9.0/bin:/nix/store/xcmwf4l5n35cislpzhbhqbnd31wwsbll-diffutils-3.10/bin:/nix/store/y1y3rml47qnh0giqd32mj07qxxqy13qg-gnused-4.9/bin:/nix/store/11b3chszacfr9liy829xqknzp3q88iji-gnugrep-3.11/bin:/nix/store/78q5np4llnqhshx72kxm7w7q31pj0v7b-gawk-5.2.2/bin:/nix/store/dxbzps4w5rikj7jdcyjcw98lk517gf0h-gnutar-1.35/bin:/nix/store/zyyb8vi6jg1swr5f34rxgi9izck2r88h-gzip-1.13/bin:/nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin/bin:/nix/store/w0q0c4jham4h0cbvi3ygydl6hrcmzn6x-gnumake-4.4.1/bin:/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin:/nix/store/8hsz6cchg5yw1wz89mab5f89k3j7l03m-patch-2.7.6/bin:/nix/store/xl7x35n2v2m398hki8q4ib235zn3hv20-xz-5.4.6-bin/bin:/nix/store/8ja6nib32kv3h9z6jwlh95b5ayma7wfx-file-5.45/bin' 60 + export PATH 61 + PS4='+ ' 62 + RANLIB='ranlib' 63 + export RANLIB 64 + READELF='readelf' 65 + export READELF 66 + SIZE='size' 67 + export SIZE 68 + SOURCE_DATE_EPOCH='315532800' 69 + export SOURCE_DATE_EPOCH 70 + STRINGS='strings' 71 + export STRINGS 72 + STRIP='strip' 73 + export STRIP 74 + XDG_DATA_DIRS='/nix/store/xwsq5dj63439l1pphrb76zjrididi3vn-patchelf-0.15.0/share' 75 + export XDG_DATA_DIRS 76 + __structuredAttrs='' 77 + export __structuredAttrs 78 + _substituteStream_has_warned_replace_deprecation='false' 79 + buildInputs='/nix/store/hkzgcfj86jzzpayghzvy09xpvjg4xmac-go-1.21.7 /nix/store/kc58bqdmjdc6mfilih5pywprs7r7lxrw-golangci-lint-1.56.2' 80 + export buildInputs 81 + buildPhase='{ echo "------------------------------------------------------------"; 82 + echo " WARNING: the existence of this path is not guaranteed."; 83 + echo " It is an internal implementation detail for pkgs.mkShell."; 84 + echo "------------------------------------------------------------"; 85 + echo; 86 + # Record all build inputs as runtime dependencies 87 + export; 88 + } >> "$out" 89 + ' 90 + export buildPhase 91 + builder='/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin/bash' 92 + export builder 93 + cmakeFlags='' 94 + export cmakeFlags 95 + configureFlags='' 96 + export configureFlags 97 + defaultBuildInputs='' 98 + defaultNativeBuildInputs='/nix/store/xwsq5dj63439l1pphrb76zjrididi3vn-patchelf-0.15.0 /nix/store/hcrhrs1mmm2q5a3rzd6xwypqgkpm13vx-update-autotools-gnu-config-scripts-hook /nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh /nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh /nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh /nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh /nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh /nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh /nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh /nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh /nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh /nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh /nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh /nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh /nix/store/wmknncrif06fqxa16hpdldhixk95nds0-strip.sh /nix/store/ln6zld1ia7rxddmxgbpfhrmb42rbxdw8-gcc-wrapper-13.2.0' 99 + depsBuildBuild='' 100 + export depsBuildBuild 101 + depsBuildBuildPropagated='' 102 + export depsBuildBuildPropagated 103 + depsBuildTarget='' 104 + export depsBuildTarget 105 + depsBuildTargetPropagated='' 106 + export depsBuildTargetPropagated 107 + depsHostHost='' 108 + export depsHostHost 109 + depsHostHostPropagated='' 110 + export depsHostHostPropagated 111 + depsTargetTarget='' 112 + export depsTargetTarget 113 + depsTargetTargetPropagated='' 114 + export depsTargetTargetPropagated 115 + doCheck='' 116 + export doCheck 117 + doInstallCheck='' 118 + export doInstallCheck 119 + dontAddDisableDepTrack='1' 120 + export dontAddDisableDepTrack 121 + declare -a envBuildBuildHooks=() 122 + declare -a envBuildHostHooks=() 123 + declare -a envBuildTargetHooks=() 124 + declare -a envHostHostHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) 125 + declare -a envHostTargetHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) 126 + declare -a envTargetTargetHooks=() 127 + declare -a fixupOutputHooks=('if [ -z "${dontPatchELF-}" ]; then patchELF "$prefix"; fi' 'if [[ -z "${noAuditTmpdir-}" && -e "$prefix" ]]; then auditTmpdir "$prefix"; fi' 'if [ -z "${dontGzipMan-}" ]; then compressManPages "$prefix"; fi' '_moveLib64' '_moveSbin' '_moveSystemdUserUnits' 'patchShebangsAuto' '_pruneLibtoolFiles' '_doStrip' ) 128 + guess='6' 129 + initialPath='/nix/store/x1xcjw5628crkk1pwr12y7nwbzkc3969-coreutils-9.4 /nix/store/i6y16f2jzcv1g1k12qdkislh3yqk2rl7-findutils-4.9.0 /nix/store/xcmwf4l5n35cislpzhbhqbnd31wwsbll-diffutils-3.10 /nix/store/y1y3rml47qnh0giqd32mj07qxxqy13qg-gnused-4.9 /nix/store/11b3chszacfr9liy829xqknzp3q88iji-gnugrep-3.11 /nix/store/78q5np4llnqhshx72kxm7w7q31pj0v7b-gawk-5.2.2 /nix/store/dxbzps4w5rikj7jdcyjcw98lk517gf0h-gnutar-1.35 /nix/store/zyyb8vi6jg1swr5f34rxgi9izck2r88h-gzip-1.13 /nix/store/b0gdx2hz2nyf9ap2n0zixczc7k2kqk9j-bzip2-1.0.8-bin /nix/store/w0q0c4jham4h0cbvi3ygydl6hrcmzn6x-gnumake-4.4.1 /nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26 /nix/store/8hsz6cchg5yw1wz89mab5f89k3j7l03m-patch-2.7.6 /nix/store/xl7x35n2v2m398hki8q4ib235zn3hv20-xz-5.4.6-bin /nix/store/8ja6nib32kv3h9z6jwlh95b5ayma7wfx-file-5.45' 130 + mesonFlags='' 131 + export mesonFlags 132 + name='nix-shell-env' 133 + export name 134 + nativeBuildInputs='' 135 + export nativeBuildInputs 136 + out='/home/pedro/Projects/Languages/Go/outputs/out' 137 + export out 138 + outputBin='out' 139 + outputDev='out' 140 + outputDevdoc='REMOVE' 141 + outputDevman='out' 142 + outputDoc='out' 143 + outputInclude='out' 144 + outputInfo='out' 145 + outputLib='out' 146 + outputMan='out' 147 + outputs='out' 148 + export outputs 149 + patches='' 150 + export patches 151 + phases='buildPhase' 152 + export phases 153 + pkg='/nix/store/ln6zld1ia7rxddmxgbpfhrmb42rbxdw8-gcc-wrapper-13.2.0' 154 + declare -a pkgsBuildBuild=() 155 + declare -a pkgsBuildHost=('/nix/store/xwsq5dj63439l1pphrb76zjrididi3vn-patchelf-0.15.0' '/nix/store/hcrhrs1mmm2q5a3rzd6xwypqgkpm13vx-update-autotools-gnu-config-scripts-hook' '/nix/store/h9lc1dpi14z7is86ffhl3ld569138595-audit-tmpdir.sh' '/nix/store/m54bmrhj6fqz8nds5zcj97w9s9bckc9v-compress-man-pages.sh' '/nix/store/wgrbkkaldkrlrni33ccvm3b6vbxzb656-make-symlinks-relative.sh' '/nix/store/5yzw0vhkyszf2d179m0qfkgxmp5wjjx4-move-docs.sh' '/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh' '/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh' '/nix/store/pag6l61paj1dc9sv15l7bm5c17xn5kyk-move-systemd-user-units.sh' '/nix/store/jivxp510zxakaaic7qkrb7v1dd2rdbw9-multiple-outputs.sh' '/nix/store/ilaf1w22bxi6jsi45alhmvvdgy4ly3zs-patch-shebangs.sh' '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh' '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh' '/nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh' '/nix/store/wmknncrif06fqxa16hpdldhixk95nds0-strip.sh' '/nix/store/ln6zld1ia7rxddmxgbpfhrmb42rbxdw8-gcc-wrapper-13.2.0' '/nix/store/cc92grinhsyp2mq5sxlmz06z68gz1h98-binutils-wrapper-2.40' ) 156 + declare -a pkgsBuildTarget=() 157 + declare -a pkgsHostHost=() 158 + declare -a pkgsHostTarget=('/nix/store/hkzgcfj86jzzpayghzvy09xpvjg4xmac-go-1.21.7' '/nix/store/kc58bqdmjdc6mfilih5pywprs7r7lxrw-golangci-lint-1.56.2' ) 159 + declare -a pkgsTargetTarget=() 160 + declare -a postFixupHooks=('_makeSymlinksRelativeInAllOutputs' '_multioutPropagateDev' ) 161 + declare -a postUnpackHooks=('_updateSourceDateEpochFromSourceRoot' ) 162 + declare -a preConfigureHooks=('_multioutConfig' ) 163 + preConfigurePhases=' updateAutotoolsGnuConfigScriptsPhase' 164 + declare -a preFixupHooks=('_moveToShare' '_multioutDocs' '_multioutDevs' ) 165 + preferLocalBuild='1' 166 + export preferLocalBuild 167 + prefix='/home/pedro/Projects/Languages/Go/outputs/out' 168 + declare -a propagatedBuildDepFiles=('propagated-build-build-deps' 'propagated-native-build-inputs' 'propagated-build-target-deps' ) 169 + propagatedBuildInputs='' 170 + export propagatedBuildInputs 171 + declare -a propagatedHostDepFiles=('propagated-host-host-deps' 'propagated-build-inputs' ) 172 + propagatedNativeBuildInputs='' 173 + export propagatedNativeBuildInputs 174 + declare -a propagatedTargetDepFiles=('propagated-target-target-deps' ) 175 + shell='/nix/store/087167dfxal194pm54cmcbbxsfy3cjgn-bash-5.2p26/bin/bash' 176 + export shell 177 + shellHook='' 178 + export shellHook 179 + stdenv='/nix/store/3qnm3nwjajgqa771dmi2dnwxrw0kzq5m-stdenv-linux' 180 + export stdenv 181 + strictDeps='' 182 + export strictDeps 183 + system='x86_64-linux' 184 + export system 185 + declare -a unpackCmdHooks=('_defaultUnpack' ) 186 + _accumFlagsArray () 187 + { 188 + 189 + local name; 190 + if [ -n "$__structuredAttrs" ]; then 191 + for name in "$@"; 192 + do 193 + local -n nameref="$name"; 194 + flagsArray+=(${nameref+"${nameref[@]}"}); 195 + done; 196 + else 197 + for name in "$@"; 198 + do 199 + local -n nameref="$name"; 200 + case "$name" in 201 + *Array) 202 + flagsArray+=(${nameref+"${nameref[@]}"}) 203 + ;; 204 + *) 205 + flagsArray+=(${nameref-}) 206 + ;; 207 + esac; 208 + done; 209 + fi 210 + } 211 + _activatePkgs () 212 + { 213 + 214 + local hostOffset targetOffset; 215 + local pkg; 216 + for hostOffset in "${allPlatOffsets[@]}"; 217 + do 218 + local pkgsVar="${pkgAccumVarVars[hostOffset + 1]}"; 219 + for targetOffset in "${allPlatOffsets[@]}"; 220 + do 221 + (( hostOffset <= targetOffset )) || continue; 222 + local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"; 223 + local pkgsSlice="${!pkgsRef}[@]"; 224 + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; 225 + do 226 + activatePackage "$pkg" "$hostOffset" "$targetOffset"; 227 + done; 228 + done; 229 + done 230 + } 231 + _addRpathPrefix () 232 + { 233 + 234 + if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then 235 + export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}"; 236 + fi 237 + } 238 + _addToEnv () 239 + { 240 + 241 + local depHostOffset depTargetOffset; 242 + local pkg; 243 + for depHostOffset in "${allPlatOffsets[@]}"; 244 + do 245 + local hookVar="${pkgHookVarVars[depHostOffset + 1]}"; 246 + local pkgsVar="${pkgAccumVarVars[depHostOffset + 1]}"; 247 + for depTargetOffset in "${allPlatOffsets[@]}"; 248 + do 249 + (( depHostOffset <= depTargetOffset )) || continue; 250 + local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"; 251 + if [[ -z "${strictDeps-}" ]]; then 252 + local visitedPkgs=""; 253 + for pkg in "${pkgsBuildBuild[@]}" "${pkgsBuildHost[@]}" "${pkgsBuildTarget[@]}" "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}" "${pkgsTargetTarget[@]}"; 254 + do 255 + if [[ "$visitedPkgs" = *"$pkg"* ]]; then 256 + continue; 257 + fi; 258 + runHook "${!hookRef}" "$pkg"; 259 + visitedPkgs+=" $pkg"; 260 + done; 261 + else 262 + local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"; 263 + local pkgsSlice="${!pkgsRef}[@]"; 264 + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; 265 + do 266 + runHook "${!hookRef}" "$pkg"; 267 + done; 268 + fi; 269 + done; 270 + done 271 + } 272 + _allFlags () 273 + { 274 + 275 + export system pname name version; 276 + for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); 277 + do 278 + if (( "${NIX_DEBUG:-0}" >= 1 )); then 279 + printf "@%s@ -> %q\n" "${varName}" "${!varName}" 1>&2; 280 + fi; 281 + args+=("--subst-var" "$varName"); 282 + done 283 + } 284 + _assignFirst () 285 + { 286 + 287 + local varName="$1"; 288 + local _var; 289 + local REMOVE=REMOVE; 290 + shift; 291 + for _var in "$@"; 292 + do 293 + if [ -n "${!_var-}" ]; then 294 + eval "${varName}"="${_var}"; 295 + return; 296 + fi; 297 + done; 298 + echo; 299 + echo "error: _assignFirst: could not find a non-empty variable whose name to assign to ${varName}."; 300 + echo " The following variables were all unset or empty:"; 301 + echo " $*"; 302 + if [ -z "${out:-}" ]; then 303 + echo ' If you do not want an "out" output in your derivation, make sure to define'; 304 + echo ' the other specific required outputs. This can be achieved by picking one'; 305 + echo " of the above as an output."; 306 + echo ' You do not have to remove "out" if you want to have a different default'; 307 + echo ' output, because the first output is taken as a default.'; 308 + echo; 309 + fi; 310 + return 1 311 + } 312 + _callImplicitHook () 313 + { 314 + 315 + local def="$1"; 316 + local hookName="$2"; 317 + if declare -F "$hookName" > /dev/null; then 318 + "$hookName"; 319 + else 320 + if type -p "$hookName" > /dev/null; then 321 + source "$hookName"; 322 + else 323 + if [ -n "${!hookName:-}" ]; then 324 + eval "${!hookName}"; 325 + else 326 + return "$def"; 327 + fi; 328 + fi; 329 + fi 330 + } 331 + _defaultUnpack () 332 + { 333 + 334 + local fn="$1"; 335 + local destination; 336 + if [ -d "$fn" ]; then 337 + destination="$(stripHash "$fn")"; 338 + if [ -e "$destination" ]; then 339 + echo "Cannot copy $fn to $destination: destination already exists!"; 340 + echo "Did you specify two \"srcs\" with the same \"name\"?"; 341 + return 1; 342 + fi; 343 + cp -pr --reflink=auto -- "$fn" "$destination"; 344 + else 345 + case "$fn" in 346 + *.tar.xz | *.tar.lzma | *.txz) 347 + ( XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < "$fn"; 348 + true ) | tar xf - --warning=no-timestamp 349 + ;; 350 + *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz) 351 + tar xf "$fn" --warning=no-timestamp 352 + ;; 353 + *) 354 + return 1 355 + ;; 356 + esac; 357 + fi 358 + } 359 + _doStrip () 360 + { 361 + 362 + local -ra flags=(dontStripHost dontStripTarget); 363 + local -ra debugDirs=(stripDebugList stripDebugListTarget); 364 + local -ra allDirs=(stripAllList stripAllListTarget); 365 + local -ra stripCmds=(STRIP STRIP_FOR_TARGET); 366 + local -ra ranlibCmds=(RANLIB RANLIB_FOR_TARGET); 367 + stripDebugList=${stripDebugList[*]:-lib lib32 lib64 libexec bin sbin}; 368 + stripDebugListTarget=${stripDebugListTarget[*]:-}; 369 + stripAllList=${stripAllList[*]:-}; 370 + stripAllListTarget=${stripAllListTarget[*]:-}; 371 + local i; 372 + for i in ${!stripCmds[@]}; 373 + do 374 + local -n flag="${flags[$i]}"; 375 + local -n debugDirList="${debugDirs[$i]}"; 376 + local -n allDirList="${allDirs[$i]}"; 377 + local -n stripCmd="${stripCmds[$i]}"; 378 + local -n ranlibCmd="${ranlibCmds[$i]}"; 379 + if [[ -n "${dontStrip-}" || -n "${flag-}" ]] || ! type -f "${stripCmd-}" 2> /dev/null 1>&2; then 380 + continue; 381 + fi; 382 + stripDirs "$stripCmd" "$ranlibCmd" "$debugDirList" "${stripDebugFlags[*]:--S -p}"; 383 + stripDirs "$stripCmd" "$ranlibCmd" "$allDirList" "${stripAllFlags[*]:--s -p}"; 384 + done 385 + } 386 + _eval () 387 + { 388 + 389 + if declare -F "$1" > /dev/null 2>&1; then 390 + "$@"; 391 + else 392 + eval "$1"; 393 + fi 394 + } 395 + _makeSymlinksRelative () 396 + { 397 + 398 + local symlinkTarget; 399 + if [ "${dontRewriteSymlinks-}" ] || [ ! -e "$prefix" ]; then 400 + return; 401 + fi; 402 + while IFS= read -r -d '' f; do 403 + symlinkTarget=$(readlink "$f"); 404 + if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then 405 + continue; 406 + fi; 407 + if [ ! -e "$symlinkTarget" ]; then 408 + echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"; 409 + fi; 410 + echo "rewriting symlink $f to be relative to $prefix"; 411 + ln -snrf "$symlinkTarget" "$f"; 412 + done < <(find $prefix -type l -print0) 413 + } 414 + _makeSymlinksRelativeInAllOutputs () 415 + { 416 + 417 + local output; 418 + for output in $(getAllOutputNames); 419 + do 420 + prefix="${!output}" _makeSymlinksRelative; 421 + done 422 + } 423 + _moveLib64 () 424 + { 425 + 426 + if [ "${dontMoveLib64-}" = 1 ]; then 427 + return; 428 + fi; 429 + if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then 430 + return; 431 + fi; 432 + echo "moving $prefix/lib64/* to $prefix/lib"; 433 + mkdir -p $prefix/lib; 434 + shopt -s dotglob; 435 + for i in $prefix/lib64/*; 436 + do 437 + mv --no-clobber "$i" $prefix/lib; 438 + done; 439 + shopt -u dotglob; 440 + rmdir $prefix/lib64; 441 + ln -s lib $prefix/lib64 442 + } 443 + _moveSbin () 444 + { 445 + 446 + if [ "${dontMoveSbin-}" = 1 ]; then 447 + return; 448 + fi; 449 + if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then 450 + return; 451 + fi; 452 + echo "moving $prefix/sbin/* to $prefix/bin"; 453 + mkdir -p $prefix/bin; 454 + shopt -s dotglob; 455 + for i in $prefix/sbin/*; 456 + do 457 + mv "$i" $prefix/bin; 458 + done; 459 + shopt -u dotglob; 460 + rmdir $prefix/sbin; 461 + ln -s bin $prefix/sbin 462 + } 463 + _moveSystemdUserUnits () 464 + { 465 + 466 + if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then 467 + return; 468 + fi; 469 + if [ ! -e "${prefix:?}/lib/systemd/user" ]; then 470 + return; 471 + fi; 472 + local source="$prefix/lib/systemd/user"; 473 + local target="$prefix/share/systemd/user"; 474 + echo "moving $source/* to $target"; 475 + mkdir -p "$target"; 476 + ( shopt -s dotglob; 477 + for i in "$source"/*; 478 + do 479 + mv "$i" "$target"; 480 + done ); 481 + rmdir "$source"; 482 + ln -s "$target" "$source" 483 + } 484 + _moveToShare () 485 + { 486 + 487 + if [ -n "$__structuredAttrs" ]; then 488 + if [ -z "${forceShare-}" ]; then 489 + forceShare=(man doc info); 490 + fi; 491 + else 492 + forceShare=(${forceShare:-man doc info}); 493 + fi; 494 + if [[ -z "$out" ]]; then 495 + return; 496 + fi; 497 + for d in "${forceShare[@]}"; 498 + do 499 + if [ -d "$out/$d" ]; then 500 + if [ -d "$out/share/$d" ]; then 501 + echo "both $d/ and share/$d/ exist!"; 502 + else 503 + echo "moving $out/$d to $out/share/$d"; 504 + mkdir -p $out/share; 505 + mv $out/$d $out/share/; 506 + fi; 507 + fi; 508 + done 509 + } 510 + _multioutConfig () 511 + { 512 + 513 + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${setOutputFlags-1}" ]; then 514 + return; 515 + fi; 516 + if [ -z "${shareDocName:-}" ]; then 517 + local confScript="${configureScript:-}"; 518 + if [ -z "$confScript" ] && [ -x ./configure ]; then 519 + confScript=./configure; 520 + fi; 521 + if [ -f "$confScript" ]; then 522 + local shareDocName="$(sed -n "s/^PACKAGE_TARNAME='\(.*\)'$/\1/p" < "$confScript")"; 523 + fi; 524 + if [ -z "$shareDocName" ] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_-]'; then 525 + shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"; 526 + fi; 527 + fi; 528 + prependToVar configureFlags --bindir="${!outputBin}"/bin --sbindir="${!outputBin}"/sbin --includedir="${!outputInclude}"/include --oldincludedir="${!outputInclude}"/include --mandir="${!outputMan}"/share/man --infodir="${!outputInfo}"/share/info --docdir="${!outputDoc}"/share/doc/"${shareDocName}" --libdir="${!outputLib}"/lib --libexecdir="${!outputLib}"/libexec --localedir="${!outputLib}"/share/locale; 529 + prependToVar installFlags pkgconfigdir="${!outputDev}"/lib/pkgconfig m4datadir="${!outputDev}"/share/aclocal aclocaldir="${!outputDev}"/share/aclocal 530 + } 531 + _multioutDevs () 532 + { 533 + 534 + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${moveToDev-1}" ]; then 535 + return; 536 + fi; 537 + moveToOutput include "${!outputInclude}"; 538 + moveToOutput lib/pkgconfig "${!outputDev}"; 539 + moveToOutput share/pkgconfig "${!outputDev}"; 540 + moveToOutput lib/cmake "${!outputDev}"; 541 + moveToOutput share/aclocal "${!outputDev}"; 542 + for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; 543 + do 544 + echo "Patching '$f' includedir to output ${!outputInclude}"; 545 + sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"; 546 + done 547 + } 548 + _multioutDocs () 549 + { 550 + 551 + local REMOVE=REMOVE; 552 + moveToOutput share/info "${!outputInfo}"; 553 + moveToOutput share/doc "${!outputDoc}"; 554 + moveToOutput share/gtk-doc "${!outputDevdoc}"; 555 + moveToOutput share/devhelp/books "${!outputDevdoc}"; 556 + moveToOutput share/man "${!outputMan}"; 557 + moveToOutput share/man/man3 "${!outputDevman}" 558 + } 559 + _multioutPropagateDev () 560 + { 561 + 562 + if [ "$(getAllOutputNames)" = "out" ]; then 563 + return; 564 + fi; 565 + local outputFirst; 566 + for outputFirst in $(getAllOutputNames); 567 + do 568 + break; 569 + done; 570 + local propagaterOutput="$outputDev"; 571 + if [ -z "$propagaterOutput" ]; then 572 + propagaterOutput="$outputFirst"; 573 + fi; 574 + if [ -z "${propagatedBuildOutputs+1}" ]; then 575 + local po_dirty="$outputBin $outputInclude $outputLib"; 576 + set +o pipefail; 577 + propagatedBuildOutputs=`echo "$po_dirty" | tr -s ' ' '\n' | grep -v -F "$propagaterOutput" | sort -u | tr '\n' ' ' `; 578 + set -o pipefail; 579 + fi; 580 + if [ -z "$propagatedBuildOutputs" ]; then 581 + return; 582 + fi; 583 + mkdir -p "${!propagaterOutput}"/nix-support; 584 + for output in $propagatedBuildOutputs; 585 + do 586 + echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/propagated-build-inputs; 587 + done 588 + } 589 + _overrideFirst () 590 + { 591 + 592 + if [ -z "${!1-}" ]; then 593 + _assignFirst "$@"; 594 + fi 595 + } 596 + _pruneLibtoolFiles () 597 + { 598 + 599 + if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then 600 + return; 601 + fi; 602 + find "$prefix" -type f -name '*.la' -exec grep -q '^# Generated by .*libtool' {} \; -exec grep -q "^old_library=''" {} \; -exec sed -i {} -e "/^dependency_libs='[^']/ c dependency_libs='' #pruned" \; 603 + } 604 + _updateSourceDateEpochFromSourceRoot () 605 + { 606 + 607 + if [ -n "$sourceRoot" ]; then 608 + updateSourceDateEpoch "$sourceRoot"; 609 + fi 610 + } 611 + activatePackage () 612 + { 613 + 614 + local pkg="$1"; 615 + local -r hostOffset="$2"; 616 + local -r targetOffset="$3"; 617 + (( hostOffset <= targetOffset )) || exit 1; 618 + if [ -f "$pkg" ]; then 619 + source "$pkg"; 620 + fi; 621 + if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then 622 + addToSearchPath _PATH "$pkg/bin"; 623 + fi; 624 + if (( hostOffset <= -1 )); then 625 + addToSearchPath _XDG_DATA_DIRS "$pkg/share"; 626 + fi; 627 + if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then 628 + addToSearchPath _HOST_PATH "$pkg/bin"; 629 + fi; 630 + if [[ -f "$pkg/nix-support/setup-hook" ]]; then 631 + source "$pkg/nix-support/setup-hook"; 632 + fi 633 + } 634 + addEnvHooks () 635 + { 636 + 637 + local depHostOffset="$1"; 638 + shift; 639 + local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"; 640 + local pkgHookVar; 641 + for pkgHookVar in "${!pkgHookVarsSlice}"; 642 + do 643 + eval "${pkgHookVar}s"'+=("$@")'; 644 + done 645 + } 646 + addToSearchPath () 647 + { 648 + 649 + addToSearchPathWithCustomDelimiter ":" "$@" 650 + } 651 + addToSearchPathWithCustomDelimiter () 652 + { 653 + 654 + local delimiter="$1"; 655 + local varName="$2"; 656 + local dir="$3"; 657 + if [[ -d "$dir" && "${!varName:+${delimiter}${!varName}${delimiter}}" != *"${delimiter}${dir}${delimiter}"* ]]; then 658 + export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"; 659 + fi 660 + } 661 + appendToVar () 662 + { 663 + 664 + local -n nameref="$1"; 665 + local useArray type; 666 + if [ -n "$__structuredAttrs" ]; then 667 + useArray=true; 668 + else 669 + useArray=false; 670 + fi; 671 + if declare -p "$1" 2> /dev/null | grep -q '^'; then 672 + type="$(declare -p "$1")"; 673 + if [[ "$type" =~ "declare -A" ]]; then 674 + echo "appendToVar(): ERROR: trying to use appendToVar on an associative array, use variable+=([\"X\"]=\"Y\") instead." 1>&2; 675 + return 1; 676 + else 677 + if [[ "$type" =~ "declare -a" ]]; then 678 + useArray=true; 679 + else 680 + useArray=false; 681 + fi; 682 + fi; 683 + fi; 684 + shift; 685 + if $useArray; then 686 + nameref=(${nameref+"${nameref[@]}"} "$@"); 687 + else 688 + nameref="${nameref-} $*"; 689 + fi 690 + } 691 + auditTmpdir () 692 + { 693 + 694 + local dir="$1"; 695 + [ -e "$dir" ] || return 0; 696 + echo "checking for references to $TMPDIR/ in $dir..."; 697 + local i; 698 + find "$dir" -type f -print0 | while IFS= read -r -d '' i; do 699 + if [[ "$i" =~ .build-id ]]; then 700 + continue; 701 + fi; 702 + if isELF "$i"; then 703 + if { 704 + printf :; 705 + patchelf --print-rpath "$i" 706 + } | grep -q -F ":$TMPDIR/"; then 707 + echo "RPATH of binary $i contains a forbidden reference to $TMPDIR/"; 708 + exit 1; 709 + fi; 710 + fi; 711 + if isScript "$i"; then 712 + if [ -e "$(dirname "$i")/.$(basename "$i")-wrapped" ]; then 713 + if grep -q -F "$TMPDIR/" "$i"; then 714 + echo "wrapper script $i contains a forbidden reference to $TMPDIR/"; 715 + exit 1; 716 + fi; 717 + fi; 718 + fi; 719 + done 720 + } 721 + bintoolsWrapper_addLDVars () 722 + { 723 + 724 + local role_post; 725 + getHostRoleEnvHook; 726 + if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then 727 + export NIX_LDFLAGS${role_post}+=" -L$1/lib64"; 728 + fi; 729 + if [[ -d "$1/lib" ]]; then 730 + local -a glob=($1/lib/lib*); 731 + if [ "${#glob[*]}" -gt 0 ]; then 732 + export NIX_LDFLAGS${role_post}+=" -L$1/lib"; 733 + fi; 734 + fi 735 + } 736 + buildPhase () 737 + { 738 + 739 + runHook preBuild; 740 + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then 741 + echo "no Makefile or custom buildPhase, doing nothing"; 742 + else 743 + foundMakefile=1; 744 + local flagsArray=(${enableParallelBuilding:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); 745 + _accumFlagsArray makeFlags makeFlagsArray buildFlags buildFlagsArray; 746 + echoCmd 'build flags' "${flagsArray[@]}"; 747 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 748 + unset flagsArray; 749 + fi; 750 + runHook postBuild 751 + } 752 + ccWrapper_addCVars () 753 + { 754 + 755 + local role_post; 756 + getHostRoleEnvHook; 757 + if [ -d "$1/include" ]; then 758 + export NIX_CFLAGS_COMPILE${role_post}+=" -isystem $1/include"; 759 + fi; 760 + if [ -d "$1/Library/Frameworks" ]; then 761 + export NIX_CFLAGS_COMPILE${role_post}+=" -iframework $1/Library/Frameworks"; 762 + fi 763 + } 764 + checkPhase () 765 + { 766 + 767 + runHook preCheck; 768 + if [[ -z "${foundMakefile:-}" ]]; then 769 + echo "no Makefile or custom checkPhase, doing nothing"; 770 + runHook postCheck; 771 + return; 772 + fi; 773 + if [[ -z "${checkTarget:-}" ]]; then 774 + if make -n ${makefile:+-f $makefile} check > /dev/null 2>&1; then 775 + checkTarget=check; 776 + else 777 + if make -n ${makefile:+-f $makefile} test > /dev/null 2>&1; then 778 + checkTarget=test; 779 + fi; 780 + fi; 781 + fi; 782 + if [[ -z "${checkTarget:-}" ]]; then 783 + echo "no check/test target in ${makefile:-Makefile}, doing nothing"; 784 + else 785 + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); 786 + _accumFlagsArray makeFlags makeFlagsArray; 787 + if [ -n "$__structuredAttrs" ]; then 788 + flagsArray+=("${checkFlags[@]:-VERBOSE=y}"); 789 + else 790 + flagsArray+=(${checkFlags:-VERBOSE=y}); 791 + fi; 792 + _accumFlagsArray checkFlagsArray; 793 + flagsArray+=(${checkTarget}); 794 + echoCmd 'check flags' "${flagsArray[@]}"; 795 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 796 + unset flagsArray; 797 + fi; 798 + runHook postCheck 799 + } 800 + compressManPages () 801 + { 802 + 803 + local dir="$1"; 804 + if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]; then 805 + return; 806 + fi; 807 + echo "gzipping man pages under $dir/share/man/"; 808 + find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | while IFS= read -r -d '' f; do 809 + if gzip -c -n "$f" > "$f".gz; then 810 + rm "$f"; 811 + else 812 + rm "$f".gz; 813 + fi; 814 + done; 815 + find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | sort -z | while IFS= read -r -d '' f; do 816 + local target; 817 + target="$(readlink -f "$f")"; 818 + if [ -f "$target".gz ]; then 819 + ln -sf "$target".gz "$f".gz && rm "$f"; 820 + fi; 821 + done 822 + } 823 + configurePhase () 824 + { 825 + 826 + runHook preConfigure; 827 + : "${configureScript=}"; 828 + if [[ -z "$configureScript" && -x ./configure ]]; then 829 + configureScript=./configure; 830 + fi; 831 + if [ -z "${dontFixLibtool:-}" ]; then 832 + export lt_cv_deplibs_check_method="${lt_cv_deplibs_check_method-pass_all}"; 833 + local i; 834 + find . -iname "ltmain.sh" -print0 | while IFS='' read -r -d '' i; do 835 + echo "fixing libtool script $i"; 836 + fixLibtool "$i"; 837 + done; 838 + CONFIGURE_MTIME_REFERENCE=$(mktemp configure.mtime.reference.XXXXXX); 839 + find . -executable -type f -name configure -exec grep -l 'GNU Libtool is free software; you can redistribute it and/or modify' {} \; -exec touch -r {} "$CONFIGURE_MTIME_REFERENCE" \; -exec sed -i s_/usr/bin/file_file_g {} \; -exec touch -r "$CONFIGURE_MTIME_REFERENCE" {} \;; 840 + rm -f "$CONFIGURE_MTIME_REFERENCE"; 841 + fi; 842 + if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then 843 + prependToVar configureFlags "${prefixKey:---prefix=}$prefix"; 844 + fi; 845 + if [[ -f "$configureScript" ]]; then 846 + if [ -z "${dontAddDisableDepTrack:-}" ]; then 847 + if grep -q dependency-tracking "$configureScript"; then 848 + prependToVar configureFlags --disable-dependency-tracking; 849 + fi; 850 + fi; 851 + if [ -z "${dontDisableStatic:-}" ]; then 852 + if grep -q enable-static "$configureScript"; then 853 + prependToVar configureFlags --disable-static; 854 + fi; 855 + fi; 856 + if [ -z "${dontPatchShebangsInConfigure:-}" ]; then 857 + patchShebangs --build "$configureScript"; 858 + fi; 859 + fi; 860 + if [ -n "$configureScript" ]; then 861 + local -a flagsArray; 862 + _accumFlagsArray configureFlags configureFlagsArray; 863 + echoCmd 'configure flags' "${flagsArray[@]}"; 864 + $configureScript "${flagsArray[@]}"; 865 + unset flagsArray; 866 + else 867 + echo "no configure script, doing nothing"; 868 + fi; 869 + runHook postConfigure 870 + } 871 + consumeEntire () 872 + { 873 + 874 + if IFS='' read -r -d '' "$1"; then 875 + echo "consumeEntire(): ERROR: Input null bytes, won't process" 1>&2; 876 + return 1; 877 + fi 878 + } 879 + distPhase () 880 + { 881 + 882 + runHook preDist; 883 + local flagsArray=(); 884 + _accumFlagsArray distFlags distFlagsArray; 885 + flagsArray+=(${distTarget:-dist}); 886 + echo 'dist flags: %q' "${flagsArray[@]}"; 887 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 888 + if [ "${dontCopyDist:-0}" != 1 ]; then 889 + mkdir -p "$out/tarballs"; 890 + cp -pvd ${tarballs[*]:-*.tar.gz} "$out/tarballs"; 891 + fi; 892 + runHook postDist 893 + } 894 + dumpVars () 895 + { 896 + 897 + if [ "${noDumpEnvVars:-0}" != 1 ]; then 898 + export 2> /dev/null >| "$NIX_BUILD_TOP/env-vars" || true; 899 + fi 900 + } 901 + echoCmd () 902 + { 903 + 904 + printf "%s:" "$1"; 905 + shift; 906 + printf ' %q' "$@"; 907 + echo 908 + } 909 + exitHandler () 910 + { 911 + 912 + exitCode="$?"; 913 + set +e; 914 + if [ -n "${showBuildStats:-}" ]; then 915 + read -r -d '' -a buildTimes < <(times); 916 + echo "build times:"; 917 + echo "user time for the shell ${buildTimes[0]}"; 918 + echo "system time for the shell ${buildTimes[1]}"; 919 + echo "user time for all child processes ${buildTimes[2]}"; 920 + echo "system time for all child processes ${buildTimes[3]}"; 921 + fi; 922 + if (( "$exitCode" != 0 )); then 923 + runHook failureHook; 924 + if [ -n "${succeedOnFailure:-}" ]; then 925 + echo "build failed with exit code $exitCode (ignored)"; 926 + mkdir -p "$out/nix-support"; 927 + printf "%s" "$exitCode" > "$out/nix-support/failed"; 928 + exit 0; 929 + fi; 930 + else 931 + runHook exitHook; 932 + fi; 933 + return "$exitCode" 934 + } 935 + findInputs () 936 + { 937 + 938 + local -r pkg="$1"; 939 + local -r hostOffset="$2"; 940 + local -r targetOffset="$3"; 941 + (( hostOffset <= targetOffset )) || exit 1; 942 + local varVar="${pkgAccumVarVars[hostOffset + 1]}"; 943 + local varRef="$varVar[$((targetOffset - hostOffset))]"; 944 + local var="${!varRef}"; 945 + unset -v varVar varRef; 946 + local varSlice="$var[*]"; 947 + case "${!varSlice-}" in 948 + *" $pkg "*) 949 + return 0 950 + ;; 951 + esac; 952 + unset -v varSlice; 953 + eval "$var"'+=("$pkg")'; 954 + if ! [ -e "$pkg" ]; then 955 + echo "build input $pkg does not exist" 1>&2; 956 + exit 1; 957 + fi; 958 + function mapOffset () 959 + { 960 + local -r inputOffset="$1"; 961 + local -n outputOffset="$2"; 962 + if (( inputOffset <= 0 )); then 963 + outputOffset=$((inputOffset + hostOffset)); 964 + else 965 + outputOffset=$((inputOffset - 1 + targetOffset)); 966 + fi 967 + }; 968 + local relHostOffset; 969 + for relHostOffset in "${allPlatOffsets[@]}"; 970 + do 971 + local files="${propagatedDepFilesVars[relHostOffset + 1]}"; 972 + local hostOffsetNext; 973 + mapOffset "$relHostOffset" hostOffsetNext; 974 + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; 975 + local relTargetOffset; 976 + for relTargetOffset in "${allPlatOffsets[@]}"; 977 + do 978 + (( "$relHostOffset" <= "$relTargetOffset" )) || continue; 979 + local fileRef="${files}[$relTargetOffset - $relHostOffset]"; 980 + local file="${!fileRef}"; 981 + unset -v fileRef; 982 + local targetOffsetNext; 983 + mapOffset "$relTargetOffset" targetOffsetNext; 984 + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; 985 + [[ -f "$pkg/nix-support/$file" ]] || continue; 986 + local pkgNext; 987 + read -r -d '' pkgNext < "$pkg/nix-support/$file" || true; 988 + for pkgNext in $pkgNext; 989 + do 990 + findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"; 991 + done; 992 + done; 993 + done 994 + } 995 + fixLibtool () 996 + { 997 + 998 + local search_path; 999 + for flag in $NIX_LDFLAGS; 1000 + do 1001 + case $flag in 1002 + -L*) 1003 + search_path+=" ${flag#-L}" 1004 + ;; 1005 + esac; 1006 + done; 1007 + sed -i "$1" -e "s^eval \(sys_lib_search_path=\).*^\1'${search_path:-}'^" -e 's^eval sys_lib_.+search_path=.*^^' 1008 + } 1009 + fixupPhase () 1010 + { 1011 + 1012 + local output; 1013 + for output in $(getAllOutputNames); 1014 + do 1015 + if [ -e "${!output}" ]; then 1016 + chmod -R u+w "${!output}"; 1017 + fi; 1018 + done; 1019 + runHook preFixup; 1020 + local output; 1021 + for output in $(getAllOutputNames); 1022 + do 1023 + prefix="${!output}" runHook fixupOutput; 1024 + done; 1025 + recordPropagatedDependencies; 1026 + if [ -n "${setupHook:-}" ]; then 1027 + mkdir -p "${!outputDev}/nix-support"; 1028 + substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"; 1029 + fi; 1030 + if [ -n "${setupHooks:-}" ]; then 1031 + mkdir -p "${!outputDev}/nix-support"; 1032 + local hook; 1033 + for hook in ${setupHooks[@]}; 1034 + do 1035 + local content; 1036 + consumeEntire content < "$hook"; 1037 + substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"; 1038 + unset -v content; 1039 + done; 1040 + unset -v hook; 1041 + fi; 1042 + if [ -n "${propagatedUserEnvPkgs:-}" ]; then 1043 + mkdir -p "${!outputBin}/nix-support"; 1044 + printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"; 1045 + fi; 1046 + runHook postFixup 1047 + } 1048 + genericBuild () 1049 + { 1050 + 1051 + export GZIP_NO_TIMESTAMPS=1; 1052 + if [ -f "${buildCommandPath:-}" ]; then 1053 + source "$buildCommandPath"; 1054 + return; 1055 + fi; 1056 + if [ -n "${buildCommand:-}" ]; then 1057 + eval "$buildCommand"; 1058 + return; 1059 + fi; 1060 + if [ -z "${phases[*]:-}" ]; then 1061 + phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}"; 1062 + fi; 1063 + for curPhase in ${phases[*]}; 1064 + do 1065 + runPhase "$curPhase"; 1066 + done 1067 + } 1068 + getAllOutputNames () 1069 + { 1070 + 1071 + if [ -n "$__structuredAttrs" ]; then 1072 + echo "${!outputs[*]}"; 1073 + else 1074 + echo "$outputs"; 1075 + fi 1076 + } 1077 + getHostRole () 1078 + { 1079 + 1080 + getRole "$hostOffset" 1081 + } 1082 + getHostRoleEnvHook () 1083 + { 1084 + 1085 + getRole "$depHostOffset" 1086 + } 1087 + getRole () 1088 + { 1089 + 1090 + case $1 in 1091 + -1) 1092 + role_post='_FOR_BUILD' 1093 + ;; 1094 + 0) 1095 + role_post='' 1096 + ;; 1097 + 1) 1098 + role_post='_FOR_TARGET' 1099 + ;; 1100 + *) 1101 + echo "binutils-wrapper-2.40: used as improper sort of dependency" 1>&2; 1102 + return 1 1103 + ;; 1104 + esac 1105 + } 1106 + getTargetRole () 1107 + { 1108 + 1109 + getRole "$targetOffset" 1110 + } 1111 + getTargetRoleEnvHook () 1112 + { 1113 + 1114 + getRole "$depTargetOffset" 1115 + } 1116 + getTargetRoleWrapper () 1117 + { 1118 + 1119 + case $targetOffset in 1120 + -1) 1121 + export NIX_BINTOOLS_WRAPPER_TARGET_BUILD_x86_64_unknown_linux_gnu=1 1122 + ;; 1123 + 0) 1124 + export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 1125 + ;; 1126 + 1) 1127 + export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu=1 1128 + ;; 1129 + *) 1130 + echo "binutils-wrapper-2.40: used as improper sort of dependency" 1>&2; 1131 + return 1 1132 + ;; 1133 + esac 1134 + } 1135 + installCheckPhase () 1136 + { 1137 + 1138 + runHook preInstallCheck; 1139 + if [[ -z "${foundMakefile:-}" ]]; then 1140 + echo "no Makefile or custom installCheckPhase, doing nothing"; 1141 + else 1142 + if [[ -z "${installCheckTarget:-}" ]] && ! make -n ${makefile:+-f $makefile} "${installCheckTarget:-installcheck}" > /dev/null 2>&1; then 1143 + echo "no installcheck target in ${makefile:-Makefile}, doing nothing"; 1144 + else 1145 + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); 1146 + _accumFlagsArray makeFlags makeFlagsArray installCheckFlags installCheckFlagsArray; 1147 + flagsArray+=(${installCheckTarget:-installcheck}); 1148 + echoCmd 'installcheck flags' "${flagsArray[@]}"; 1149 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 1150 + unset flagsArray; 1151 + fi; 1152 + fi; 1153 + runHook postInstallCheck 1154 + } 1155 + installPhase () 1156 + { 1157 + 1158 + runHook preInstall; 1159 + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then 1160 + echo "no Makefile or custom installPhase, doing nothing"; 1161 + runHook postInstall; 1162 + return; 1163 + else 1164 + foundMakefile=1; 1165 + fi; 1166 + if [ -n "$prefix" ]; then 1167 + mkdir -p "$prefix"; 1168 + fi; 1169 + local flagsArray=(${enableParallelInstalling:+-j${NIX_BUILD_CORES}} SHELL=$SHELL); 1170 + _accumFlagsArray makeFlags makeFlagsArray installFlags installFlagsArray; 1171 + if [ -n "$__structuredAttrs" ]; then 1172 + flagsArray+=("${installTargets[@]:-install}"); 1173 + else 1174 + flagsArray+=(${installTargets:-install}); 1175 + fi; 1176 + echoCmd 'install flags' "${flagsArray[@]}"; 1177 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 1178 + unset flagsArray; 1179 + runHook postInstall 1180 + } 1181 + isELF () 1182 + { 1183 + 1184 + local fn="$1"; 1185 + local fd; 1186 + local magic; 1187 + exec {fd}< "$fn"; 1188 + read -r -n 4 -u "$fd" magic; 1189 + exec {fd}>&-; 1190 + if [ "$magic" = 'ELF' ]; then 1191 + return 0; 1192 + else 1193 + return 1; 1194 + fi 1195 + } 1196 + isMachO () 1197 + { 1198 + 1199 + local fn="$1"; 1200 + local fd; 1201 + local magic; 1202 + exec {fd}< "$fn"; 1203 + read -r -n 4 -u "$fd" magic; 1204 + exec {fd}>&-; 1205 + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then 1206 + return 0; 1207 + else 1208 + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then 1209 + return 0; 1210 + else 1211 + if [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then 1212 + return 0; 1213 + else 1214 + return 1; 1215 + fi; 1216 + fi; 1217 + fi 1218 + } 1219 + isScript () 1220 + { 1221 + 1222 + local fn="$1"; 1223 + local fd; 1224 + local magic; 1225 + exec {fd}< "$fn"; 1226 + read -r -n 2 -u "$fd" magic; 1227 + exec {fd}>&-; 1228 + if [[ "$magic" =~ \#! ]]; then 1229 + return 0; 1230 + else 1231 + return 1; 1232 + fi 1233 + } 1234 + mapOffset () 1235 + { 1236 + 1237 + local -r inputOffset="$1"; 1238 + local -n outputOffset="$2"; 1239 + if (( inputOffset <= 0 )); then 1240 + outputOffset=$((inputOffset + hostOffset)); 1241 + else 1242 + outputOffset=$((inputOffset - 1 + targetOffset)); 1243 + fi 1244 + } 1245 + moveToOutput () 1246 + { 1247 + 1248 + local patt="$1"; 1249 + local dstOut="$2"; 1250 + local output; 1251 + for output in $(getAllOutputNames); 1252 + do 1253 + if [ "${!output}" = "$dstOut" ]; then 1254 + continue; 1255 + fi; 1256 + local srcPath; 1257 + for srcPath in "${!output}"/$patt; 1258 + do 1259 + if [ ! -e "$srcPath" ] && [ ! -L "$srcPath" ]; then 1260 + continue; 1261 + fi; 1262 + if [ "$dstOut" = REMOVE ]; then 1263 + echo "Removing $srcPath"; 1264 + rm -r "$srcPath"; 1265 + else 1266 + local dstPath="$dstOut${srcPath#${!output}}"; 1267 + echo "Moving $srcPath to $dstPath"; 1268 + if [ -d "$dstPath" ] && [ -d "$srcPath" ]; then 1269 + rmdir "$srcPath" --ignore-fail-on-non-empty; 1270 + if [ -d "$srcPath" ]; then 1271 + mv -t "$dstPath" "$srcPath"/*; 1272 + rmdir "$srcPath"; 1273 + fi; 1274 + else 1275 + mkdir -p "$(readlink -m "$dstPath/..")"; 1276 + mv "$srcPath" "$dstPath"; 1277 + fi; 1278 + fi; 1279 + local srcParent="$(readlink -m "$srcPath/..")"; 1280 + if [ -n "$(find "$srcParent" -maxdepth 0 -type d -empty 2> /dev/null)" ]; then 1281 + echo "Removing empty $srcParent/ and (possibly) its parents"; 1282 + rmdir -p --ignore-fail-on-non-empty "$srcParent" 2> /dev/null || true; 1283 + fi; 1284 + done; 1285 + done 1286 + } 1287 + patchELF () 1288 + { 1289 + 1290 + local dir="$1"; 1291 + [ -e "$dir" ] || return 0; 1292 + echo "shrinking RPATHs of ELF executables and libraries in $dir"; 1293 + local i; 1294 + while IFS= read -r -d '' i; do 1295 + if [[ "$i" =~ .build-id ]]; then 1296 + continue; 1297 + fi; 1298 + if ! isELF "$i"; then 1299 + continue; 1300 + fi; 1301 + echo "shrinking $i"; 1302 + patchelf --shrink-rpath "$i" || true; 1303 + done < <(find "$dir" -type f -print0) 1304 + } 1305 + patchPhase () 1306 + { 1307 + 1308 + runHook prePatch; 1309 + local -a patchesArray; 1310 + if [ -n "$__structuredAttrs" ]; then 1311 + patchesArray=(${patches:+"${patches[@]}"}); 1312 + else 1313 + patchesArray=(${patches:-}); 1314 + fi; 1315 + for i in "${patchesArray[@]}"; 1316 + do 1317 + echo "applying patch $i"; 1318 + local uncompress=cat; 1319 + case "$i" in 1320 + *.gz) 1321 + uncompress="gzip -d" 1322 + ;; 1323 + *.bz2) 1324 + uncompress="bzip2 -d" 1325 + ;; 1326 + *.xz) 1327 + uncompress="xz -d" 1328 + ;; 1329 + *.lzma) 1330 + uncompress="lzma -d" 1331 + ;; 1332 + esac; 1333 + local -a flagsArray; 1334 + if [ -n "$__structuredAttrs" ]; then 1335 + flagsArray=("${patchFlags[@]:--p1}"); 1336 + else 1337 + flagsArray=(${patchFlags:--p1}); 1338 + fi; 1339 + $uncompress < "$i" 2>&1 | patch "${flagsArray[@]}"; 1340 + done; 1341 + runHook postPatch 1342 + } 1343 + patchShebangs () 1344 + { 1345 + 1346 + local pathName; 1347 + local update; 1348 + while [[ $# -gt 0 ]]; do 1349 + case "$1" in 1350 + --host) 1351 + pathName=HOST_PATH; 1352 + shift 1353 + ;; 1354 + --build) 1355 + pathName=PATH; 1356 + shift 1357 + ;; 1358 + --update) 1359 + update=true; 1360 + shift 1361 + ;; 1362 + --) 1363 + shift; 1364 + break 1365 + ;; 1366 + -* | --*) 1367 + echo "Unknown option $1 supplied to patchShebangs" 1>&2; 1368 + return 1 1369 + ;; 1370 + *) 1371 + break 1372 + ;; 1373 + esac; 1374 + done; 1375 + echo "patching script interpreter paths in $@"; 1376 + local f; 1377 + local oldPath; 1378 + local newPath; 1379 + local arg0; 1380 + local args; 1381 + local oldInterpreterLine; 1382 + local newInterpreterLine; 1383 + if [[ $# -eq 0 ]]; then 1384 + echo "No arguments supplied to patchShebangs" 1>&2; 1385 + return 0; 1386 + fi; 1387 + local f; 1388 + while IFS= read -r -d '' f; do 1389 + isScript "$f" || continue; 1390 + read -r oldInterpreterLine < "$f" || [ "$oldInterpreterLine" ]; 1391 + read -r oldPath arg0 args <<< "${oldInterpreterLine:2}"; 1392 + if [[ -z "${pathName:-}" ]]; then 1393 + if [[ -n $strictDeps && $f == "$NIX_STORE"* ]]; then 1394 + pathName=HOST_PATH; 1395 + else 1396 + pathName=PATH; 1397 + fi; 1398 + fi; 1399 + if [[ "$oldPath" == *"/bin/env" ]]; then 1400 + if [[ $arg0 == "-S" ]]; then 1401 + arg0=${args%% *}; 1402 + args=${args#* }; 1403 + newPath="$(PATH="${!pathName}" command -v "env" || true)"; 1404 + args="-S $(PATH="${!pathName}" command -v "$arg0" || true) $args"; 1405 + else 1406 + if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then 1407 + echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 1>&2; 1408 + exit 1; 1409 + else 1410 + newPath="$(PATH="${!pathName}" command -v "$arg0" || true)"; 1411 + fi; 1412 + fi; 1413 + else 1414 + if [[ -z $oldPath ]]; then 1415 + oldPath="/bin/sh"; 1416 + fi; 1417 + newPath="$(PATH="${!pathName}" command -v "$(basename "$oldPath")" || true)"; 1418 + args="$arg0 $args"; 1419 + fi; 1420 + newInterpreterLine="$newPath $args"; 1421 + newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}}; 1422 + if [[ -n "$oldPath" && ( "$update" == true || "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ) ]]; then 1423 + if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then 1424 + echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""; 1425 + escapedInterpreterLine=${newInterpreterLine//\\/\\\\}; 1426 + timestamp=$(stat --printf "%y" "$f"); 1427 + sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"; 1428 + touch --date "$timestamp" "$f"; 1429 + fi; 1430 + fi; 1431 + done < <(find "$@" -type f -perm -0100 -print0) 1432 + } 1433 + patchShebangsAuto () 1434 + { 1435 + 1436 + if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then 1437 + if [[ "$output" != out && "$output" = "$outputDev" ]]; then 1438 + patchShebangs --build "$prefix"; 1439 + else 1440 + patchShebangs --host "$prefix"; 1441 + fi; 1442 + fi 1443 + } 1444 + prependToVar () 1445 + { 1446 + 1447 + local -n nameref="$1"; 1448 + local useArray type; 1449 + if [ -n "$__structuredAttrs" ]; then 1450 + useArray=true; 1451 + else 1452 + useArray=false; 1453 + fi; 1454 + if declare -p "$1" 2> /dev/null | grep -q '^'; then 1455 + type="$(declare -p "$1")"; 1456 + if [[ "$type" =~ "declare -A" ]]; then 1457 + echo "prependToVar(): ERROR: trying to use prependToVar on an associative array." 1>&2; 1458 + return 1; 1459 + else 1460 + if [[ "$type" =~ "declare -a" ]]; then 1461 + useArray=true; 1462 + else 1463 + useArray=false; 1464 + fi; 1465 + fi; 1466 + fi; 1467 + shift; 1468 + if $useArray; then 1469 + nameref=("$@" ${nameref+"${nameref[@]}"}); 1470 + else 1471 + nameref="$* ${nameref-}"; 1472 + fi 1473 + } 1474 + printLines () 1475 + { 1476 + 1477 + (( "$#" > 0 )) || return 0; 1478 + printf '%s\n' "$@" 1479 + } 1480 + printWords () 1481 + { 1482 + 1483 + (( "$#" > 0 )) || return 0; 1484 + printf '%s ' "$@" 1485 + } 1486 + recordPropagatedDependencies () 1487 + { 1488 + 1489 + declare -ra flatVars=(depsBuildBuildPropagated propagatedNativeBuildInputs depsBuildTargetPropagated depsHostHostPropagated propagatedBuildInputs depsTargetTargetPropagated); 1490 + declare -ra flatFiles=("${propagatedBuildDepFiles[@]}" "${propagatedHostDepFiles[@]}" "${propagatedTargetDepFiles[@]}"); 1491 + local propagatedInputsIndex; 1492 + for propagatedInputsIndex in "${!flatVars[@]}"; 1493 + do 1494 + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"; 1495 + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"; 1496 + [[ -n "${!propagatedInputsSlice}" ]] || continue; 1497 + mkdir -p "${!outputDev}/nix-support"; 1498 + printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"; 1499 + done 1500 + } 1501 + runHook () 1502 + { 1503 + 1504 + local hookName="$1"; 1505 + shift; 1506 + local hooksSlice="${hookName%Hook}Hooks[@]"; 1507 + local hook; 1508 + for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; 1509 + do 1510 + _eval "$hook" "$@"; 1511 + done; 1512 + return 0 1513 + } 1514 + runOneHook () 1515 + { 1516 + 1517 + local hookName="$1"; 1518 + shift; 1519 + local hooksSlice="${hookName%Hook}Hooks[@]"; 1520 + local hook ret=1; 1521 + for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; 1522 + do 1523 + if _eval "$hook" "$@"; then 1524 + ret=0; 1525 + break; 1526 + fi; 1527 + done; 1528 + return "$ret" 1529 + } 1530 + runPhase () 1531 + { 1532 + 1533 + local curPhase="$*"; 1534 + if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then 1535 + return; 1536 + fi; 1537 + if [[ "$curPhase" = patchPhase && -n "${dontPatch:-}" ]]; then 1538 + return; 1539 + fi; 1540 + if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then 1541 + return; 1542 + fi; 1543 + if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then 1544 + return; 1545 + fi; 1546 + if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then 1547 + return; 1548 + fi; 1549 + if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then 1550 + return; 1551 + fi; 1552 + if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then 1553 + return; 1554 + fi; 1555 + if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then 1556 + return; 1557 + fi; 1558 + if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then 1559 + return; 1560 + fi; 1561 + if [[ -n $NIX_LOG_FD ]]; then 1562 + echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" >&"$NIX_LOG_FD"; 1563 + fi; 1564 + showPhaseHeader "$curPhase"; 1565 + dumpVars; 1566 + local startTime=$(date +"%s"); 1567 + eval "${!curPhase:-$curPhase}"; 1568 + local endTime=$(date +"%s"); 1569 + showPhaseFooter "$curPhase" "$startTime" "$endTime"; 1570 + if [ "$curPhase" = unpackPhase ]; then 1571 + [ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"; 1572 + cd "${sourceRoot:-.}"; 1573 + fi 1574 + } 1575 + showPhaseFooter () 1576 + { 1577 + 1578 + local phase="$1"; 1579 + local startTime="$2"; 1580 + local endTime="$3"; 1581 + local delta=$(( endTime - startTime )); 1582 + (( delta < 30 )) && return; 1583 + local H=$((delta/3600)); 1584 + local M=$((delta%3600/60)); 1585 + local S=$((delta%60)); 1586 + echo -n "$phase completed in "; 1587 + (( H > 0 )) && echo -n "$H hours "; 1588 + (( M > 0 )) && echo -n "$M minutes "; 1589 + echo "$S seconds" 1590 + } 1591 + showPhaseHeader () 1592 + { 1593 + 1594 + local phase="$1"; 1595 + echo "Running phase: $phase" 1596 + } 1597 + stripDirs () 1598 + { 1599 + 1600 + local cmd="$1"; 1601 + local ranlibCmd="$2"; 1602 + local paths="$3"; 1603 + local stripFlags="$4"; 1604 + local excludeFlags=(); 1605 + local pathsNew=; 1606 + [ -z "$cmd" ] && echo "stripDirs: Strip command is empty" 1>&2 && exit 1; 1607 + [ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1; 1608 + local pattern; 1609 + if [ -n "${stripExclude:-}" ]; then 1610 + for pattern in "${stripExclude[@]}"; 1611 + do 1612 + excludeFlags+=(-a '!' '(' -name "$pattern" -o -wholename "$prefix/$pattern" ')'); 1613 + done; 1614 + fi; 1615 + local p; 1616 + for p in ${paths}; 1617 + do 1618 + if [ -e "$prefix/$p" ]; then 1619 + pathsNew="${pathsNew} $prefix/$p"; 1620 + fi; 1621 + done; 1622 + paths=${pathsNew}; 1623 + if [ -n "${paths}" ]; then 1624 + echo "stripping (with command $cmd and flags $stripFlags) in $paths"; 1625 + local striperr; 1626 + striperr="$(mktemp --tmpdir="$TMPDIR" 'striperr.XXXXXX')"; 1627 + find $paths -type f "${excludeFlags[@]}" -a '!' -path "$prefix/lib/debug/*" -print0 | xargs -r -0 -n1 -- realpath -z | sort -u -z | xargs -r -0 -n1 -P "$NIX_BUILD_CORES" -- $cmd $stripFlags 2> "$striperr" || exit_code=$?; 1628 + [[ "$exit_code" = 123 || -z "$exit_code" ]] || ( cat "$striperr" 1>&2 && exit 1 ); 1629 + rm "$striperr"; 1630 + find $paths -name '*.a' -type f -exec $ranlibCmd '{}' \; 2> /dev/null; 1631 + fi 1632 + } 1633 + stripHash () 1634 + { 1635 + 1636 + local strippedName casematchOpt=0; 1637 + strippedName="$(basename -- "$1")"; 1638 + shopt -q nocasematch && casematchOpt=1; 1639 + shopt -u nocasematch; 1640 + if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then 1641 + echo "${strippedName:33}"; 1642 + else 1643 + echo "$strippedName"; 1644 + fi; 1645 + if (( casematchOpt )); then 1646 + shopt -s nocasematch; 1647 + fi 1648 + } 1649 + substitute () 1650 + { 1651 + 1652 + local input="$1"; 1653 + local output="$2"; 1654 + shift 2; 1655 + if [ ! -f "$input" ]; then 1656 + echo "substitute(): ERROR: file '$input' does not exist" 1>&2; 1657 + return 1; 1658 + fi; 1659 + local content; 1660 + consumeEntire content < "$input"; 1661 + if [ -e "$output" ]; then 1662 + chmod +w "$output"; 1663 + fi; 1664 + substituteStream content "file '$input'" "$@" > "$output" 1665 + } 1666 + substituteAll () 1667 + { 1668 + 1669 + local input="$1"; 1670 + local output="$2"; 1671 + local -a args=(); 1672 + _allFlags; 1673 + substitute "$input" "$output" "${args[@]}" 1674 + } 1675 + substituteAllInPlace () 1676 + { 1677 + 1678 + local fileName="$1"; 1679 + shift; 1680 + substituteAll "$fileName" "$fileName" "$@" 1681 + } 1682 + substituteAllStream () 1683 + { 1684 + 1685 + local -a args=(); 1686 + _allFlags; 1687 + substituteStream "$1" "$2" "${args[@]}" 1688 + } 1689 + substituteInPlace () 1690 + { 1691 + 1692 + local -a fileNames=(); 1693 + for arg in "$@"; 1694 + do 1695 + if [[ "$arg" = "--"* ]]; then 1696 + break; 1697 + fi; 1698 + fileNames+=("$arg"); 1699 + shift; 1700 + done; 1701 + for file in "${fileNames[@]}"; 1702 + do 1703 + substitute "$file" "$file" "$@"; 1704 + done 1705 + } 1706 + substituteStream () 1707 + { 1708 + 1709 + local var=$1; 1710 + local description=$2; 1711 + shift 2; 1712 + while (( "$#" )); do 1713 + local replace_mode="$1"; 1714 + case "$1" in 1715 + --replace) 1716 + if ! "$_substituteStream_has_warned_replace_deprecation"; then 1717 + echo "substituteStream(): WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. ($description)" 1>&2; 1718 + _substituteStream_has_warned_replace_deprecation=true; 1719 + fi; 1720 + replace_mode='--replace-warn' 1721 + ;& 1722 + --replace-quiet | --replace-warn | --replace-fail) 1723 + pattern="$2"; 1724 + replacement="$3"; 1725 + shift 3; 1726 + local savedvar; 1727 + savedvar="${!var}"; 1728 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; 1729 + if [ "$pattern" != "$replacement" ]; then 1730 + if [ "${!var}" == "$savedvar" ]; then 1731 + if [ "$replace_mode" == --replace-warn ]; then 1732 + printf "substituteStream(): WARNING: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; 1733 + else 1734 + if [ "$replace_mode" == --replace-fail ]; then 1735 + printf "substituteStream(): ERROR: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; 1736 + return 1; 1737 + fi; 1738 + fi; 1739 + fi; 1740 + fi 1741 + ;; 1742 + --subst-var) 1743 + local varName="$2"; 1744 + shift 2; 1745 + if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then 1746 + echo "substituteStream(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." 1>&2; 1747 + return 1; 1748 + fi; 1749 + if [ -z ${!varName+x} ]; then 1750 + echo "substituteStream(): ERROR: variable \$$varName is unset" 1>&2; 1751 + return 1; 1752 + fi; 1753 + pattern="@$varName@"; 1754 + replacement="${!varName}"; 1755 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' 1756 + ;; 1757 + --subst-var-by) 1758 + pattern="@$2@"; 1759 + replacement="$3"; 1760 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; 1761 + shift 3 1762 + ;; 1763 + *) 1764 + echo "substituteStream(): ERROR: Invalid command line argument: $1" 1>&2; 1765 + return 1 1766 + ;; 1767 + esac; 1768 + done; 1769 + printf "%s" "${!var}" 1770 + } 1771 + unpackFile () 1772 + { 1773 + 1774 + curSrc="$1"; 1775 + echo "unpacking source archive $curSrc"; 1776 + if ! runOneHook unpackCmd "$curSrc"; then 1777 + echo "do not know how to unpack source archive $curSrc"; 1778 + exit 1; 1779 + fi 1780 + } 1781 + unpackPhase () 1782 + { 1783 + 1784 + runHook preUnpack; 1785 + if [ -z "${srcs:-}" ]; then 1786 + if [ -z "${src:-}" ]; then 1787 + echo 'variable $src or $srcs should point to the source'; 1788 + exit 1; 1789 + fi; 1790 + srcs="$src"; 1791 + fi; 1792 + local -a srcsArray; 1793 + if [ -n "$__structuredAttrs" ]; then 1794 + srcsArray=("${srcs[@]}"); 1795 + else 1796 + srcsArray=($srcs); 1797 + fi; 1798 + local dirsBefore=""; 1799 + for i in *; 1800 + do 1801 + if [ -d "$i" ]; then 1802 + dirsBefore="$dirsBefore $i "; 1803 + fi; 1804 + done; 1805 + for i in "${srcsArray[@]}"; 1806 + do 1807 + unpackFile "$i"; 1808 + done; 1809 + : "${sourceRoot=}"; 1810 + if [ -n "${setSourceRoot:-}" ]; then 1811 + runOneHook setSourceRoot; 1812 + else 1813 + if [ -z "$sourceRoot" ]; then 1814 + for i in *; 1815 + do 1816 + if [ -d "$i" ]; then 1817 + case $dirsBefore in 1818 + *\ $i\ *) 1819 + 1820 + ;; 1821 + *) 1822 + if [ -n "$sourceRoot" ]; then 1823 + echo "unpacker produced multiple directories"; 1824 + exit 1; 1825 + fi; 1826 + sourceRoot="$i" 1827 + ;; 1828 + esac; 1829 + fi; 1830 + done; 1831 + fi; 1832 + fi; 1833 + if [ -z "$sourceRoot" ]; then 1834 + echo "unpacker appears to have produced no directories"; 1835 + exit 1; 1836 + fi; 1837 + echo "source root is $sourceRoot"; 1838 + if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then 1839 + chmod -R u+w -- "$sourceRoot"; 1840 + fi; 1841 + runHook postUnpack 1842 + } 1843 + updateAutotoolsGnuConfigScriptsPhase () 1844 + { 1845 + 1846 + if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then 1847 + return; 1848 + fi; 1849 + for script in config.sub config.guess; 1850 + do 1851 + for f in $(find . -type f -name "$script"); 1852 + do 1853 + echo "Updating Autotools / GNU config script to a newer upstream version: $f"; 1854 + cp -f "/nix/store/zwkzkw313x6vmd9683h11rqaawyysz1s-gnu-config-2023-09-19/$script" "$f"; 1855 + done; 1856 + done 1857 + } 1858 + updateSourceDateEpoch () 1859 + { 1860 + 1861 + local path="$1"; 1862 + local -a res=($(find "$path" -type f -not -newer "$NIX_BUILD_TOP/.." -printf '%T@ %p\0' | sort -n --zero-terminated | tail -n1 --zero-terminated | head -c -1)); 1863 + local time="${res[0]//\.[0-9]*/}"; 1864 + local newestFile="${res[1]}"; 1865 + if [ "${time:-0}" -gt "$SOURCE_DATE_EPOCH" ]; then 1866 + echo "setting SOURCE_DATE_EPOCH to timestamp $time of file $newestFile"; 1867 + export SOURCE_DATE_EPOCH="$time"; 1868 + local now="$(date +%s)"; 1869 + if [ "$time" -gt $((now - 60)) ]; then 1870 + echo "warning: file $newestFile may be generated; SOURCE_DATE_EPOCH may be non-deterministic"; 1871 + fi; 1872 + fi 1873 + } 1874 + PATH="$PATH${nix_saved_PATH:+:$nix_saved_PATH}" 1875 + XDG_DATA_DIRS="$XDG_DATA_DIRS${nix_saved_XDG_DATA_DIRS:+:$nix_saved_XDG_DATA_DIRS}" 1876 + export NIX_BUILD_TOP="$(mktemp -d -t nix-shell.XXXXXX)" 1877 + export TMP="$NIX_BUILD_TOP" 1878 + export TMPDIR="$NIX_BUILD_TOP" 1879 + export TEMP="$NIX_BUILD_TOP" 1880 + export TEMPDIR="$NIX_BUILD_TOP" 1881 + eval "$shellHook"
Go/arrays/arrays.go Go/learn-go-with-tests/arrays/arrays.go
Go/arrays/arrays_test.go Go/learn-go-with-tests/arrays/arrays_test.go
Go/concurrency/concurrency.go Go/learn-go-with-tests/concurrency/concurrency.go
Go/concurrency/concurrency_test.go Go/learn-go-with-tests/concurrency/concurrency_test.go
Go/dependencyInjection/dependency.go Go/learn-go-with-tests/dependencyInjection/dependency.go
Go/dependencyInjection/dependency_test.go Go/learn-go-with-tests/dependencyInjection/dependency_test.go
Go/dictionary/dictionary.go Go/learn-go-with-tests/dictionary/dictionary.go
Go/dictionary/dictionary_test.go Go/learn-go-with-tests/dictionary/dictionary_test.go
Go/go.mod Go/learn-go-with-tests/go.mod
Go/helloworld/hello.go Go/learn-go-with-tests/helloworld/hello.go
Go/helloworld/hello_test.go Go/learn-go-with-tests/helloworld/hello_test.go
Go/integers/adder.go Go/learn-go-with-tests/integers/adder.go
Go/integers/adder_test.go Go/learn-go-with-tests/integers/adder_test.go
Go/iteration/repeat.go Go/learn-go-with-tests/iteration/repeat.go
Go/iteration/repeat_test.go Go/learn-go-with-tests/iteration/repeat_test.go
+15
Go/learn-go-with-tests/reflection/reflection.go
···
··· 1 + package main 2 + 3 + import "reflect" 4 + 5 + func walk(x interface{}, fn func(input string)){ 6 + val := reflect.ValueOf(x) 7 + 8 + for i := 0; i < val.NumField(); i++ { 9 + field := val.Field(i) 10 + 11 + if field.Kind() == reflect.String { 12 + fn(field.String()) 13 + } 14 + } 15 + }
+51
Go/learn-go-with-tests/reflection/reflection_test.go
···
··· 1 + package main 2 + 3 + import ( 4 + "reflect" 5 + "testing" 6 + ) 7 + 8 + func TestWalk(t *testing.T) { 9 + 10 + cases := []struct { 11 + Name string 12 + Input interface{} 13 + ExpectedCalls []string 14 + }{ 15 + { 16 + "struct with one string field", 17 + struct { Name string }{"Chris"}, 18 + []string{"Chris"}, 19 + }, 20 + { 21 + "struct with two string field", 22 + struct { 23 + Name string 24 + City string 25 + }{"Chris", "London"}, 26 + []string{"Chris", "London"}, 27 + }, 28 + { 29 + "struct with non string field", 30 + struct { 31 + Name string 32 + Age int 33 + }{"Chris", 33}, 34 + []string{"Chris"}, 35 + }, 36 + } 37 + 38 + for _, test := range cases { 39 + t.Run(test.Name, func(t *testing.T) { 40 + var got []string 41 + 42 + walk(test.Input, func(input string) { 43 + got = append(got, input) 44 + }) 45 + 46 + if !reflect.DeepEqual(got, test.ExpectedCalls) { 47 + t.Errorf("got %v, want %v", got, test.ExpectedCalls) 48 + } 49 + }) 50 + } 51 + }
Go/mocking/mocking.go Go/learn-go-with-tests/mocking/mocking.go
Go/mocking/mocking_test.go Go/learn-go-with-tests/mocking/mocking_test.go
Go/pointers/pointer.go Go/learn-go-with-tests/pointers/pointer.go
Go/pointers/pointer_test.go Go/learn-go-with-tests/pointers/pointer_test.go
Go/racer/racer.go Go/learn-go-with-tests/racer/racer.go
Go/racer/racer_test.go Go/learn-go-with-tests/racer/racer_test.go
Go/shapes/shapes.go Go/learn-go-with-tests/shapes/shapes.go
Go/shapes/shapes_test.go Go/learn-go-with-tests/shapes/shapes_test.go