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