A Gleam codegen library in Gleam

Initial Commit

Signed-off-by: Naomi Roberts <mia@naomieow.xyz>

lesbian.skin 947feea2

0/0
Waiting for spindle ...
+19
.direnv/bin/nix-direnv-reload
··· 1 + #!/usr/bin/env bash 2 + set -e 3 + if [[ ! -d "/home/naomi/Projects/stare" ]]; then 4 + echo "Cannot find source directory; Did you move it?" 5 + echo "(Looking for "/home/naomi/Projects/stare")" 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/naomi/Projects/stare" true 12 + 13 + # Update the mtime for .envrc. 14 + # This will cause direnv to reload again - but without re-building. 15 + touch "/home/naomi/Projects/stare/.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/naomi/Projects/stare/.envrc" "/home/naomi/Projects/stare/.direnv"/*.rc
+1
.direnv/flake-inputs/4bdm5fcwix168v4l6rr9p7a9iafgp6zs-source
··· 1 + /nix/store/4bdm5fcwix168v4l6rr9p7a9iafgp6zs-source
+1
.direnv/flake-inputs/m4wnrynr4sd7i8nn49dsr5hsa7b6rgm3-source
··· 1 + /nix/store/m4wnrynr4sd7i8nn49dsr5hsa7b6rgm3-source
+1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
··· 1 + /nix/store/xj4n30kdb30rg740bzgc6j7r83vc5ni0-nix-shell-env
+2125
.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/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin/bash' 11 + CC='gcc' 12 + export CC 13 + CONFIG_SHELL='/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin/bash' 14 + export CONFIG_SHELL 15 + CXX='g++' 16 + export CXX 17 + HOSTTYPE='x86_64' 18 + HOST_PATH='/nix/store/xbp2j3z0lhizr5vvzff4dgdcxgs8i2w7-coreutils-9.7/bin:/nix/store/bn3p3g6lsl0wa4ybrvik5rk4j5h3q7lb-findutils-4.10.0/bin:/nix/store/wjd5xfqk2cm55wfkc0nyxlg38d1h17x0-diffutils-3.12/bin:/nix/store/i74283mw5bncn16i0zbz0lvvq4sn0q87-gnused-4.9/bin:/nix/store/5ygilvgz6l47fw3x5ylb0cz1afgc3737-gnugrep-3.12/bin:/nix/store/0f4bvykzxsjvxh01jh1zai6s5jjlrach-gawk-5.3.2/bin:/nix/store/wa302h6k7rvrp6mzvq96swdyh3np0cyh-gnutar-1.35/bin:/nix/store/6w3g3nzyqqvhv36q2xj22k4d9vw3jl7h-gzip-1.14/bin:/nix/store/yiwcf5lsmalda0211g2nra5p20vmbp3q-bzip2-1.0.8-bin/bin:/nix/store/3aliwf9m0ji0fvpb6dg5hhp691fsvi1p-gnumake-4.4.1/bin:/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin:/nix/store/8j75alqms3ldbds4b4zip9mmy4af59ml-patch-2.8/bin:/nix/store/fksqvzy6pc1a4rbpyyiq4932m22aq5h4-xz-5.8.1-bin/bin:/nix/store/z08sfbfszjqfd52v6ccw35l332rfskz6-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/ky2x48xfid0nn5arablpwlnsngj70gws-binutils-wrapper-2.44' 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='12' 33 + export NIX_BUILD_CORES 34 + NIX_CC='/nix/store/bcw9f6r9v2fm3kv7d15fcrya0mf34xds-gcc-wrapper-14.3.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=xj4n30kdb3' 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 stackclashprotection stackprotector strictoverflow zerocallusedregs' 43 + export NIX_HARDENING_ENABLE 44 + NIX_LDFLAGS='-rpath /home/naomi/Projects/stare/outputs/out/lib -L/nix/store/iq81zapms5601xf1v22yd1bbag9fa0nd-gleam-1.12.0/lib -L/nix/store/iq81zapms5601xf1v22yd1bbag9fa0nd-gleam-1.12.0/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/iq81zapms5601xf1v22yd1bbag9fa0nd-gleam-1.12.0/bin:/nix/store/z74806vcdf6jdxcqv7v0gfwd3lf8z0h7-erlang-28.0.2/bin:/nix/store/fpypbb4708427dmhlxnsyww74hf50mjf-rebar3-3.25.1/bin:/nix/store/b3rsa3r13bkp8hr5g3pncxpb6b3crvxl-patchelf-0.15.0/bin:/nix/store/bcw9f6r9v2fm3kv7d15fcrya0mf34xds-gcc-wrapper-14.3.0/bin:/nix/store/qdknxw57cwy1jkrhq7fzmiis73j42jv6-gcc-14.3.0/bin:/nix/store/j941hd82ybw2czd7lgf3xwccmqy9281h-glibc-2.40-66-bin/bin:/nix/store/xbp2j3z0lhizr5vvzff4dgdcxgs8i2w7-coreutils-9.7/bin:/nix/store/ky2x48xfid0nn5arablpwlnsngj70gws-binutils-wrapper-2.44/bin:/nix/store/xrwdb41dqi2ia6lr2s61w5bzfg2m71pi-binutils-2.44/bin:/nix/store/xbp2j3z0lhizr5vvzff4dgdcxgs8i2w7-coreutils-9.7/bin:/nix/store/bn3p3g6lsl0wa4ybrvik5rk4j5h3q7lb-findutils-4.10.0/bin:/nix/store/wjd5xfqk2cm55wfkc0nyxlg38d1h17x0-diffutils-3.12/bin:/nix/store/i74283mw5bncn16i0zbz0lvvq4sn0q87-gnused-4.9/bin:/nix/store/5ygilvgz6l47fw3x5ylb0cz1afgc3737-gnugrep-3.12/bin:/nix/store/0f4bvykzxsjvxh01jh1zai6s5jjlrach-gawk-5.3.2/bin:/nix/store/wa302h6k7rvrp6mzvq96swdyh3np0cyh-gnutar-1.35/bin:/nix/store/6w3g3nzyqqvhv36q2xj22k4d9vw3jl7h-gzip-1.14/bin:/nix/store/yiwcf5lsmalda0211g2nra5p20vmbp3q-bzip2-1.0.8-bin/bin:/nix/store/3aliwf9m0ji0fvpb6dg5hhp691fsvi1p-gnumake-4.4.1/bin:/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin:/nix/store/8j75alqms3ldbds4b4zip9mmy4af59ml-patch-2.8/bin:/nix/store/fksqvzy6pc1a4rbpyyiq4932m22aq5h4-xz-5.8.1-bin/bin:/nix/store/z08sfbfszjqfd52v6ccw35l332rfskz6-file-5.45/bin' 60 + export PATH 61 + PS4='+ ' 62 + RANLIB='ranlib' 63 + export RANLIB 64 + READELF='readelf' 65 + export READELF 66 + SHELL='/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin/bash' 67 + export SHELL 68 + SIZE='size' 69 + export SIZE 70 + SOURCE_DATE_EPOCH='315532800' 71 + export SOURCE_DATE_EPOCH 72 + STRINGS='strings' 73 + export STRINGS 74 + STRIP='strip' 75 + export STRIP 76 + XDG_DATA_DIRS='/nix/store/b3rsa3r13bkp8hr5g3pncxpb6b3crvxl-patchelf-0.15.0/share' 77 + export XDG_DATA_DIRS 78 + __structuredAttrs='' 79 + export __structuredAttrs 80 + _substituteStream_has_warned_replace_deprecation='false' 81 + buildInputs='' 82 + export buildInputs 83 + buildPhase='{ echo "------------------------------------------------------------"; 84 + echo " WARNING: the existence of this path is not guaranteed."; 85 + echo " It is an internal implementation detail for pkgs.mkShell."; 86 + echo "------------------------------------------------------------"; 87 + echo; 88 + # Record all build inputs as runtime dependencies 89 + export; 90 + } >> "$out" 91 + ' 92 + export buildPhase 93 + builder='/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin/bash' 94 + export builder 95 + cmakeFlags='' 96 + export cmakeFlags 97 + configureFlags='' 98 + export configureFlags 99 + defaultBuildInputs='' 100 + defaultNativeBuildInputs='/nix/store/b3rsa3r13bkp8hr5g3pncxpb6b3crvxl-patchelf-0.15.0 /nix/store/y1khqn4bmkx7vxbmgsdpp5vi81500zhb-update-autotools-gnu-config-scripts-hook /nix/store/0y5xmdb7qfvimjwbq7ibg1xdgkgjwqng-no-broken-symlinks.sh /nix/store/cv1d7p48379km6a85h4zp6kr86brh32q-audit-tmpdir.sh /nix/store/4bawv6x85435v6s624sfk5cdpg9gr6yq-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/cmzya9irvxzlkh7lfy6i82gbp0saxqj3-multiple-outputs.sh /nix/store/x8c40nfigps493a07sdr2pm5s9j1cdc0-patch-shebangs.sh /nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh /nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh /nix/store/z7k98578dfzi6l3hsvbivzm7hfqlk0zc-set-source-date-epoch-to-latest.sh /nix/store/pilsssjjdxvdphlg2h19p0bfx5q0jzkn-strip.sh /nix/store/bcw9f6r9v2fm3kv7d15fcrya0mf34xds-gcc-wrapper-14.3.0' 101 + depsBuildBuild='' 102 + export depsBuildBuild 103 + depsBuildBuildPropagated='' 104 + export depsBuildBuildPropagated 105 + depsBuildTarget='' 106 + export depsBuildTarget 107 + depsBuildTargetPropagated='' 108 + export depsBuildTargetPropagated 109 + depsHostHost='' 110 + export depsHostHost 111 + depsHostHostPropagated='' 112 + export depsHostHostPropagated 113 + depsTargetTarget='' 114 + export depsTargetTarget 115 + depsTargetTargetPropagated='' 116 + export depsTargetTargetPropagated 117 + doCheck='' 118 + export doCheck 119 + doInstallCheck='' 120 + export doInstallCheck 121 + dontAddDisableDepTrack='1' 122 + export dontAddDisableDepTrack 123 + declare -a envBuildBuildHooks=() 124 + declare -a envBuildHostHooks=() 125 + declare -a envBuildTargetHooks=() 126 + declare -a envHostHostHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) 127 + declare -a envHostTargetHooks=('ccWrapper_addCVars' 'bintoolsWrapper_addLDVars' ) 128 + declare -a envTargetTargetHooks=() 129 + 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' ) 130 + guess='12' 131 + initialPath='/nix/store/xbp2j3z0lhizr5vvzff4dgdcxgs8i2w7-coreutils-9.7 /nix/store/bn3p3g6lsl0wa4ybrvik5rk4j5h3q7lb-findutils-4.10.0 /nix/store/wjd5xfqk2cm55wfkc0nyxlg38d1h17x0-diffutils-3.12 /nix/store/i74283mw5bncn16i0zbz0lvvq4sn0q87-gnused-4.9 /nix/store/5ygilvgz6l47fw3x5ylb0cz1afgc3737-gnugrep-3.12 /nix/store/0f4bvykzxsjvxh01jh1zai6s5jjlrach-gawk-5.3.2 /nix/store/wa302h6k7rvrp6mzvq96swdyh3np0cyh-gnutar-1.35 /nix/store/6w3g3nzyqqvhv36q2xj22k4d9vw3jl7h-gzip-1.14 /nix/store/yiwcf5lsmalda0211g2nra5p20vmbp3q-bzip2-1.0.8-bin /nix/store/3aliwf9m0ji0fvpb6dg5hhp691fsvi1p-gnumake-4.4.1 /nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3 /nix/store/8j75alqms3ldbds4b4zip9mmy4af59ml-patch-2.8 /nix/store/fksqvzy6pc1a4rbpyyiq4932m22aq5h4-xz-5.8.1-bin /nix/store/z08sfbfszjqfd52v6ccw35l332rfskz6-file-5.45' 132 + mesonFlags='' 133 + export mesonFlags 134 + name='nix-shell-env' 135 + export name 136 + nativeBuildInputs='/nix/store/iq81zapms5601xf1v22yd1bbag9fa0nd-gleam-1.12.0 /nix/store/z74806vcdf6jdxcqv7v0gfwd3lf8z0h7-erlang-28.0.2 /nix/store/fpypbb4708427dmhlxnsyww74hf50mjf-rebar3-3.25.1' 137 + export nativeBuildInputs 138 + out='/home/naomi/Projects/stare/outputs/out' 139 + export out 140 + outputBin='out' 141 + outputDev='out' 142 + outputDevdoc='REMOVE' 143 + outputDevman='out' 144 + outputDoc='out' 145 + outputInclude='out' 146 + outputInfo='out' 147 + outputLib='out' 148 + outputMan='out' 149 + outputs='out' 150 + export outputs 151 + patches='' 152 + export patches 153 + phases='buildPhase' 154 + export phases 155 + pkg='/nix/store/bcw9f6r9v2fm3kv7d15fcrya0mf34xds-gcc-wrapper-14.3.0' 156 + declare -a pkgsBuildBuild=() 157 + declare -a pkgsBuildHost=('/nix/store/iq81zapms5601xf1v22yd1bbag9fa0nd-gleam-1.12.0' '/nix/store/z74806vcdf6jdxcqv7v0gfwd3lf8z0h7-erlang-28.0.2' '/nix/store/fpypbb4708427dmhlxnsyww74hf50mjf-rebar3-3.25.1' '/nix/store/b3rsa3r13bkp8hr5g3pncxpb6b3crvxl-patchelf-0.15.0' '/nix/store/y1khqn4bmkx7vxbmgsdpp5vi81500zhb-update-autotools-gnu-config-scripts-hook' '/nix/store/0y5xmdb7qfvimjwbq7ibg1xdgkgjwqng-no-broken-symlinks.sh' '/nix/store/cv1d7p48379km6a85h4zp6kr86brh32q-audit-tmpdir.sh' '/nix/store/4bawv6x85435v6s624sfk5cdpg9gr6yq-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/cmzya9irvxzlkh7lfy6i82gbp0saxqj3-multiple-outputs.sh' '/nix/store/x8c40nfigps493a07sdr2pm5s9j1cdc0-patch-shebangs.sh' '/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh' '/nix/store/xyff06pkhki3qy1ls77w10s0v79c9il0-reproducible-builds.sh' '/nix/store/z7k98578dfzi6l3hsvbivzm7hfqlk0zc-set-source-date-epoch-to-latest.sh' '/nix/store/pilsssjjdxvdphlg2h19p0bfx5q0jzkn-strip.sh' '/nix/store/bcw9f6r9v2fm3kv7d15fcrya0mf34xds-gcc-wrapper-14.3.0' '/nix/store/ky2x48xfid0nn5arablpwlnsngj70gws-binutils-wrapper-2.44' ) 158 + declare -a pkgsBuildTarget=() 159 + declare -a pkgsHostHost=() 160 + declare -a pkgsHostTarget=() 161 + declare -a pkgsTargetTarget=() 162 + declare -a postFixupHooks=('noBrokenSymlinksInAllOutputs' '_makeSymlinksRelativeInAllOutputs' '_multioutPropagateDev' ) 163 + declare -a postUnpackHooks=('_updateSourceDateEpochFromSourceRoot' ) 164 + declare -a preConfigureHooks=('_multioutConfig' ) 165 + preConfigurePhases=' updateAutotoolsGnuConfigScriptsPhase' 166 + declare -a preFixupHooks=('_moveToShare' '_multioutDocs' '_multioutDevs' ) 167 + preferLocalBuild='1' 168 + export preferLocalBuild 169 + prefix='/home/naomi/Projects/stare/outputs/out' 170 + declare -a propagatedBuildDepFiles=('propagated-build-build-deps' 'propagated-native-build-inputs' 'propagated-build-target-deps' ) 171 + propagatedBuildInputs='' 172 + export propagatedBuildInputs 173 + declare -a propagatedHostDepFiles=('propagated-host-host-deps' 'propagated-build-inputs' ) 174 + propagatedNativeBuildInputs='' 175 + export propagatedNativeBuildInputs 176 + declare -a propagatedTargetDepFiles=('propagated-target-target-deps' ) 177 + shell='/nix/store/4bacfs7zrg714ffffbjp57nsvcz6zfkq-bash-5.3p3/bin/bash' 178 + export shell 179 + shellHook='' 180 + export shellHook 181 + stdenv='/nix/store/i2ph69njb7121m5z49mjmiy4bqjd6vrl-stdenv-linux' 182 + export stdenv 183 + strictDeps='' 184 + export strictDeps 185 + system='x86_64-linux' 186 + export system 187 + declare -a unpackCmdHooks=('_defaultUnpack' ) 188 + _activatePkgs () 189 + { 190 + 191 + local hostOffset targetOffset; 192 + local pkg; 193 + for hostOffset in "${allPlatOffsets[@]}"; 194 + do 195 + local pkgsVar="${pkgAccumVarVars[hostOffset + 1]}"; 196 + for targetOffset in "${allPlatOffsets[@]}"; 197 + do 198 + (( hostOffset <= targetOffset )) || continue; 199 + local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"; 200 + local pkgsSlice="${!pkgsRef}[@]"; 201 + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; 202 + do 203 + activatePackage "$pkg" "$hostOffset" "$targetOffset"; 204 + done; 205 + done; 206 + done 207 + } 208 + _addRpathPrefix () 209 + { 210 + 211 + if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then 212 + export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}"; 213 + fi 214 + } 215 + _addToEnv () 216 + { 217 + 218 + local depHostOffset depTargetOffset; 219 + local pkg; 220 + for depHostOffset in "${allPlatOffsets[@]}"; 221 + do 222 + local hookVar="${pkgHookVarVars[depHostOffset + 1]}"; 223 + local pkgsVar="${pkgAccumVarVars[depHostOffset + 1]}"; 224 + for depTargetOffset in "${allPlatOffsets[@]}"; 225 + do 226 + (( depHostOffset <= depTargetOffset )) || continue; 227 + local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"; 228 + if [[ -z "${strictDeps-}" ]]; then 229 + local visitedPkgs=""; 230 + for pkg in "${pkgsBuildBuild[@]}" "${pkgsBuildHost[@]}" "${pkgsBuildTarget[@]}" "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}" "${pkgsTargetTarget[@]}"; 231 + do 232 + if [[ "$visitedPkgs" = *"$pkg"* ]]; then 233 + continue; 234 + fi; 235 + runHook "${!hookRef}" "$pkg"; 236 + visitedPkgs+=" $pkg"; 237 + done; 238 + else 239 + local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"; 240 + local pkgsSlice="${!pkgsRef}[@]"; 241 + for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; 242 + do 243 + runHook "${!hookRef}" "$pkg"; 244 + done; 245 + fi; 246 + done; 247 + done 248 + } 249 + _allFlags () 250 + { 251 + 252 + export system pname name version; 253 + while IFS='' read -r varName; do 254 + nixTalkativeLog "@${varName}@ -> ${!varName}"; 255 + args+=("--subst-var" "$varName"); 256 + done < <(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }') 257 + } 258 + _assignFirst () 259 + { 260 + 261 + local varName="$1"; 262 + local _var; 263 + local REMOVE=REMOVE; 264 + shift; 265 + for _var in "$@"; 266 + do 267 + if [ -n "${!_var-}" ]; then 268 + eval "${varName}"="${_var}"; 269 + return; 270 + fi; 271 + done; 272 + echo; 273 + echo "error: _assignFirst: could not find a non-empty variable whose name to assign to ${varName}."; 274 + echo " The following variables were all unset or empty:"; 275 + echo " $*"; 276 + if [ -z "${out:-}" ]; then 277 + echo ' If you do not want an "out" output in your derivation, make sure to define'; 278 + echo ' the other specific required outputs. This can be achieved by picking one'; 279 + echo " of the above as an output."; 280 + echo ' You do not have to remove "out" if you want to have a different default'; 281 + echo ' output, because the first output is taken as a default.'; 282 + echo; 283 + fi; 284 + return 1 285 + } 286 + _callImplicitHook () 287 + { 288 + 289 + local def="$1"; 290 + local hookName="$2"; 291 + if declare -F "$hookName" > /dev/null; then 292 + nixTalkativeLog "calling implicit '$hookName' function hook"; 293 + "$hookName"; 294 + else 295 + if type -p "$hookName" > /dev/null; then 296 + nixTalkativeLog "sourcing implicit '$hookName' script hook"; 297 + source "$hookName"; 298 + else 299 + if [ -n "${!hookName:-}" ]; then 300 + nixTalkativeLog "evaling implicit '$hookName' string hook"; 301 + eval "${!hookName}"; 302 + else 303 + return "$def"; 304 + fi; 305 + fi; 306 + fi 307 + } 308 + _defaultUnpack () 309 + { 310 + 311 + local fn="$1"; 312 + local destination; 313 + if [ -d "$fn" ]; then 314 + destination="$(stripHash "$fn")"; 315 + if [ -e "$destination" ]; then 316 + echo "Cannot copy $fn to $destination: destination already exists!"; 317 + echo "Did you specify two \"srcs\" with the same \"name\"?"; 318 + return 1; 319 + fi; 320 + cp -r --preserve=timestamps --reflink=auto -- "$fn" "$destination"; 321 + else 322 + case "$fn" in 323 + *.tar.xz | *.tar.lzma | *.txz) 324 + ( XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < "$fn"; 325 + true ) | tar xf - --mode=+w --warning=no-timestamp 326 + ;; 327 + *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz) 328 + tar xf "$fn" --mode=+w --warning=no-timestamp 329 + ;; 330 + *) 331 + return 1 332 + ;; 333 + esac; 334 + fi 335 + } 336 + _doStrip () 337 + { 338 + 339 + local -ra flags=(dontStripHost dontStripTarget); 340 + local -ra debugDirs=(stripDebugList stripDebugListTarget); 341 + local -ra allDirs=(stripAllList stripAllListTarget); 342 + local -ra stripCmds=(STRIP STRIP_FOR_TARGET); 343 + local -ra ranlibCmds=(RANLIB RANLIB_FOR_TARGET); 344 + stripDebugList=${stripDebugList[*]:-lib lib32 lib64 libexec bin sbin Applications Library/Frameworks}; 345 + stripDebugListTarget=${stripDebugListTarget[*]:-}; 346 + stripAllList=${stripAllList[*]:-}; 347 + stripAllListTarget=${stripAllListTarget[*]:-}; 348 + local i; 349 + for i in ${!stripCmds[@]}; 350 + do 351 + local -n flag="${flags[$i]}"; 352 + local -n debugDirList="${debugDirs[$i]}"; 353 + local -n allDirList="${allDirs[$i]}"; 354 + local -n stripCmd="${stripCmds[$i]}"; 355 + local -n ranlibCmd="${ranlibCmds[$i]}"; 356 + if [[ -n "${dontStrip-}" || -n "${flag-}" ]] || ! type -f "${stripCmd-}" 2> /dev/null 1>&2; then 357 + continue; 358 + fi; 359 + stripDirs "$stripCmd" "$ranlibCmd" "$debugDirList" "${stripDebugFlags[*]:--S -p}"; 360 + stripDirs "$stripCmd" "$ranlibCmd" "$allDirList" "${stripAllFlags[*]:--s -p}"; 361 + done 362 + } 363 + _eval () 364 + { 365 + 366 + if declare -F "$1" > /dev/null 2>&1; then 367 + "$@"; 368 + else 369 + eval "$1"; 370 + fi 371 + } 372 + _logHook () 373 + { 374 + 375 + if [[ -z ${NIX_LOG_FD-} ]]; then 376 + return; 377 + fi; 378 + local hookKind="$1"; 379 + local hookExpr="$2"; 380 + shift 2; 381 + if declare -F "$hookExpr" > /dev/null 2>&1; then 382 + nixTalkativeLog "calling '$hookKind' function hook '$hookExpr'" "$@"; 383 + else 384 + if type -p "$hookExpr" > /dev/null; then 385 + nixTalkativeLog "sourcing '$hookKind' script hook '$hookExpr'"; 386 + else 387 + if [[ "$hookExpr" != "_callImplicitHook"* ]]; then 388 + local exprToOutput; 389 + if [[ ${NIX_DEBUG:-0} -ge 5 ]]; then 390 + exprToOutput="$hookExpr"; 391 + else 392 + local hookExprLine; 393 + while IFS= read -r hookExprLine; do 394 + hookExprLine="${hookExprLine#"${hookExprLine%%[![:space:]]*}"}"; 395 + if [[ -n "$hookExprLine" ]]; then 396 + exprToOutput+="$hookExprLine\\n "; 397 + fi; 398 + done <<< "$hookExpr"; 399 + exprToOutput="${exprToOutput%%\\n }"; 400 + fi; 401 + nixTalkativeLog "evaling '$hookKind' string hook '$exprToOutput'"; 402 + fi; 403 + fi; 404 + fi 405 + } 406 + _makeSymlinksRelative () 407 + { 408 + 409 + local symlinkTarget; 410 + if [ "${dontRewriteSymlinks-}" ] || [ ! -e "$prefix" ]; then 411 + return; 412 + fi; 413 + while IFS= read -r -d '' f; do 414 + symlinkTarget=$(readlink "$f"); 415 + if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then 416 + continue; 417 + fi; 418 + if [ ! -e "$symlinkTarget" ]; then 419 + echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"; 420 + fi; 421 + echo "rewriting symlink $f to be relative to $prefix"; 422 + ln -snrf "$symlinkTarget" "$f"; 423 + done < <(find $prefix -type l -print0) 424 + } 425 + _makeSymlinksRelativeInAllOutputs () 426 + { 427 + 428 + local output; 429 + for output in $(getAllOutputNames); 430 + do 431 + prefix="${!output}" _makeSymlinksRelative; 432 + done 433 + } 434 + _moveLib64 () 435 + { 436 + 437 + if [ "${dontMoveLib64-}" = 1 ]; then 438 + return; 439 + fi; 440 + if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then 441 + return; 442 + fi; 443 + echo "moving $prefix/lib64/* to $prefix/lib"; 444 + mkdir -p $prefix/lib; 445 + shopt -s dotglob; 446 + for i in $prefix/lib64/*; 447 + do 448 + mv --no-clobber "$i" $prefix/lib; 449 + done; 450 + shopt -u dotglob; 451 + rmdir $prefix/lib64; 452 + ln -s lib $prefix/lib64 453 + } 454 + _moveSbin () 455 + { 456 + 457 + if [ "${dontMoveSbin-}" = 1 ]; then 458 + return; 459 + fi; 460 + if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then 461 + return; 462 + fi; 463 + echo "moving $prefix/sbin/* to $prefix/bin"; 464 + mkdir -p $prefix/bin; 465 + shopt -s dotglob; 466 + for i in $prefix/sbin/*; 467 + do 468 + mv "$i" $prefix/bin; 469 + done; 470 + shopt -u dotglob; 471 + rmdir $prefix/sbin; 472 + ln -s bin $prefix/sbin 473 + } 474 + _moveSystemdUserUnits () 475 + { 476 + 477 + if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then 478 + return; 479 + fi; 480 + if [ ! -e "${prefix:?}/lib/systemd/user" ]; then 481 + return; 482 + fi; 483 + local source="$prefix/lib/systemd/user"; 484 + local target="$prefix/share/systemd/user"; 485 + echo "moving $source/* to $target"; 486 + mkdir -p "$target"; 487 + ( shopt -s dotglob; 488 + for i in "$source"/*; 489 + do 490 + mv "$i" "$target"; 491 + done ); 492 + rmdir "$source"; 493 + ln -s "$target" "$source" 494 + } 495 + _moveToShare () 496 + { 497 + 498 + if [ -n "$__structuredAttrs" ]; then 499 + if [ -z "${forceShare-}" ]; then 500 + forceShare=(man doc info); 501 + fi; 502 + else 503 + forceShare=(${forceShare:-man doc info}); 504 + fi; 505 + if [[ -z "$out" ]]; then 506 + return; 507 + fi; 508 + for d in "${forceShare[@]}"; 509 + do 510 + if [ -d "$out/$d" ]; then 511 + if [ -d "$out/share/$d" ]; then 512 + echo "both $d/ and share/$d/ exist!"; 513 + else 514 + echo "moving $out/$d to $out/share/$d"; 515 + mkdir -p $out/share; 516 + mv $out/$d $out/share/; 517 + fi; 518 + fi; 519 + done 520 + } 521 + _multioutConfig () 522 + { 523 + 524 + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${setOutputFlags-1}" ]; then 525 + return; 526 + fi; 527 + if [ -z "${shareDocName:-}" ]; then 528 + local confScript="${configureScript:-}"; 529 + if [ -z "$confScript" ] && [ -x ./configure ]; then 530 + confScript=./configure; 531 + fi; 532 + if [ -f "$confScript" ]; then 533 + local shareDocName="$(sed -n "s/^PACKAGE_TARNAME='\(.*\)'$/\1/p" < "$confScript")"; 534 + fi; 535 + if [ -z "$shareDocName" ] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_-]'; then 536 + shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"; 537 + fi; 538 + fi; 539 + prependToVar configureFlags --bindir="${!outputBin}"/bin --sbindir="${!outputBin}"/sbin --includedir="${!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; 540 + prependToVar installFlags pkgconfigdir="${!outputDev}"/lib/pkgconfig m4datadir="${!outputDev}"/share/aclocal aclocaldir="${!outputDev}"/share/aclocal 541 + } 542 + _multioutDevs () 543 + { 544 + 545 + if [ "$(getAllOutputNames)" = "out" ] || [ -z "${moveToDev-1}" ]; then 546 + return; 547 + fi; 548 + moveToOutput include "${!outputInclude}"; 549 + moveToOutput lib/pkgconfig "${!outputDev}"; 550 + moveToOutput share/pkgconfig "${!outputDev}"; 551 + moveToOutput lib/cmake "${!outputDev}"; 552 + moveToOutput share/aclocal "${!outputDev}"; 553 + for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; 554 + do 555 + echo "Patching '$f' includedir to output ${!outputInclude}"; 556 + sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"; 557 + done 558 + } 559 + _multioutDocs () 560 + { 561 + 562 + local REMOVE=REMOVE; 563 + moveToOutput share/info "${!outputInfo}"; 564 + moveToOutput share/doc "${!outputDoc}"; 565 + moveToOutput share/gtk-doc "${!outputDevdoc}"; 566 + moveToOutput share/devhelp/books "${!outputDevdoc}"; 567 + moveToOutput share/man "${!outputMan}"; 568 + moveToOutput share/man/man3 "${!outputDevman}" 569 + } 570 + _multioutPropagateDev () 571 + { 572 + 573 + if [ "$(getAllOutputNames)" = "out" ]; then 574 + return; 575 + fi; 576 + local outputFirst; 577 + for outputFirst in $(getAllOutputNames); 578 + do 579 + break; 580 + done; 581 + local propagaterOutput="$outputDev"; 582 + if [ -z "$propagaterOutput" ]; then 583 + propagaterOutput="$outputFirst"; 584 + fi; 585 + if [ -z "${propagatedBuildOutputs+1}" ]; then 586 + local po_dirty="$outputBin $outputInclude $outputLib"; 587 + set +o pipefail; 588 + propagatedBuildOutputs=`echo "$po_dirty" | tr -s ' ' '\n' | grep -v -F "$propagaterOutput" | sort -u | tr '\n' ' ' `; 589 + set -o pipefail; 590 + fi; 591 + if [ -z "$propagatedBuildOutputs" ]; then 592 + return; 593 + fi; 594 + mkdir -p "${!propagaterOutput}"/nix-support; 595 + for output in $propagatedBuildOutputs; 596 + do 597 + echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/propagated-build-inputs; 598 + done 599 + } 600 + _nixLogWithLevel () 601 + { 602 + 603 + [[ -z ${NIX_LOG_FD-} || ${NIX_DEBUG:-0} -lt ${1:?} ]] && return 0; 604 + local logLevel; 605 + case "${1:?}" in 606 + 0) 607 + logLevel=ERROR 608 + ;; 609 + 1) 610 + logLevel=WARN 611 + ;; 612 + 2) 613 + logLevel=NOTICE 614 + ;; 615 + 3) 616 + logLevel=INFO 617 + ;; 618 + 4) 619 + logLevel=TALKATIVE 620 + ;; 621 + 5) 622 + logLevel=CHATTY 623 + ;; 624 + 6) 625 + logLevel=DEBUG 626 + ;; 627 + 7) 628 + logLevel=VOMIT 629 + ;; 630 + *) 631 + echo "_nixLogWithLevel: called with invalid log level: ${1:?}" >&"$NIX_LOG_FD"; 632 + return 1 633 + ;; 634 + esac; 635 + local callerName="${FUNCNAME[2]}"; 636 + if [[ $callerName == "_callImplicitHook" ]]; then 637 + callerName="${hookName:?}"; 638 + fi; 639 + printf "%s: %s: %s\n" "$logLevel" "$callerName" "${2:?}" >&"$NIX_LOG_FD" 640 + } 641 + _overrideFirst () 642 + { 643 + 644 + if [ -z "${!1-}" ]; then 645 + _assignFirst "$@"; 646 + fi 647 + } 648 + _pruneLibtoolFiles () 649 + { 650 + 651 + if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then 652 + return; 653 + fi; 654 + 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" \; 655 + } 656 + _updateSourceDateEpochFromSourceRoot () 657 + { 658 + 659 + if [ -n "$sourceRoot" ]; then 660 + updateSourceDateEpoch "$sourceRoot"; 661 + fi 662 + } 663 + activatePackage () 664 + { 665 + 666 + local pkg="$1"; 667 + local -r hostOffset="$2"; 668 + local -r targetOffset="$3"; 669 + (( hostOffset <= targetOffset )) || exit 1; 670 + if [ -f "$pkg" ]; then 671 + nixTalkativeLog "sourcing setup hook '$pkg'"; 672 + source "$pkg"; 673 + fi; 674 + if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then 675 + addToSearchPath _PATH "$pkg/bin"; 676 + fi; 677 + if (( hostOffset <= -1 )); then 678 + addToSearchPath _XDG_DATA_DIRS "$pkg/share"; 679 + fi; 680 + if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then 681 + addToSearchPath _HOST_PATH "$pkg/bin"; 682 + fi; 683 + if [[ -f "$pkg/nix-support/setup-hook" ]]; then 684 + nixTalkativeLog "sourcing setup hook '$pkg/nix-support/setup-hook'"; 685 + source "$pkg/nix-support/setup-hook"; 686 + fi 687 + } 688 + addEnvHooks () 689 + { 690 + 691 + local depHostOffset="$1"; 692 + shift; 693 + local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"; 694 + local pkgHookVar; 695 + for pkgHookVar in "${!pkgHookVarsSlice}"; 696 + do 697 + eval "${pkgHookVar}s"'+=("$@")'; 698 + done 699 + } 700 + addToSearchPath () 701 + { 702 + 703 + addToSearchPathWithCustomDelimiter ":" "$@" 704 + } 705 + addToSearchPathWithCustomDelimiter () 706 + { 707 + 708 + local delimiter="$1"; 709 + local varName="$2"; 710 + local dir="$3"; 711 + if [[ -d "$dir" && "${!varName:+${delimiter}${!varName}${delimiter}}" != *"${delimiter}${dir}${delimiter}"* ]]; then 712 + export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"; 713 + fi 714 + } 715 + appendToVar () 716 + { 717 + 718 + local -n nameref="$1"; 719 + local useArray type; 720 + if [ -n "$__structuredAttrs" ]; then 721 + useArray=true; 722 + else 723 + useArray=false; 724 + fi; 725 + if type=$(declare -p "$1" 2> /dev/null); then 726 + case "${type#* }" in 727 + -A*) 728 + echo "appendToVar(): ERROR: trying to use appendToVar on an associative array, use variable+=([\"X\"]=\"Y\") instead." 1>&2; 729 + return 1 730 + ;; 731 + -a*) 732 + useArray=true 733 + ;; 734 + *) 735 + useArray=false 736 + ;; 737 + esac; 738 + fi; 739 + shift; 740 + if $useArray; then 741 + nameref=(${nameref+"${nameref[@]}"} "$@"); 742 + else 743 + nameref="${nameref-} $*"; 744 + fi 745 + } 746 + auditTmpdir () 747 + { 748 + 749 + local dir="$1"; 750 + [ -e "$dir" ] || return 0; 751 + echo "checking for references to $TMPDIR/ in $dir..."; 752 + local tmpdir elf_fifo script_fifo; 753 + tmpdir="$(mktemp -d)"; 754 + elf_fifo="$tmpdir/elf"; 755 + script_fifo="$tmpdir/script"; 756 + mkfifo "$elf_fifo" "$script_fifo"; 757 + ( find "$dir" -type f -not -path '*/.build-id/*' -print0 | while IFS= read -r -d '' file; do 758 + if isELF "$file"; then 759 + printf '%s\0' "$file" 1>&3; 760 + else 761 + if isScript "$file"; then 762 + filename=${file##*/}; 763 + dir=${file%/*}; 764 + if [ -e "$dir/.$filename-wrapped" ]; then 765 + printf '%s\0' "$file" 1>&4; 766 + fi; 767 + fi; 768 + fi; 769 + done; 770 + exec 3>&- 4>&- ) 3> "$elf_fifo" 4> "$script_fifo" & ( xargs -0 -r -P "$NIX_BUILD_CORES" -n 1 sh -c ' 771 + if { printf :; patchelf --print-rpath "$1"; } | grep -q -F ":$TMPDIR/"; then 772 + echo "RPATH of binary $1 contains a forbidden reference to $TMPDIR/" 773 + exit 1 774 + fi 775 + ' _ < "$elf_fifo" ) & local pid_elf=$!; 776 + local pid_script; 777 + ( xargs -0 -r -P "$NIX_BUILD_CORES" -n 1 sh -c ' 778 + if grep -q -F "$TMPDIR/" "$1"; then 779 + echo "wrapper script $1 contains a forbidden reference to $TMPDIR/" 780 + exit 1 781 + fi 782 + ' _ < "$script_fifo" ) & local pid_script=$!; 783 + wait "$pid_elf" || { 784 + echo "Some binaries contain forbidden references to $TMPDIR/. Check the error above!"; 785 + exit 1 786 + }; 787 + wait "$pid_script" || { 788 + echo "Some scripts contain forbidden references to $TMPDIR/. Check the error above!"; 789 + exit 1 790 + }; 791 + rm -r "$tmpdir" 792 + } 793 + bintoolsWrapper_addLDVars () 794 + { 795 + 796 + local role_post; 797 + getHostRoleEnvHook; 798 + if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then 799 + export NIX_LDFLAGS${role_post}+=" -L$1/lib64"; 800 + fi; 801 + if [[ -d "$1/lib" ]]; then 802 + local -a glob=($1/lib/lib*); 803 + if [ "${#glob[*]}" -gt 0 ]; then 804 + export NIX_LDFLAGS${role_post}+=" -L$1/lib"; 805 + fi; 806 + fi 807 + } 808 + buildPhase () 809 + { 810 + 811 + runHook preBuild; 812 + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then 813 + echo "no Makefile or custom buildPhase, doing nothing"; 814 + else 815 + foundMakefile=1; 816 + local flagsArray=(${enableParallelBuilding:+-j${NIX_BUILD_CORES}} SHELL="$SHELL"); 817 + concatTo flagsArray makeFlags makeFlagsArray buildFlags buildFlagsArray; 818 + echoCmd 'build flags' "${flagsArray[@]}"; 819 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 820 + unset flagsArray; 821 + fi; 822 + runHook postBuild 823 + } 824 + ccWrapper_addCVars () 825 + { 826 + 827 + local role_post; 828 + getHostRoleEnvHook; 829 + local found=; 830 + if [ -d "$1/include" ]; then 831 + export NIX_CFLAGS_COMPILE${role_post}+=" -isystem $1/include"; 832 + found=1; 833 + fi; 834 + if [ -d "$1/Library/Frameworks" ]; then 835 + export NIX_CFLAGS_COMPILE${role_post}+=" -iframework $1/Library/Frameworks"; 836 + found=1; 837 + fi; 838 + if [[ -n "" && -n ${NIX_STORE:-} && -n $found ]]; then 839 + local scrubbed="$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-${1#"$NIX_STORE"/*-}"; 840 + export NIX_CFLAGS_COMPILE${role_post}+=" -fmacro-prefix-map=$1=$scrubbed"; 841 + fi 842 + } 843 + checkPhase () 844 + { 845 + 846 + runHook preCheck; 847 + if [[ -z "${foundMakefile:-}" ]]; then 848 + echo "no Makefile or custom checkPhase, doing nothing"; 849 + runHook postCheck; 850 + return; 851 + fi; 852 + if [[ -z "${checkTarget:-}" ]]; then 853 + if make -n ${makefile:+-f $makefile} check > /dev/null 2>&1; then 854 + checkTarget="check"; 855 + else 856 + if make -n ${makefile:+-f $makefile} test > /dev/null 2>&1; then 857 + checkTarget="test"; 858 + fi; 859 + fi; 860 + fi; 861 + if [[ -z "${checkTarget:-}" ]]; then 862 + echo "no check/test target in ${makefile:-Makefile}, doing nothing"; 863 + else 864 + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL="$SHELL"); 865 + concatTo flagsArray makeFlags makeFlagsArray checkFlags=VERBOSE=y checkFlagsArray checkTarget; 866 + echoCmd 'check flags' "${flagsArray[@]}"; 867 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 868 + unset flagsArray; 869 + fi; 870 + runHook postCheck 871 + } 872 + compressManPages () 873 + { 874 + 875 + local dir="$1"; 876 + if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]; then 877 + return; 878 + fi; 879 + echo "gzipping man pages under $dir/share/man/"; 880 + find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | xargs -0 -n1 -P "$NIX_BUILD_CORES" gzip -f; 881 + find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\|xz\)$' -print0 | sort -z | while IFS= read -r -d '' f; do 882 + local target; 883 + target="$(readlink -f "$f")"; 884 + if [ -f "$target".gz ]; then 885 + ln -sf "$target".gz "$f".gz && rm "$f"; 886 + fi; 887 + done 888 + } 889 + concatStringsSep () 890 + { 891 + 892 + local sep="$1"; 893 + local name="$2"; 894 + local type oldifs; 895 + if type=$(declare -p "$name" 2> /dev/null); then 896 + local -n nameref="$name"; 897 + case "${type#* }" in 898 + -A*) 899 + echo "concatStringsSep(): ERROR: trying to use concatStringsSep on an associative array." 1>&2; 900 + return 1 901 + ;; 902 + -a*) 903 + local IFS="$(printf '\036')" 904 + ;; 905 + *) 906 + local IFS=" " 907 + ;; 908 + esac; 909 + local ifs_separated="${nameref[*]}"; 910 + echo -n "${ifs_separated//"$IFS"/"$sep"}"; 911 + fi 912 + } 913 + concatTo () 914 + { 915 + 916 + local -; 917 + set -o noglob; 918 + local -n targetref="$1"; 919 + shift; 920 + local arg default name type; 921 + for arg in "$@"; 922 + do 923 + IFS="=" read -r name default <<< "$arg"; 924 + local -n nameref="$name"; 925 + if [[ -z "${nameref[*]}" && -n "$default" ]]; then 926 + targetref+=("$default"); 927 + else 928 + if type=$(declare -p "$name" 2> /dev/null); then 929 + case "${type#* }" in 930 + -A*) 931 + echo "concatTo(): ERROR: trying to use concatTo on an associative array." 1>&2; 932 + return 1 933 + ;; 934 + -a*) 935 + targetref+=("${nameref[@]}") 936 + ;; 937 + *) 938 + if [[ "$name" = *"Array" ]]; then 939 + nixErrorLog "concatTo(): $name is not declared as array, treating as a singleton. This will become an error in future"; 940 + targetref+=(${nameref+"${nameref[@]}"}); 941 + else 942 + targetref+=(${nameref-}); 943 + fi 944 + ;; 945 + esac; 946 + fi; 947 + fi; 948 + done 949 + } 950 + configurePhase () 951 + { 952 + 953 + runHook preConfigure; 954 + : "${configureScript=}"; 955 + if [[ -z "$configureScript" && -x ./configure ]]; then 956 + configureScript=./configure; 957 + fi; 958 + if [ -z "${dontFixLibtool:-}" ]; then 959 + export lt_cv_deplibs_check_method="${lt_cv_deplibs_check_method-pass_all}"; 960 + local i; 961 + find . -iname "ltmain.sh" -print0 | while IFS='' read -r -d '' i; do 962 + echo "fixing libtool script $i"; 963 + fixLibtool "$i"; 964 + done; 965 + CONFIGURE_MTIME_REFERENCE=$(mktemp configure.mtime.reference.XXXXXX); 966 + 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" {} \;; 967 + rm -f "$CONFIGURE_MTIME_REFERENCE"; 968 + fi; 969 + if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then 970 + prependToVar configureFlags "${prefixKey:---prefix=}$prefix"; 971 + fi; 972 + if [[ -f "$configureScript" ]]; then 973 + if [ -z "${dontAddDisableDepTrack:-}" ]; then 974 + if grep -q dependency-tracking "$configureScript"; then 975 + prependToVar configureFlags --disable-dependency-tracking; 976 + fi; 977 + fi; 978 + if [ -z "${dontDisableStatic:-}" ]; then 979 + if grep -q enable-static "$configureScript"; then 980 + prependToVar configureFlags --disable-static; 981 + fi; 982 + fi; 983 + if [ -z "${dontPatchShebangsInConfigure:-}" ]; then 984 + patchShebangs --build "$configureScript"; 985 + fi; 986 + fi; 987 + if [ -n "$configureScript" ]; then 988 + local -a flagsArray; 989 + concatTo flagsArray configureFlags configureFlagsArray; 990 + echoCmd 'configure flags' "${flagsArray[@]}"; 991 + $configureScript "${flagsArray[@]}"; 992 + unset flagsArray; 993 + else 994 + echo "no configure script, doing nothing"; 995 + fi; 996 + runHook postConfigure 997 + } 998 + consumeEntire () 999 + { 1000 + 1001 + if IFS='' read -r -d '' "$1"; then 1002 + echo "consumeEntire(): ERROR: Input null bytes, won't process" 1>&2; 1003 + return 1; 1004 + fi 1005 + } 1006 + distPhase () 1007 + { 1008 + 1009 + runHook preDist; 1010 + local flagsArray=(); 1011 + concatTo flagsArray distFlags distFlagsArray distTarget=dist; 1012 + echo 'dist flags: %q' "${flagsArray[@]}"; 1013 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 1014 + if [ "${dontCopyDist:-0}" != 1 ]; then 1015 + mkdir -p "$out/tarballs"; 1016 + cp -pvd ${tarballs[*]:-*.tar.gz} "$out/tarballs"; 1017 + fi; 1018 + runHook postDist 1019 + } 1020 + dumpVars () 1021 + { 1022 + 1023 + if [[ "${noDumpEnvVars:-0}" != 1 && -d "$NIX_BUILD_TOP" ]]; then 1024 + local old_umask; 1025 + old_umask=$(umask); 1026 + umask 0077; 1027 + export 2> /dev/null > "$NIX_BUILD_TOP/env-vars"; 1028 + umask "$old_umask"; 1029 + fi 1030 + } 1031 + echoCmd () 1032 + { 1033 + 1034 + printf "%s:" "$1"; 1035 + shift; 1036 + printf ' %q' "$@"; 1037 + echo 1038 + } 1039 + exitHandler () 1040 + { 1041 + 1042 + exitCode="$?"; 1043 + set +e; 1044 + if [ -n "${showBuildStats:-}" ]; then 1045 + read -r -d '' -a buildTimes < <(times); 1046 + echo "build times:"; 1047 + echo "user time for the shell ${buildTimes[0]}"; 1048 + echo "system time for the shell ${buildTimes[1]}"; 1049 + echo "user time for all child processes ${buildTimes[2]}"; 1050 + echo "system time for all child processes ${buildTimes[3]}"; 1051 + fi; 1052 + if (( "$exitCode" != 0 )); then 1053 + runHook failureHook; 1054 + if [ -n "${succeedOnFailure:-}" ]; then 1055 + echo "build failed with exit code $exitCode (ignored)"; 1056 + mkdir -p "$out/nix-support"; 1057 + printf "%s" "$exitCode" > "$out/nix-support/failed"; 1058 + exit 0; 1059 + fi; 1060 + else 1061 + runHook exitHook; 1062 + fi; 1063 + return "$exitCode" 1064 + } 1065 + findInputs () 1066 + { 1067 + 1068 + local -r pkg="$1"; 1069 + local -r hostOffset="$2"; 1070 + local -r targetOffset="$3"; 1071 + (( hostOffset <= targetOffset )) || exit 1; 1072 + local varVar="${pkgAccumVarVars[hostOffset + 1]}"; 1073 + local varRef="$varVar[$((targetOffset - hostOffset))]"; 1074 + local var="${!varRef}"; 1075 + unset -v varVar varRef; 1076 + local varSlice="$var[*]"; 1077 + case " ${!varSlice-} " in 1078 + *" $pkg "*) 1079 + return 0 1080 + ;; 1081 + esac; 1082 + unset -v varSlice; 1083 + eval "$var"'+=("$pkg")'; 1084 + if ! [ -e "$pkg" ]; then 1085 + echo "build input $pkg does not exist" 1>&2; 1086 + exit 1; 1087 + fi; 1088 + function mapOffset () 1089 + { 1090 + local -r inputOffset="$1"; 1091 + local -n outputOffset="$2"; 1092 + if (( inputOffset <= 0 )); then 1093 + outputOffset=$((inputOffset + hostOffset)); 1094 + else 1095 + outputOffset=$((inputOffset - 1 + targetOffset)); 1096 + fi 1097 + }; 1098 + local relHostOffset; 1099 + for relHostOffset in "${allPlatOffsets[@]}"; 1100 + do 1101 + local files="${propagatedDepFilesVars[relHostOffset + 1]}"; 1102 + local hostOffsetNext; 1103 + mapOffset "$relHostOffset" hostOffsetNext; 1104 + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; 1105 + local relTargetOffset; 1106 + for relTargetOffset in "${allPlatOffsets[@]}"; 1107 + do 1108 + (( "$relHostOffset" <= "$relTargetOffset" )) || continue; 1109 + local fileRef="${files}[$relTargetOffset - $relHostOffset]"; 1110 + local file="${!fileRef}"; 1111 + unset -v fileRef; 1112 + local targetOffsetNext; 1113 + mapOffset "$relTargetOffset" targetOffsetNext; 1114 + (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue; 1115 + [[ -f "$pkg/nix-support/$file" ]] || continue; 1116 + local pkgNext; 1117 + read -r -d '' pkgNext < "$pkg/nix-support/$file" || true; 1118 + for pkgNext in $pkgNext; 1119 + do 1120 + findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"; 1121 + done; 1122 + done; 1123 + done 1124 + } 1125 + fixLibtool () 1126 + { 1127 + 1128 + local search_path; 1129 + for flag in $NIX_LDFLAGS; 1130 + do 1131 + case $flag in 1132 + -L*) 1133 + search_path+=" ${flag#-L}" 1134 + ;; 1135 + esac; 1136 + done; 1137 + sed -i "$1" -e "s^eval \(sys_lib_search_path=\).*^\1'${search_path:-}'^" -e 's^eval sys_lib_.+search_path=.*^^' 1138 + } 1139 + fixupPhase () 1140 + { 1141 + 1142 + local output; 1143 + for output in $(getAllOutputNames); 1144 + do 1145 + if [ -e "${!output}" ]; then 1146 + chmod -R u+w,u-s,g-s "${!output}"; 1147 + fi; 1148 + done; 1149 + runHook preFixup; 1150 + local output; 1151 + for output in $(getAllOutputNames); 1152 + do 1153 + prefix="${!output}" runHook fixupOutput; 1154 + done; 1155 + recordPropagatedDependencies; 1156 + if [ -n "${setupHook:-}" ]; then 1157 + mkdir -p "${!outputDev}/nix-support"; 1158 + substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"; 1159 + fi; 1160 + if [ -n "${setupHooks:-}" ]; then 1161 + mkdir -p "${!outputDev}/nix-support"; 1162 + local hook; 1163 + for hook in ${setupHooks[@]}; 1164 + do 1165 + local content; 1166 + consumeEntire content < "$hook"; 1167 + substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"; 1168 + unset -v content; 1169 + done; 1170 + unset -v hook; 1171 + fi; 1172 + if [ -n "${propagatedUserEnvPkgs[*]:-}" ]; then 1173 + mkdir -p "${!outputBin}/nix-support"; 1174 + printWords "${propagatedUserEnvPkgs[@]}" > "${!outputBin}/nix-support/propagated-user-env-packages"; 1175 + fi; 1176 + runHook postFixup 1177 + } 1178 + genericBuild () 1179 + { 1180 + 1181 + export GZIP_NO_TIMESTAMPS=1; 1182 + if [ -f "${buildCommandPath:-}" ]; then 1183 + source "$buildCommandPath"; 1184 + return; 1185 + fi; 1186 + if [ -n "${buildCommand:-}" ]; then 1187 + eval "$buildCommand"; 1188 + return; 1189 + fi; 1190 + if [ -z "${phases[*]:-}" ]; then 1191 + phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}"; 1192 + fi; 1193 + for curPhase in ${phases[*]}; 1194 + do 1195 + runPhase "$curPhase"; 1196 + done 1197 + } 1198 + getAllOutputNames () 1199 + { 1200 + 1201 + if [ -n "$__structuredAttrs" ]; then 1202 + echo "${!outputs[*]}"; 1203 + else 1204 + echo "$outputs"; 1205 + fi 1206 + } 1207 + getHostRole () 1208 + { 1209 + 1210 + getRole "$hostOffset" 1211 + } 1212 + getHostRoleEnvHook () 1213 + { 1214 + 1215 + getRole "$depHostOffset" 1216 + } 1217 + getRole () 1218 + { 1219 + 1220 + case $1 in 1221 + -1) 1222 + role_post='_FOR_BUILD' 1223 + ;; 1224 + 0) 1225 + role_post='' 1226 + ;; 1227 + 1) 1228 + role_post='_FOR_TARGET' 1229 + ;; 1230 + *) 1231 + echo "binutils-wrapper-2.44: used as improper sort of dependency" 1>&2; 1232 + return 1 1233 + ;; 1234 + esac 1235 + } 1236 + getTargetRole () 1237 + { 1238 + 1239 + getRole "$targetOffset" 1240 + } 1241 + getTargetRoleEnvHook () 1242 + { 1243 + 1244 + getRole "$depTargetOffset" 1245 + } 1246 + getTargetRoleWrapper () 1247 + { 1248 + 1249 + case $targetOffset in 1250 + -1) 1251 + export NIX_BINTOOLS_WRAPPER_TARGET_BUILD_x86_64_unknown_linux_gnu=1 1252 + ;; 1253 + 0) 1254 + export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 1255 + ;; 1256 + 1) 1257 + export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu=1 1258 + ;; 1259 + *) 1260 + echo "binutils-wrapper-2.44: used as improper sort of dependency" 1>&2; 1261 + return 1 1262 + ;; 1263 + esac 1264 + } 1265 + installCheckPhase () 1266 + { 1267 + 1268 + runHook preInstallCheck; 1269 + if [[ -z "${foundMakefile:-}" ]]; then 1270 + echo "no Makefile or custom installCheckPhase, doing nothing"; 1271 + else 1272 + if [[ -z "${installCheckTarget:-}" ]] && ! make -n ${makefile:+-f $makefile} "${installCheckTarget:-installcheck}" > /dev/null 2>&1; then 1273 + echo "no installcheck target in ${makefile:-Makefile}, doing nothing"; 1274 + else 1275 + local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL="$SHELL"); 1276 + concatTo flagsArray makeFlags makeFlagsArray installCheckFlags installCheckFlagsArray installCheckTarget=installcheck; 1277 + echoCmd 'installcheck flags' "${flagsArray[@]}"; 1278 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 1279 + unset flagsArray; 1280 + fi; 1281 + fi; 1282 + runHook postInstallCheck 1283 + } 1284 + installPhase () 1285 + { 1286 + 1287 + runHook preInstall; 1288 + if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then 1289 + echo "no Makefile or custom installPhase, doing nothing"; 1290 + runHook postInstall; 1291 + return; 1292 + else 1293 + foundMakefile=1; 1294 + fi; 1295 + if [ -n "$prefix" ]; then 1296 + mkdir -p "$prefix"; 1297 + fi; 1298 + local flagsArray=(${enableParallelInstalling:+-j${NIX_BUILD_CORES}} SHELL="$SHELL"); 1299 + concatTo flagsArray makeFlags makeFlagsArray installFlags installFlagsArray installTargets=install; 1300 + echoCmd 'install flags' "${flagsArray[@]}"; 1301 + make ${makefile:+-f $makefile} "${flagsArray[@]}"; 1302 + unset flagsArray; 1303 + runHook postInstall 1304 + } 1305 + isELF () 1306 + { 1307 + 1308 + local fn="$1"; 1309 + local fd; 1310 + local magic; 1311 + exec {fd}< "$fn"; 1312 + LANG=C read -r -n 4 -u "$fd" magic; 1313 + exec {fd}>&-; 1314 + if [ "$magic" = 'ELF' ]; then 1315 + return 0; 1316 + else 1317 + return 1; 1318 + fi 1319 + } 1320 + isMachO () 1321 + { 1322 + 1323 + local fn="$1"; 1324 + local fd; 1325 + local magic; 1326 + exec {fd}< "$fn"; 1327 + LANG=C read -r -n 4 -u "$fd" magic; 1328 + exec {fd}>&-; 1329 + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then 1330 + return 0; 1331 + else 1332 + if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then 1333 + return 0; 1334 + else 1335 + if [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then 1336 + return 0; 1337 + else 1338 + return 1; 1339 + fi; 1340 + fi; 1341 + fi 1342 + } 1343 + isScript () 1344 + { 1345 + 1346 + local fn="$1"; 1347 + local fd; 1348 + local magic; 1349 + exec {fd}< "$fn"; 1350 + LANG=C read -r -n 2 -u "$fd" magic; 1351 + exec {fd}>&-; 1352 + if [[ "$magic" =~ \#! ]]; then 1353 + return 0; 1354 + else 1355 + return 1; 1356 + fi 1357 + } 1358 + mapOffset () 1359 + { 1360 + 1361 + local -r inputOffset="$1"; 1362 + local -n outputOffset="$2"; 1363 + if (( inputOffset <= 0 )); then 1364 + outputOffset=$((inputOffset + hostOffset)); 1365 + else 1366 + outputOffset=$((inputOffset - 1 + targetOffset)); 1367 + fi 1368 + } 1369 + moveToOutput () 1370 + { 1371 + 1372 + local patt="$1"; 1373 + local dstOut="$2"; 1374 + local output; 1375 + for output in $(getAllOutputNames); 1376 + do 1377 + if [ "${!output}" = "$dstOut" ]; then 1378 + continue; 1379 + fi; 1380 + local srcPath; 1381 + for srcPath in "${!output}"/$patt; 1382 + do 1383 + if [ ! -e "$srcPath" ] && [ ! -L "$srcPath" ]; then 1384 + continue; 1385 + fi; 1386 + if [ "$dstOut" = REMOVE ]; then 1387 + echo "Removing $srcPath"; 1388 + rm -r "$srcPath"; 1389 + else 1390 + local dstPath="$dstOut${srcPath#${!output}}"; 1391 + echo "Moving $srcPath to $dstPath"; 1392 + if [ -d "$dstPath" ] && [ -d "$srcPath" ]; then 1393 + rmdir "$srcPath" --ignore-fail-on-non-empty; 1394 + if [ -d "$srcPath" ]; then 1395 + mv -t "$dstPath" "$srcPath"/*; 1396 + rmdir "$srcPath"; 1397 + fi; 1398 + else 1399 + mkdir -p "$(readlink -m "$dstPath/..")"; 1400 + mv "$srcPath" "$dstPath"; 1401 + fi; 1402 + fi; 1403 + local srcParent="$(readlink -m "$srcPath/..")"; 1404 + if [ -n "$(find "$srcParent" -maxdepth 0 -type d -empty 2> /dev/null)" ]; then 1405 + echo "Removing empty $srcParent/ and (possibly) its parents"; 1406 + rmdir -p --ignore-fail-on-non-empty "$srcParent" 2> /dev/null || true; 1407 + fi; 1408 + done; 1409 + done 1410 + } 1411 + nixChattyLog () 1412 + { 1413 + 1414 + _nixLogWithLevel 5 "$*" 1415 + } 1416 + nixDebugLog () 1417 + { 1418 + 1419 + _nixLogWithLevel 6 "$*" 1420 + } 1421 + nixErrorLog () 1422 + { 1423 + 1424 + _nixLogWithLevel 0 "$*" 1425 + } 1426 + nixInfoLog () 1427 + { 1428 + 1429 + _nixLogWithLevel 3 "$*" 1430 + } 1431 + nixLog () 1432 + { 1433 + 1434 + [[ -z ${NIX_LOG_FD-} ]] && return 0; 1435 + local callerName="${FUNCNAME[1]}"; 1436 + if [[ $callerName == "_callImplicitHook" ]]; then 1437 + callerName="${hookName:?}"; 1438 + fi; 1439 + printf "%s: %s\n" "$callerName" "$*" >&"$NIX_LOG_FD" 1440 + } 1441 + nixNoticeLog () 1442 + { 1443 + 1444 + _nixLogWithLevel 2 "$*" 1445 + } 1446 + nixTalkativeLog () 1447 + { 1448 + 1449 + _nixLogWithLevel 4 "$*" 1450 + } 1451 + nixVomitLog () 1452 + { 1453 + 1454 + _nixLogWithLevel 7 "$*" 1455 + } 1456 + nixWarnLog () 1457 + { 1458 + 1459 + _nixLogWithLevel 1 "$*" 1460 + } 1461 + noBrokenSymlinks () 1462 + { 1463 + 1464 + local -r output="${1:?}"; 1465 + local path; 1466 + local pathParent; 1467 + local symlinkTarget; 1468 + local -i numDanglingSymlinks=0; 1469 + local -i numReflexiveSymlinks=0; 1470 + local -i numUnreadableSymlinks=0; 1471 + if [[ ! -e $output ]]; then 1472 + nixWarnLog "skipping non-existent output $output"; 1473 + return 0; 1474 + fi; 1475 + nixInfoLog "running on $output"; 1476 + while IFS= read -r -d '' path; do 1477 + pathParent="$(dirname "$path")"; 1478 + if ! symlinkTarget="$(readlink "$path")"; then 1479 + nixErrorLog "the symlink $path is unreadable"; 1480 + numUnreadableSymlinks+=1; 1481 + continue; 1482 + fi; 1483 + if [[ $symlinkTarget == /* ]]; then 1484 + nixInfoLog "symlink $path points to absolute target $symlinkTarget"; 1485 + else 1486 + nixInfoLog "symlink $path points to relative target $symlinkTarget"; 1487 + symlinkTarget="$(realpath --no-symlinks --canonicalize-missing "$pathParent/$symlinkTarget")"; 1488 + fi; 1489 + if [[ $symlinkTarget = "$TMPDIR"/* ]]; then 1490 + nixErrorLog "the symlink $path points to $TMPDIR directory: $symlinkTarget"; 1491 + numDanglingSymlinks+=1; 1492 + continue; 1493 + fi; 1494 + if [[ $symlinkTarget != "$NIX_STORE"/* ]]; then 1495 + nixInfoLog "symlink $path points outside the Nix store; ignoring"; 1496 + continue; 1497 + fi; 1498 + if [[ $path == "$symlinkTarget" ]]; then 1499 + nixErrorLog "the symlink $path is reflexive"; 1500 + numReflexiveSymlinks+=1; 1501 + else 1502 + if [[ ! -e $symlinkTarget ]]; then 1503 + nixErrorLog "the symlink $path points to a missing target: $symlinkTarget"; 1504 + numDanglingSymlinks+=1; 1505 + else 1506 + nixDebugLog "the symlink $path is irreflexive and points to a target which exists"; 1507 + fi; 1508 + fi; 1509 + done < <(find "$output" -type l -print0); 1510 + if ((numDanglingSymlinks > 0 || numReflexiveSymlinks > 0 || numUnreadableSymlinks > 0)); then 1511 + nixErrorLog "found $numDanglingSymlinks dangling symlinks, $numReflexiveSymlinks reflexive symlinks and $numUnreadableSymlinks unreadable symlinks"; 1512 + exit 1; 1513 + fi; 1514 + return 0 1515 + } 1516 + noBrokenSymlinksInAllOutputs () 1517 + { 1518 + 1519 + if [[ -z ${dontCheckForBrokenSymlinks-} ]]; then 1520 + for output in $(getAllOutputNames); 1521 + do 1522 + noBrokenSymlinks "${!output}"; 1523 + done; 1524 + fi 1525 + } 1526 + patchELF () 1527 + { 1528 + 1529 + local dir="$1"; 1530 + [ -e "$dir" ] || return 0; 1531 + echo "shrinking RPATHs of ELF executables and libraries in $dir"; 1532 + local i; 1533 + while IFS= read -r -d '' i; do 1534 + if [[ "$i" =~ .build-id ]]; then 1535 + continue; 1536 + fi; 1537 + if ! isELF "$i"; then 1538 + continue; 1539 + fi; 1540 + echo "shrinking $i"; 1541 + patchelf --shrink-rpath "$i" || true; 1542 + done < <(find "$dir" -type f -print0) 1543 + } 1544 + patchPhase () 1545 + { 1546 + 1547 + runHook prePatch; 1548 + local -a patchesArray; 1549 + concatTo patchesArray patches; 1550 + local -a flagsArray; 1551 + concatTo flagsArray patchFlags=-p1; 1552 + for i in "${patchesArray[@]}"; 1553 + do 1554 + echo "applying patch $i"; 1555 + local uncompress=cat; 1556 + case "$i" in 1557 + *.gz) 1558 + uncompress="gzip -d" 1559 + ;; 1560 + *.bz2) 1561 + uncompress="bzip2 -d" 1562 + ;; 1563 + *.xz) 1564 + uncompress="xz -d" 1565 + ;; 1566 + *.lzma) 1567 + uncompress="lzma -d" 1568 + ;; 1569 + esac; 1570 + $uncompress < "$i" 2>&1 | patch "${flagsArray[@]}"; 1571 + done; 1572 + runHook postPatch 1573 + } 1574 + patchShebangs () 1575 + { 1576 + 1577 + local pathName; 1578 + local update=false; 1579 + while [[ $# -gt 0 ]]; do 1580 + case "$1" in 1581 + --host) 1582 + pathName=HOST_PATH; 1583 + shift 1584 + ;; 1585 + --build) 1586 + pathName=PATH; 1587 + shift 1588 + ;; 1589 + --update) 1590 + update=true; 1591 + shift 1592 + ;; 1593 + --) 1594 + shift; 1595 + break 1596 + ;; 1597 + -* | --*) 1598 + echo "Unknown option $1 supplied to patchShebangs" 1>&2; 1599 + return 1 1600 + ;; 1601 + *) 1602 + break 1603 + ;; 1604 + esac; 1605 + done; 1606 + echo "patching script interpreter paths in $@"; 1607 + local f; 1608 + local oldPath; 1609 + local newPath; 1610 + local arg0; 1611 + local args; 1612 + local oldInterpreterLine; 1613 + local newInterpreterLine; 1614 + if [[ $# -eq 0 ]]; then 1615 + echo "No arguments supplied to patchShebangs" 1>&2; 1616 + return 0; 1617 + fi; 1618 + local f; 1619 + while IFS= read -r -d '' f; do 1620 + isScript "$f" || continue; 1621 + read -r oldInterpreterLine < "$f" || [ "$oldInterpreterLine" ]; 1622 + read -r oldPath arg0 args <<< "${oldInterpreterLine:2}"; 1623 + if [[ -z "${pathName:-}" ]]; then 1624 + if [[ -n $strictDeps && $f == "$NIX_STORE"* ]]; then 1625 + pathName=HOST_PATH; 1626 + else 1627 + pathName=PATH; 1628 + fi; 1629 + fi; 1630 + if [[ "$oldPath" == *"/bin/env" ]]; then 1631 + if [[ $arg0 == "-S" ]]; then 1632 + arg0=${args%% *}; 1633 + [[ "$args" == *" "* ]] && args=${args#* } || args=; 1634 + newPath="$(PATH="${!pathName}" type -P "env" || true)"; 1635 + args="-S $(PATH="${!pathName}" type -P "$arg0" || true) $args"; 1636 + else 1637 + if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then 1638 + echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 1>&2; 1639 + exit 1; 1640 + else 1641 + newPath="$(PATH="${!pathName}" type -P "$arg0" || true)"; 1642 + fi; 1643 + fi; 1644 + else 1645 + if [[ -z $oldPath ]]; then 1646 + oldPath="/bin/sh"; 1647 + fi; 1648 + newPath="$(PATH="${!pathName}" type -P "$(basename "$oldPath")" || true)"; 1649 + args="$arg0 $args"; 1650 + fi; 1651 + newInterpreterLine="$newPath $args"; 1652 + newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}}; 1653 + if [[ -n "$oldPath" && ( "$update" == true || "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ) ]]; then 1654 + if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then 1655 + echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""; 1656 + escapedInterpreterLine=${newInterpreterLine//\\/\\\\}; 1657 + timestamp=$(stat --printf "%y" "$f"); 1658 + tmpFile=$(mktemp -t patchShebangs.XXXXXXXXXX); 1659 + sed -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" > "$tmpFile"; 1660 + local restoreReadOnly; 1661 + if [[ ! -w "$f" ]]; then 1662 + chmod +w "$f"; 1663 + restoreReadOnly=true; 1664 + fi; 1665 + cat "$tmpFile" > "$f"; 1666 + rm "$tmpFile"; 1667 + if [[ -n "${restoreReadOnly:-}" ]]; then 1668 + chmod -w "$f"; 1669 + fi; 1670 + touch --date "$timestamp" "$f"; 1671 + fi; 1672 + fi; 1673 + done < <(find "$@" -type f -perm -0100 -print0) 1674 + } 1675 + patchShebangsAuto () 1676 + { 1677 + 1678 + if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then 1679 + if [[ "$output" != out && "$output" = "$outputDev" ]]; then 1680 + patchShebangs --build "$prefix"; 1681 + else 1682 + patchShebangs --host "$prefix"; 1683 + fi; 1684 + fi 1685 + } 1686 + prependToVar () 1687 + { 1688 + 1689 + local -n nameref="$1"; 1690 + local useArray type; 1691 + if [ -n "$__structuredAttrs" ]; then 1692 + useArray=true; 1693 + else 1694 + useArray=false; 1695 + fi; 1696 + if type=$(declare -p "$1" 2> /dev/null); then 1697 + case "${type#* }" in 1698 + -A*) 1699 + echo "prependToVar(): ERROR: trying to use prependToVar on an associative array." 1>&2; 1700 + return 1 1701 + ;; 1702 + -a*) 1703 + useArray=true 1704 + ;; 1705 + *) 1706 + useArray=false 1707 + ;; 1708 + esac; 1709 + fi; 1710 + shift; 1711 + if $useArray; then 1712 + nameref=("$@" ${nameref+"${nameref[@]}"}); 1713 + else 1714 + nameref="$* ${nameref-}"; 1715 + fi 1716 + } 1717 + printLines () 1718 + { 1719 + 1720 + (( "$#" > 0 )) || return 0; 1721 + printf '%s\n' "$@" 1722 + } 1723 + printWords () 1724 + { 1725 + 1726 + (( "$#" > 0 )) || return 0; 1727 + printf '%s ' "$@" 1728 + } 1729 + recordPropagatedDependencies () 1730 + { 1731 + 1732 + declare -ra flatVars=(depsBuildBuildPropagated propagatedNativeBuildInputs depsBuildTargetPropagated depsHostHostPropagated propagatedBuildInputs depsTargetTargetPropagated); 1733 + declare -ra flatFiles=("${propagatedBuildDepFiles[@]}" "${propagatedHostDepFiles[@]}" "${propagatedTargetDepFiles[@]}"); 1734 + local propagatedInputsIndex; 1735 + for propagatedInputsIndex in "${!flatVars[@]}"; 1736 + do 1737 + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"; 1738 + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"; 1739 + [[ -n "${!propagatedInputsSlice}" ]] || continue; 1740 + mkdir -p "${!outputDev}/nix-support"; 1741 + printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"; 1742 + done 1743 + } 1744 + runHook () 1745 + { 1746 + 1747 + local hookName="$1"; 1748 + shift; 1749 + local hooksSlice="${hookName%Hook}Hooks[@]"; 1750 + local hook; 1751 + for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; 1752 + do 1753 + _logHook "$hookName" "$hook" "$@"; 1754 + _eval "$hook" "$@"; 1755 + done; 1756 + return 0 1757 + } 1758 + runOneHook () 1759 + { 1760 + 1761 + local hookName="$1"; 1762 + shift; 1763 + local hooksSlice="${hookName%Hook}Hooks[@]"; 1764 + local hook ret=1; 1765 + for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; 1766 + do 1767 + _logHook "$hookName" "$hook" "$@"; 1768 + if _eval "$hook" "$@"; then 1769 + ret=0; 1770 + break; 1771 + fi; 1772 + done; 1773 + return "$ret" 1774 + } 1775 + runPhase () 1776 + { 1777 + 1778 + local curPhase="$*"; 1779 + if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then 1780 + return; 1781 + fi; 1782 + if [[ "$curPhase" = patchPhase && -n "${dontPatch:-}" ]]; then 1783 + return; 1784 + fi; 1785 + if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then 1786 + return; 1787 + fi; 1788 + if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then 1789 + return; 1790 + fi; 1791 + if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then 1792 + return; 1793 + fi; 1794 + if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then 1795 + return; 1796 + fi; 1797 + if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then 1798 + return; 1799 + fi; 1800 + if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then 1801 + return; 1802 + fi; 1803 + if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then 1804 + return; 1805 + fi; 1806 + showPhaseHeader "$curPhase"; 1807 + dumpVars; 1808 + local startTime endTime; 1809 + startTime=$(date +"%s"); 1810 + eval "${!curPhase:-$curPhase}"; 1811 + endTime=$(date +"%s"); 1812 + showPhaseFooter "$curPhase" "$startTime" "$endTime"; 1813 + if [ "$curPhase" = unpackPhase ]; then 1814 + [ -n "${sourceRoot:-}" ] && chmod +x -- "${sourceRoot}"; 1815 + cd -- "${sourceRoot:-.}"; 1816 + fi 1817 + } 1818 + showPhaseFooter () 1819 + { 1820 + 1821 + local phase="$1"; 1822 + local startTime="$2"; 1823 + local endTime="$3"; 1824 + local delta=$(( endTime - startTime )); 1825 + (( delta < 30 )) && return; 1826 + local H=$((delta/3600)); 1827 + local M=$((delta%3600/60)); 1828 + local S=$((delta%60)); 1829 + echo -n "$phase completed in "; 1830 + (( H > 0 )) && echo -n "$H hours "; 1831 + (( M > 0 )) && echo -n "$M minutes "; 1832 + echo "$S seconds" 1833 + } 1834 + showPhaseHeader () 1835 + { 1836 + 1837 + local phase="$1"; 1838 + echo "Running phase: $phase"; 1839 + if [[ -z ${NIX_LOG_FD-} ]]; then 1840 + return; 1841 + fi; 1842 + printf "@nix { \"action\": \"setPhase\", \"phase\": \"%s\" }\n" "$phase" >&"$NIX_LOG_FD" 1843 + } 1844 + stripDirs () 1845 + { 1846 + 1847 + local cmd="$1"; 1848 + local ranlibCmd="$2"; 1849 + local paths="$3"; 1850 + local stripFlags="$4"; 1851 + local excludeFlags=(); 1852 + local pathsNew=; 1853 + [ -z "$cmd" ] && echo "stripDirs: Strip command is empty" 1>&2 && exit 1; 1854 + [ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1; 1855 + local pattern; 1856 + if [ -n "${stripExclude:-}" ]; then 1857 + for pattern in "${stripExclude[@]}"; 1858 + do 1859 + excludeFlags+=(-a '!' '(' -name "$pattern" -o -wholename "$prefix/$pattern" ')'); 1860 + done; 1861 + fi; 1862 + local p; 1863 + for p in ${paths}; 1864 + do 1865 + if [ -e "$prefix/$p" ]; then 1866 + pathsNew="${pathsNew} $prefix/$p"; 1867 + fi; 1868 + done; 1869 + paths=${pathsNew}; 1870 + if [ -n "${paths}" ]; then 1871 + echo "stripping (with command $cmd and flags $stripFlags) in $paths"; 1872 + local striperr; 1873 + striperr="$(mktemp --tmpdir="$TMPDIR" 'striperr.XXXXXX')"; 1874 + find $paths -type f "${excludeFlags[@]}" -a '!' -path "$prefix/lib/debug/*" -printf '%D-%i,%p\0' | sort -t, -k1,1 -u -z | cut -d, -f2- -z | xargs -r -0 -n1 -P "$NIX_BUILD_CORES" -- $cmd $stripFlags 2> "$striperr" || exit_code=$?; 1875 + [[ "$exit_code" = 123 || -z "$exit_code" ]] || ( cat "$striperr" 1>&2 && exit 1 ); 1876 + rm "$striperr"; 1877 + find $paths -name '*.a' -type f -exec $ranlibCmd '{}' \; 2> /dev/null; 1878 + fi 1879 + } 1880 + stripHash () 1881 + { 1882 + 1883 + local strippedName casematchOpt=0; 1884 + strippedName="$(basename -- "$1")"; 1885 + shopt -q nocasematch && casematchOpt=1; 1886 + shopt -u nocasematch; 1887 + if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then 1888 + echo "${strippedName:33}"; 1889 + else 1890 + echo "$strippedName"; 1891 + fi; 1892 + if (( casematchOpt )); then 1893 + shopt -s nocasematch; 1894 + fi 1895 + } 1896 + substitute () 1897 + { 1898 + 1899 + local input="$1"; 1900 + local output="$2"; 1901 + shift 2; 1902 + if [ ! -f "$input" ]; then 1903 + echo "substitute(): ERROR: file '$input' does not exist" 1>&2; 1904 + return 1; 1905 + fi; 1906 + local content; 1907 + consumeEntire content < "$input"; 1908 + if [ -e "$output" ]; then 1909 + chmod +w "$output"; 1910 + fi; 1911 + substituteStream content "file '$input'" "$@" > "$output" 1912 + } 1913 + substituteAll () 1914 + { 1915 + 1916 + local input="$1"; 1917 + local output="$2"; 1918 + local -a args=(); 1919 + _allFlags; 1920 + substitute "$input" "$output" "${args[@]}" 1921 + } 1922 + substituteAllInPlace () 1923 + { 1924 + 1925 + local fileName="$1"; 1926 + shift; 1927 + substituteAll "$fileName" "$fileName" "$@" 1928 + } 1929 + substituteAllStream () 1930 + { 1931 + 1932 + local -a args=(); 1933 + _allFlags; 1934 + substituteStream "$1" "$2" "${args[@]}" 1935 + } 1936 + substituteInPlace () 1937 + { 1938 + 1939 + local -a fileNames=(); 1940 + for arg in "$@"; 1941 + do 1942 + if [[ "$arg" = "--"* ]]; then 1943 + break; 1944 + fi; 1945 + fileNames+=("$arg"); 1946 + shift; 1947 + done; 1948 + if ! [[ "${#fileNames[@]}" -gt 0 ]]; then 1949 + echo "substituteInPlace called without any files to operate on (files must come before options!)" 1>&2; 1950 + return 1; 1951 + fi; 1952 + for file in "${fileNames[@]}"; 1953 + do 1954 + substitute "$file" "$file" "$@"; 1955 + done 1956 + } 1957 + substituteStream () 1958 + { 1959 + 1960 + local var=$1; 1961 + local description=$2; 1962 + shift 2; 1963 + while (( "$#" )); do 1964 + local replace_mode="$1"; 1965 + case "$1" in 1966 + --replace) 1967 + if ! "$_substituteStream_has_warned_replace_deprecation"; then 1968 + echo "substituteStream() in derivation $name: WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. ($description)" 1>&2; 1969 + _substituteStream_has_warned_replace_deprecation=true; 1970 + fi; 1971 + replace_mode='--replace-warn' 1972 + ;& 1973 + --replace-quiet | --replace-warn | --replace-fail) 1974 + pattern="$2"; 1975 + replacement="$3"; 1976 + shift 3; 1977 + if ! [[ "${!var}" == *"$pattern"* ]]; then 1978 + if [ "$replace_mode" == --replace-warn ]; then 1979 + printf "substituteStream() in derivation $name: WARNING: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; 1980 + else 1981 + if [ "$replace_mode" == --replace-fail ]; then 1982 + printf "substituteStream() in derivation $name: ERROR: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2; 1983 + return 1; 1984 + fi; 1985 + fi; 1986 + fi; 1987 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' 1988 + ;; 1989 + --subst-var) 1990 + local varName="$2"; 1991 + shift 2; 1992 + if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then 1993 + echo "substituteStream() in derivation $name: ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." 1>&2; 1994 + return 1; 1995 + fi; 1996 + if [ -z ${!varName+x} ]; then 1997 + echo "substituteStream() in derivation $name: ERROR: variable \$$varName is unset" 1>&2; 1998 + return 1; 1999 + fi; 2000 + pattern="@$varName@"; 2001 + replacement="${!varName}"; 2002 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' 2003 + ;; 2004 + --subst-var-by) 2005 + pattern="@$2@"; 2006 + replacement="$3"; 2007 + eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; 2008 + shift 3 2009 + ;; 2010 + *) 2011 + echo "substituteStream() in derivation $name: ERROR: Invalid command line argument: $1" 1>&2; 2012 + return 1 2013 + ;; 2014 + esac; 2015 + done; 2016 + printf "%s" "${!var}" 2017 + } 2018 + unpackFile () 2019 + { 2020 + 2021 + curSrc="$1"; 2022 + echo "unpacking source archive $curSrc"; 2023 + if ! runOneHook unpackCmd "$curSrc"; then 2024 + echo "do not know how to unpack source archive $curSrc"; 2025 + exit 1; 2026 + fi 2027 + } 2028 + unpackPhase () 2029 + { 2030 + 2031 + runHook preUnpack; 2032 + if [ -z "${srcs:-}" ]; then 2033 + if [ -z "${src:-}" ]; then 2034 + echo 'variable $src or $srcs should point to the source'; 2035 + exit 1; 2036 + fi; 2037 + srcs="$src"; 2038 + fi; 2039 + local -a srcsArray; 2040 + concatTo srcsArray srcs; 2041 + local dirsBefore=""; 2042 + for i in *; 2043 + do 2044 + if [ -d "$i" ]; then 2045 + dirsBefore="$dirsBefore $i "; 2046 + fi; 2047 + done; 2048 + for i in "${srcsArray[@]}"; 2049 + do 2050 + unpackFile "$i"; 2051 + done; 2052 + : "${sourceRoot=}"; 2053 + if [ -n "${setSourceRoot:-}" ]; then 2054 + runOneHook setSourceRoot; 2055 + else 2056 + if [ -z "$sourceRoot" ]; then 2057 + for i in *; 2058 + do 2059 + if [ -d "$i" ]; then 2060 + case $dirsBefore in 2061 + *\ $i\ *) 2062 + 2063 + ;; 2064 + *) 2065 + if [ -n "$sourceRoot" ]; then 2066 + echo "unpacker produced multiple directories"; 2067 + exit 1; 2068 + fi; 2069 + sourceRoot="$i" 2070 + ;; 2071 + esac; 2072 + fi; 2073 + done; 2074 + fi; 2075 + fi; 2076 + if [ -z "$sourceRoot" ]; then 2077 + echo "unpacker appears to have produced no directories"; 2078 + exit 1; 2079 + fi; 2080 + echo "source root is $sourceRoot"; 2081 + if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then 2082 + chmod -R u+w -- "$sourceRoot"; 2083 + fi; 2084 + runHook postUnpack 2085 + } 2086 + updateAutotoolsGnuConfigScriptsPhase () 2087 + { 2088 + 2089 + if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then 2090 + return; 2091 + fi; 2092 + for script in config.sub config.guess; 2093 + do 2094 + for f in $(find . -type f -name "$script"); 2095 + do 2096 + echo "Updating Autotools / GNU config script to a newer upstream version: $f"; 2097 + cp -f "/nix/store/41mfbqgyi798xpfiab363vb5w2zsm654-gnu-config-2024-01-01/$script" "$f"; 2098 + done; 2099 + done 2100 + } 2101 + updateSourceDateEpoch () 2102 + { 2103 + 2104 + local path="$1"; 2105 + [[ $path == -* ]] && path="./$path"; 2106 + 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)); 2107 + local time="${res[0]//\.[0-9]*/}"; 2108 + local newestFile="${res[1]}"; 2109 + if [ "${time:-0}" -gt "$SOURCE_DATE_EPOCH" ]; then 2110 + echo "setting SOURCE_DATE_EPOCH to timestamp $time of file $newestFile"; 2111 + export SOURCE_DATE_EPOCH="$time"; 2112 + local now="$(date +%s)"; 2113 + if [ "$time" -gt $((now - 60)) ]; then 2114 + echo "warning: file $newestFile may be generated; SOURCE_DATE_EPOCH may be non-deterministic"; 2115 + fi; 2116 + fi 2117 + } 2118 + PATH="$PATH${nix_saved_PATH:+:$nix_saved_PATH}" 2119 + XDG_DATA_DIRS="$XDG_DATA_DIRS${nix_saved_XDG_DATA_DIRS:+:$nix_saved_XDG_DATA_DIRS}" 2120 + export NIX_BUILD_TOP="$(mktemp -d -t nix-shell.XXXXXX)" 2121 + export TMP="$NIX_BUILD_TOP" 2122 + export TMPDIR="$NIX_BUILD_TOP" 2123 + export TEMP="$NIX_BUILD_TOP" 2124 + export TEMPDIR="$NIX_BUILD_TOP" 2125 + eval "${shellHook:-}"
+1
.envrc
··· 1 + use flake
+6
.gitignore
··· 1 + *.beam 2 + *.ez 3 + /build 4 + erl_crash.dump 5 + .envrc 6 + .direnv/
+9
.tangled/workflows/test.yaml
··· 1 + when: 2 + - event: ["push", "pull-request"] 3 + branch: main 4 + 5 + engine: "nixery" 6 + 7 + steps: 8 + - test: 9 + command: "nix run .#test"
+56
README.md
··· 1 + # stare 2 + 3 + [![Package Version](https://img.shields.io/hexpm/v/stare)](https://hex.pm/packages/stare) 4 + [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/stare/) 5 + 6 + ```sh 7 + gleam add stare@1 8 + ``` 9 + ```gleam 10 + import gleam/io 11 + import stare 12 + 13 + pub fn main() -> Nil { 14 + let assert Ok(code) = stare.module( 15 + imports: [ 16 + stare.import_( 17 + module: ["gleam", "io"], 18 + types: [], 19 + constructors: [], 20 + functions: [], 21 + alias: None, 22 + ), 23 + ], 24 + functions: [ 25 + stare.function( 26 + name: "main", 27 + public: True, 28 + parameters: [], 29 + return_type: Some(type_.nil()), 30 + statements: [ 31 + stare.function_call( 32 + module: Some("io"), 33 + function: "println", 34 + arguments: [stare.value(value.string("Hello World!"))], 35 + ), 36 + ], 37 + ), 38 + ], 39 + ) 40 + io.println(code) 41 + // import gleam/io 42 + // 43 + // pub fn main() -> Nil { 44 + // io.println("Hello World!") 45 + //} 46 + } 47 + ``` 48 + 49 + Further documentation can be found at <https://hexdocs.pm/stare>. 50 + 51 + ## Development 52 + 53 + ```sh 54 + gleam run # Run the project 55 + gleam test # Run the tests 56 + ```
+27
flake.lock
··· 1 + { 2 + "nodes": { 3 + "nixpkgs": { 4 + "locked": { 5 + "lastModified": 1757034884, 6 + "narHash": "sha256-PgLSZDBEWUHpfTRfFyklmiiLBE1i1aGCtz4eRA3POao=", 7 + "owner": "NixOS", 8 + "repo": "nixpkgs", 9 + "rev": "ca77296380960cd497a765102eeb1356eb80fed0", 10 + "type": "github" 11 + }, 12 + "original": { 13 + "owner": "NixOS", 14 + "ref": "nixpkgs-unstable", 15 + "repo": "nixpkgs", 16 + "type": "github" 17 + } 18 + }, 19 + "root": { 20 + "inputs": { 21 + "nixpkgs": "nixpkgs" 22 + } 23 + } 24 + }, 25 + "root": "root", 26 + "version": 7 27 + }
+43
flake.nix
··· 1 + { 2 + inputs = { 3 + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 4 + }; 5 + 6 + outputs = {nixpkgs, ...}: let 7 + lib = nixpkgs.lib; 8 + supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; 9 + forEachSupportedSystem = f: 10 + lib.genAttrs supportedSystems (system: 11 + f { 12 + pkgs = import nixpkgs {inherit system;}; 13 + }); 14 + in { 15 + devShells = forEachSupportedSystem ({pkgs}: { 16 + default = pkgs.mkShell { 17 + packages = with pkgs; [ 18 + gleam 19 + erlang_28 20 + beam28Packages.rebar3 21 + ]; 22 + }; 23 + }); 24 + apps = forEachSupportedSystem ({pkgs}: let 25 + runtimeInputs = with pkgs; [ 26 + gleam 27 + erlang_28 28 + beam28Packages.rebar3 29 + ]; 30 + in { 31 + test = { 32 + type = "app"; 33 + program = "${(pkgs.writeShellApplication { 34 + inherit runtimeInputs; 35 + name = "test"; 36 + text = '' 37 + ${pkgs.gleam}/bin/gleam test 38 + ''; 39 + })}/bin/test"; 40 + }; 41 + }); 42 + }; 43 + }
+21
gleam.toml
··· 1 + name = "stare" 2 + version = "1.0.0" 3 + 4 + # Fill out these fields if you intend to generate HTML documentation or publish 5 + # your project to the Hex package manager. 6 + # 7 + # description = "" 8 + # licences = ["Apache-2.0"] 9 + # repository = { type = "github", user = "", repo = "" } 10 + # links = [{ title = "Website", href = "" }] 11 + # 12 + # For a full reference of all the available options, you can have a look at 13 + # https://gleam.run/writing-gleam/gleam-toml/. 14 + 15 + [dependencies] 16 + gleam_stdlib = ">= 0.44.0 and < 2.0.0" 17 + shellout = ">= 1.7.0 and < 2.0.0" 18 + simplifile = ">= 2.3.0 and < 3.0.0" 19 + 20 + [dev-dependencies] 21 + gleeunit = ">= 1.0.0 and < 2.0.0"
+16
manifest.toml
··· 1 + # This file was generated by Gleam 2 + # You typically do not need to edit this file 3 + 4 + packages = [ 5 + { name = "filepath", version = "1.1.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "B06A9AF0BF10E51401D64B98E4B627F1D2E48C154967DA7AF4D0914780A6D40A" }, 6 + { name = "gleam_stdlib", version = "0.63.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "5E216C7D5E8BE22359C9D7DAA2CFBD66039BC12565542F34CD033C5BB57071ED" }, 7 + { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" }, 8 + { name = "shellout", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "1BDC03438FEB97A6AF3E396F4ABEB32BECF20DF2452EC9A8C0ACEB7BDDF70B14" }, 9 + { name = "simplifile", version = "2.3.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "0A868DAC6063D9E983477981839810DC2E553285AB4588B87E3E9C96A7FB4CB4" }, 10 + ] 11 + 12 + [requirements] 13 + gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" } 14 + gleeunit = { version = ">= 1.0.0 and < 2.0.0" } 15 + shellout = { version = ">= 1.7.0 and < 2.0.0" } 16 + simplifile = { version = ">= 2.3.0 and < 3.0.0" }
+233
src/stare.gleam
··· 1 + import gleam/list 2 + import gleam/option.{type Option} 3 + import gleam/result 4 + import gleam/string 5 + import gleam/string_tree 6 + import shellout 7 + import simplifile 8 + import stare/type_ 9 + import stare/value 10 + 11 + @internal 12 + pub opaque type Module { 13 + Module(imports: List(Import), functions: List(Function)) 14 + } 15 + 16 + pub fn module( 17 + imports imports: List(Import), 18 + functions functions: List(Function), 19 + ) -> Module { 20 + Module(imports:, functions:) 21 + } 22 + 23 + @internal 24 + pub opaque type Import { 25 + Import( 26 + module: List(String), 27 + types: List(String), 28 + constructors: List(String), 29 + functions: List(String), 30 + alias: Option(String), 31 + ) 32 + } 33 + 34 + pub fn import_( 35 + module module: List(String), 36 + types types: List(String), 37 + constructors constructors: List(String), 38 + functions functions: List(String), 39 + alias alias: Option(String), 40 + ) -> Import { 41 + Import(module:, types:, constructors:, functions:, alias:) 42 + } 43 + 44 + @internal 45 + pub opaque type Parameter { 46 + Parameter(name: String, label: Option(String), type_: Option(type_.Type)) 47 + } 48 + 49 + pub fn parameter( 50 + label label: Option(String), 51 + name name: String, 52 + type_ type_: Option(type_.Type), 53 + ) -> Parameter { 54 + Parameter(name:, label:, type_:) 55 + } 56 + 57 + @internal 58 + pub opaque type Statement { 59 + FunctionCall( 60 + module: Option(String), 61 + function_name: String, 62 + arguments: List(Statement), 63 + ) 64 + Raw(value.Value) 65 + AddInts(value.Value, value.Value) 66 + AddFloats(value.Value, value.Value) 67 + } 68 + 69 + pub fn add_ints(left left: Int, right right: Int) -> Statement { 70 + AddInts(value.int(left), value.int(right)) 71 + } 72 + 73 + pub fn add_floats(left left: Float, right right: Float) -> Statement { 74 + AddFloats(value.float(left), value.float(right)) 75 + } 76 + 77 + pub fn value(value value: value.Value) -> Statement { 78 + Raw(value) 79 + } 80 + 81 + pub fn function_call( 82 + module module: Option(String), 83 + function function_name: String, 84 + arguments arguments: List(Statement), 85 + ) -> Statement { 86 + FunctionCall(module:, function_name:, arguments:) 87 + } 88 + 89 + @internal 90 + pub opaque type Function { 91 + Function( 92 + name: String, 93 + public: Bool, 94 + params: List(Parameter), 95 + type_: Option(type_.Type), 96 + statements: List(Statement), 97 + ) 98 + } 99 + 100 + pub fn function( 101 + name name: String, 102 + public public: Bool, 103 + parameters params: List(Parameter), 104 + return_type type_: Option(type_.Type), 105 + statements statements: List(Statement), 106 + ) -> Function { 107 + Function(name:, public:, params:, type_:, statements:) 108 + } 109 + 110 + pub fn generate_import(import_ import_: Import) -> String { 111 + let Import(module:, types:, constructors:, functions:, alias:) = import_ 112 + let i = 113 + "import " 114 + <> list.fold(module, "", fn(acc, part) { acc <> part <> "/" }) 115 + |> string.drop_end(1) 116 + 117 + let i = case types, constructors, functions { 118 + [], [], [] -> i 119 + _, _, _ -> { 120 + i 121 + <> ".{" 122 + <> list.fold(types, "", fn(acc, type_) { acc <> "type " <> type_ <> "," }) 123 + <> list.fold(constructors, "", fn(acc, constructor) { 124 + acc <> constructor <> "," 125 + }) 126 + <> list.fold(functions, "", fn(acc, function) { acc <> function <> "," }) 127 + <> "}" 128 + } 129 + } 130 + case alias { 131 + option.None -> i 132 + option.Some(alias) -> i <> " as " <> alias 133 + } 134 + } 135 + 136 + pub fn generate_statement(statement statement: Statement) -> String { 137 + case statement { 138 + FunctionCall(module:, function_name:, arguments: _) -> { 139 + string_tree.new() 140 + |> string_tree.append(case module { 141 + option.None -> "" 142 + option.Some(module) -> module <> "." 143 + }) 144 + |> string_tree.append(function_name) 145 + |> string_tree.append("(") 146 + |> string_tree.append( 147 + list.fold(statement.arguments, "", fn(acc, arg) { 148 + acc <> generate_statement(arg) <> "," 149 + }), 150 + ) 151 + |> string_tree.append(")") 152 + |> string_tree.to_string() 153 + } 154 + Raw(value) -> value.to_string(value) 155 + AddInts(left, right) -> 156 + value.to_string(left) <> "+" <> value.to_string(right) 157 + AddFloats(left, right) -> 158 + value.to_string(left) <> "+." <> value.to_string(right) 159 + } 160 + } 161 + 162 + pub fn generate_function(function function: Function) -> String { 163 + string_tree.new() 164 + |> string_tree.append(case function.public { 165 + False -> "" 166 + True -> "pub " 167 + }) 168 + |> string_tree.append("fn ") 169 + |> string_tree.append(function.name <> "(") 170 + |> string_tree.append(") ") 171 + |> string_tree.append(case function.type_ { 172 + option.None -> "" 173 + option.Some(type_) -> "-> " <> type_.to_string(type_:) <> " " 174 + }) 175 + |> string_tree.append("{\n") 176 + |> string_tree.append_tree( 177 + function.statements 178 + |> list.fold(string_tree.new(), fn(acc, statement) { 179 + string_tree.append(acc, generate_statement(statement) <> "\n") 180 + }), 181 + ) 182 + |> string_tree.append("}") 183 + |> string_tree.to_string() 184 + } 185 + 186 + pub fn generate(module: Module) -> String { 187 + let imports = 188 + module.imports 189 + |> list.fold(string_tree.new(), fn(acc, import_) { 190 + string_tree.append(acc, generate_import(import_:) <> "\n") 191 + }) 192 + 193 + let functions = 194 + module.functions 195 + |> list.fold(string_tree.new(), fn(acc, function) { 196 + string_tree.append(acc, generate_function(function:) <> "\n") 197 + }) 198 + 199 + string_tree.new() 200 + |> string_tree.append_tree(imports) 201 + |> string_tree.append("\n") 202 + |> string_tree.append_tree(functions) 203 + |> string_tree.to_string() 204 + } 205 + 206 + pub fn format(code code: String) -> Result(String, Nil) { 207 + use _ <- result.try( 208 + simplifile.create_directory_all("./build/tmp/") 209 + |> result.replace_error(Nil), 210 + ) 211 + use _ <- result.try( 212 + simplifile.write(to: "./build/tmp/format.gleam", contents: code) 213 + |> result.replace_error(Nil), 214 + ) 215 + use _ <- result.try( 216 + shellout.command( 217 + run: "gleam", 218 + with: ["format", "./build/tmp/format.gleam"], 219 + in: ".", 220 + opt: [], 221 + ) 222 + |> result.replace_error(Nil), 223 + ) 224 + use code <- result.try( 225 + simplifile.read(from: "./build/tmp/format.gleam") 226 + |> result.replace_error(Nil), 227 + ) 228 + use _ <- result.try( 229 + simplifile.delete("./build/tmp/format.gleam") 230 + |> result.replace_error(Nil), 231 + ) 232 + Ok(code) 233 + }
+40
src/stare/type_.gleam
··· 1 + @internal 2 + pub type Constructor 3 + 4 + @internal 5 + pub opaque type Type { 6 + CustomType( 7 + name: String, 8 + public: Bool, 9 + opaque_: Bool, 10 + constructors: List(Constructor), 11 + ) 12 + NilType 13 + StringType 14 + } 15 + 16 + @internal 17 + pub fn to_string(type_ type_: Type) -> String { 18 + case type_ { 19 + CustomType(name:, public: _, opaque_: _, constructors: _) -> name 20 + NilType -> "Nil" 21 + StringType -> "String" 22 + } 23 + } 24 + 25 + pub fn nil() -> Type { 26 + NilType 27 + } 28 + 29 + pub fn string() -> Type { 30 + StringType 31 + } 32 + 33 + pub fn custom( 34 + name name: String, 35 + public public: Bool, 36 + opaque_ opaque_: Bool, 37 + constructors constructors: List(Constructor), 38 + ) -> Type { 39 + CustomType(name:, public:, opaque_:, constructors:) 40 + }
+36
src/stare/value.gleam
··· 1 + import gleam/float 2 + import gleam/int 3 + 4 + @internal 5 + pub opaque type Value { 6 + NilValue 7 + StringValue(String) 8 + IntValue(Int) 9 + FloatValue(Float) 10 + } 11 + 12 + @internal 13 + pub fn to_string(value value: Value) -> String { 14 + case value { 15 + NilValue -> "Nil" 16 + StringValue(v) -> "\"" <> v <> "\"" 17 + IntValue(v) -> int.to_string(v) 18 + FloatValue(v) -> float.to_string(v) 19 + } 20 + } 21 + 22 + pub fn nil() -> Value { 23 + NilValue 24 + } 25 + 26 + pub fn string(string string: String) -> Value { 27 + StringValue(string) 28 + } 29 + 30 + pub fn int(int int: Int) -> Value { 31 + IntValue(int) 32 + } 33 + 34 + pub fn float(float float: Float) -> Value { 35 + FloatValue(float) 36 + }
+170
test/stare_test.gleam
··· 1 + import gleam/option.{None, Some} 2 + import gleeunit 3 + import stare 4 + import stare/type_ 5 + import stare/value 6 + 7 + pub fn main() -> Nil { 8 + gleeunit.main() 9 + } 10 + 11 + pub fn integer_addition_test() { 12 + let module = 13 + stare.module( 14 + imports: [ 15 + stare.import_( 16 + module: ["gleam", "io"], 17 + types: [], 18 + constructors: [], 19 + functions: [], 20 + alias: None, 21 + ), 22 + stare.import_( 23 + module: ["gleam", "int"], 24 + types: [], 25 + constructors: [], 26 + functions: [], 27 + alias: None, 28 + ), 29 + ], 30 + functions: [ 31 + stare.function( 32 + name: "main", 33 + public: True, 34 + parameters: [], 35 + return_type: None, 36 + statements: [ 37 + stare.function_call( 38 + module: Some("io"), 39 + function: "println", 40 + arguments: [ 41 + stare.function_call( 42 + module: Some("int"), 43 + function: "to_string", 44 + arguments: [stare.add_ints(1, 2)], 45 + ), 46 + ], 47 + ), 48 + ], 49 + ), 50 + ], 51 + ) 52 + let assert Ok(code) = 53 + module 54 + |> stare.generate() 55 + |> stare.format() 56 + 57 + let file = 58 + "import gleam/int 59 + import gleam/io 60 + 61 + pub fn main() { 62 + io.println(int.to_string(1 + 2)) 63 + } 64 + " 65 + 66 + assert file == code 67 + } 68 + 69 + pub fn float_addition_test() { 70 + let module = 71 + stare.module( 72 + imports: [ 73 + stare.import_( 74 + module: ["gleam", "io"], 75 + types: [], 76 + constructors: [], 77 + functions: [], 78 + alias: None, 79 + ), 80 + stare.import_( 81 + module: ["gleam", "float"], 82 + types: [], 83 + constructors: [], 84 + functions: [], 85 + alias: None, 86 + ), 87 + ], 88 + functions: [ 89 + stare.function( 90 + name: "main", 91 + public: True, 92 + parameters: [], 93 + return_type: None, 94 + statements: [ 95 + stare.function_call( 96 + module: Some("io"), 97 + function: "println", 98 + arguments: [ 99 + stare.function_call( 100 + module: Some("float"), 101 + function: "to_string", 102 + arguments: [stare.add_floats(1.1, 2.2)], 103 + ), 104 + ], 105 + ), 106 + ], 107 + ), 108 + ], 109 + ) 110 + let assert Ok(code) = 111 + module 112 + |> stare.generate() 113 + |> stare.format() 114 + 115 + let file = 116 + "import gleam/float 117 + import gleam/io 118 + 119 + pub fn main() { 120 + io.println(float.to_string(1.1 +. 2.2)) 121 + } 122 + " 123 + 124 + assert file == code 125 + } 126 + 127 + pub fn generate_hello_world_test() { 128 + let module = 129 + stare.module( 130 + imports: [ 131 + stare.import_( 132 + module: ["gleam", "io"], 133 + types: [], 134 + constructors: [], 135 + functions: [], 136 + alias: None, 137 + ), 138 + ], 139 + functions: [ 140 + stare.function( 141 + name: "main", 142 + public: True, 143 + parameters: [], 144 + return_type: Some(type_.nil()), 145 + statements: [ 146 + stare.function_call( 147 + module: Some("io"), 148 + function: "println", 149 + arguments: [stare.value(value.string("Hello World!"))], 150 + ), 151 + ], 152 + ), 153 + ], 154 + ) 155 + 156 + let assert Ok(code) = 157 + module 158 + |> stare.generate() 159 + |> stare.format() 160 + 161 + let file = 162 + "import gleam/io 163 + 164 + pub fn main() -> Nil { 165 + io.println(\"Hello World!\") 166 + } 167 + " 168 + 169 + assert file == code 170 + }