create-gardener 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/package.json +1 -1
  2. package/template/src/backend/controllers/gardener.controller.ts +6 -19
  3. package/template/src/backend/routes/gardener.route.ts +2 -1
  4. package/template/src/backend/server.ts +1 -1
  5. package/template/src/frontend/frontendtemplate.ejs +4 -4
  6. package/template/src/frontend/gardenerST.js +340 -0
  7. package/template/src/frontend/static/components/emailsvg.js +55 -0
  8. package/template/src/frontend/{components → static/components}/eyeoff.js +1 -1
  9. package/template/src/frontend/static/components/eyeon.js +43 -0
  10. package/template/src/frontend/{components → static/components}/notification.js +1 -1
  11. package/template/src/frontend/{components → static/components}/passwordBox.js +3 -3
  12. package/template/src/frontend/static/components/test.js +54 -0
  13. package/template/src/frontend/{gardener.js → static/gardener.js} +14 -1
  14. package/template/src/frontend/{style.css → static/style.css} +148 -347
  15. package/template/src/frontend/views/_.ejs +8 -8
  16. package/template/src/frontend/views/_login.ejs +8 -8
  17. package/.direnv/bin/nix-direnv-reload +0 -19
  18. package/.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc +0 -2140
  19. package/.envrc +0 -1
  20. package/template/src/frontend/components/emailsvg.js +0 -55
  21. package/template/src/frontend/components/eyeon.js +0 -44
  22. package/template/src/frontend/components/test.js +0 -54
  23. /package/template/src/{backend → frontend/static}/cache/gardener_500x500.webp +0 -0
  24. /package/template/src/frontend/{components → static/components}/nonui/api.js +0 -0
  25. /package/template/src/frontend/{global.js → static/global.js} +0 -0
  26. /package/template/src/frontend/{style2.css → static/style2.css} +0 -0
@@ -1,2140 +0,0 @@
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/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin/bash'
11
- CC='gcc'
12
- export CC
13
- CONFIG_SHELL='/nix/store/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin/bash'
14
- export CONFIG_SHELL
15
- CXX='g++'
16
- export CXX
17
- HOSTTYPE='x86_64'
18
- HOST_PATH='/nix/store/d75200gb22v7p0703h5jrkgg8bqydk5q-coreutils-9.8/bin:/nix/store/wd99g2j010fdkry0ws1bhxzm52w82ssx-findutils-4.10.0/bin:/nix/store/20zvyjvxq9x2mkp7rbnvrwjjzq2n76hh-diffutils-3.12/bin:/nix/store/k06ssckzrzn9jjvvs4n62m6567zmbx6x-gnused-4.9/bin:/nix/store/qfmq7p42ak5yn389qvx7zpxkan5i4xiy-gnugrep-3.12/bin:/nix/store/nmxm04dhkaqg1q6hai70n9zmzb0q49a5-gawk-5.3.2/bin:/nix/store/k1lcfin159706lihwx5hhvl80dbij4jw-gnutar-1.35/bin:/nix/store/0hv4z5s3r1h4lmvn0427mlxjxgvg34nr-gzip-1.14/bin:/nix/store/p61ba9fdgx3358bpp18hv4rslf6n5bq6-bzip2-1.0.8-bin/bin:/nix/store/mkm3my2067305hdh7rzmi10npwr7y17f-gnumake-4.4.1/bin:/nix/store/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin:/nix/store/clrf4mjwr8xcfpvway6w34wzvqc1hry4-patch-2.8/bin:/nix/store/j1zc5jh0vi9sbxj09ldj4xklgm6kpf8n-xz-5.8.1-bin/bin:/nix/store/s2k48fw3y698j4kcvmw0520m06ihv2z4-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/dwiyp91lmxq864plaas14jm14m87sg3f-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='8'
33
- export NIX_BUILD_CORES
34
- NIX_CC='/nix/store/r9wbjib6xxjkyb9yvjvrkl4sq61i2lyn-gcc-wrapper-15.2.0'
35
- export NIX_CC
36
- NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu='1'
37
- export NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu
38
- NIX_CFLAGS_COMPILE=' -frandom-seed=9ihwc8km8z'
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 libcxxhardeningextensive libcxxhardeningfast pic relro stackclashprotection stackprotector strictoverflow zerocallusedregs'
43
- export NIX_HARDENING_ENABLE
44
- NIX_LDFLAGS='-rpath /home/ritish/Workshop/web/Gardener/GardenerNPM/outputs/out/lib '
45
- export NIX_LDFLAGS
46
- NIX_NO_SELF_RPATH='1'
47
- NIX_STORE='/nix/store'
48
- export NIX_STORE
49
- NM='nm'
50
- export NM
51
- OBJCOPY='objcopy'
52
- export OBJCOPY
53
- OBJDUMP='objdump'
54
- export OBJDUMP
55
- OLDPWD=''
56
- export OLDPWD
57
- OPTERR='1'
58
- OSTYPE='linux-gnu'
59
- PATH='/nix/store/3vs2fr2mazafcdwyza15bfhpmccx1k7z-patchelf-0.15.2/bin:/nix/store/r9wbjib6xxjkyb9yvjvrkl4sq61i2lyn-gcc-wrapper-15.2.0/bin:/nix/store/qarrb8yfby1yyypm32vabzgxgq3w41ma-gcc-15.2.0/bin:/nix/store/7ri1mm5y99nkr7657r77wycrvhg7z9x0-glibc-2.40-66-bin/bin:/nix/store/d75200gb22v7p0703h5jrkgg8bqydk5q-coreutils-9.8/bin:/nix/store/dwiyp91lmxq864plaas14jm14m87sg3f-binutils-wrapper-2.44/bin:/nix/store/cl88v2m1y5q3k6jlkq5jjf73nmfgl1px-binutils-2.44/bin:/nix/store/d75200gb22v7p0703h5jrkgg8bqydk5q-coreutils-9.8/bin:/nix/store/wd99g2j010fdkry0ws1bhxzm52w82ssx-findutils-4.10.0/bin:/nix/store/20zvyjvxq9x2mkp7rbnvrwjjzq2n76hh-diffutils-3.12/bin:/nix/store/k06ssckzrzn9jjvvs4n62m6567zmbx6x-gnused-4.9/bin:/nix/store/qfmq7p42ak5yn389qvx7zpxkan5i4xiy-gnugrep-3.12/bin:/nix/store/nmxm04dhkaqg1q6hai70n9zmzb0q49a5-gawk-5.3.2/bin:/nix/store/k1lcfin159706lihwx5hhvl80dbij4jw-gnutar-1.35/bin:/nix/store/0hv4z5s3r1h4lmvn0427mlxjxgvg34nr-gzip-1.14/bin:/nix/store/p61ba9fdgx3358bpp18hv4rslf6n5bq6-bzip2-1.0.8-bin/bin:/nix/store/mkm3my2067305hdh7rzmi10npwr7y17f-gnumake-4.4.1/bin:/nix/store/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin:/nix/store/clrf4mjwr8xcfpvway6w34wzvqc1hry4-patch-2.8/bin:/nix/store/j1zc5jh0vi9sbxj09ldj4xklgm6kpf8n-xz-5.8.1-bin/bin:/nix/store/s2k48fw3y698j4kcvmw0520m06ihv2z4-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/lw117lsr8d585xs63kx5k233impyrq7q-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/3vs2fr2mazafcdwyza15bfhpmccx1k7z-patchelf-0.15.2/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/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin/bash'
94
- export builder
95
- cmakeFlags=''
96
- export cmakeFlags
97
- configureFlags=''
98
- export configureFlags
99
- defaultBuildInputs=''
100
- defaultNativeBuildInputs='/nix/store/3vs2fr2mazafcdwyza15bfhpmccx1k7z-patchelf-0.15.2 /nix/store/9k7h0vvpnb8w4xcaypff4i76n1bsmwzz-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/r9wbjib6xxjkyb9yvjvrkl4sq61i2lyn-gcc-wrapper-15.2.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
- initialPath='/nix/store/d75200gb22v7p0703h5jrkgg8bqydk5q-coreutils-9.8 /nix/store/wd99g2j010fdkry0ws1bhxzm52w82ssx-findutils-4.10.0 /nix/store/20zvyjvxq9x2mkp7rbnvrwjjzq2n76hh-diffutils-3.12 /nix/store/k06ssckzrzn9jjvvs4n62m6567zmbx6x-gnused-4.9 /nix/store/qfmq7p42ak5yn389qvx7zpxkan5i4xiy-gnugrep-3.12 /nix/store/nmxm04dhkaqg1q6hai70n9zmzb0q49a5-gawk-5.3.2 /nix/store/k1lcfin159706lihwx5hhvl80dbij4jw-gnutar-1.35 /nix/store/0hv4z5s3r1h4lmvn0427mlxjxgvg34nr-gzip-1.14 /nix/store/p61ba9fdgx3358bpp18hv4rslf6n5bq6-bzip2-1.0.8-bin /nix/store/mkm3my2067305hdh7rzmi10npwr7y17f-gnumake-4.4.1 /nix/store/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3 /nix/store/clrf4mjwr8xcfpvway6w34wzvqc1hry4-patch-2.8 /nix/store/j1zc5jh0vi9sbxj09ldj4xklgm6kpf8n-xz-5.8.1-bin /nix/store/s2k48fw3y698j4kcvmw0520m06ihv2z4-file-5.45'
131
- mesonFlags=''
132
- export mesonFlags
133
- name='Flake-template-env'
134
- export name
135
- nativeBuildInputs=''
136
- export nativeBuildInputs
137
- out='/home/ritish/Workshop/web/Gardener/GardenerNPM/outputs/out'
138
- export out
139
- outputBin='out'
140
- outputDev='out'
141
- outputDevdoc='REMOVE'
142
- outputDevman='out'
143
- outputDoc='out'
144
- outputInclude='out'
145
- outputInfo='out'
146
- outputLib='out'
147
- outputMan='out'
148
- outputs='out'
149
- export outputs
150
- patches=''
151
- export patches
152
- phases='buildPhase'
153
- export phases
154
- pkg='/nix/store/r9wbjib6xxjkyb9yvjvrkl4sq61i2lyn-gcc-wrapper-15.2.0'
155
- declare -a pkgsBuildBuild=()
156
- declare -a pkgsBuildHost=('/nix/store/3vs2fr2mazafcdwyza15bfhpmccx1k7z-patchelf-0.15.2' '/nix/store/9k7h0vvpnb8w4xcaypff4i76n1bsmwzz-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/r9wbjib6xxjkyb9yvjvrkl4sq61i2lyn-gcc-wrapper-15.2.0' '/nix/store/dwiyp91lmxq864plaas14jm14m87sg3f-binutils-wrapper-2.44' )
157
- declare -a pkgsBuildTarget=()
158
- declare -a pkgsHostHost=()
159
- declare -a pkgsHostTarget=()
160
- declare -a pkgsTargetTarget=()
161
- declare -a postFixupHooks=('noBrokenSymlinksInAllOutputs' '_makeSymlinksRelative' '_multioutPropagateDev' )
162
- declare -a postUnpackHooks=('_updateSourceDateEpochFromSourceRoot' )
163
- declare -a preConfigureHooks=('_multioutConfig' )
164
- preConfigurePhases=' updateAutotoolsGnuConfigScriptsPhase'
165
- declare -a preFixupHooks=('_moveToShare' '_multioutDocs' '_multioutDevs' )
166
- preferLocalBuild='1'
167
- export preferLocalBuild
168
- prefix='/home/ritish/Workshop/web/Gardener/GardenerNPM/outputs/out'
169
- declare -a propagatedBuildDepFiles=('propagated-build-build-deps' 'propagated-native-build-inputs' 'propagated-build-target-deps' )
170
- propagatedBuildInputs=''
171
- export propagatedBuildInputs
172
- declare -a propagatedHostDepFiles=('propagated-host-host-deps' 'propagated-build-inputs' )
173
- propagatedNativeBuildInputs=''
174
- export propagatedNativeBuildInputs
175
- declare -a propagatedTargetDepFiles=('propagated-target-target-deps' )
176
- shell='/nix/store/lw117lsr8d585xs63kx5k233impyrq7q-bash-5.3p3/bin/bash'
177
- export shell
178
- shellHook='export PNPM_HOME="$HOME/.local/share/pnpm"
179
- export PATH="$PNPM_HOME:$PATH"
180
- '
181
- export shellHook
182
- stdenv='/nix/store/n1k7lm072r5k3g6v6wb91d2q4sxcxddm-stdenv-linux'
183
- export stdenv
184
- strictDeps=''
185
- export strictDeps
186
- system='x86_64-linux'
187
- export system
188
- declare -a unpackCmdHooks=('_defaultUnpack' )
189
- _activatePkgs ()
190
- {
191
-
192
- local hostOffset targetOffset;
193
- local pkg;
194
- for hostOffset in "${allPlatOffsets[@]}";
195
- do
196
- local pkgsVar="${pkgAccumVarVars[hostOffset + 1]}";
197
- for targetOffset in "${allPlatOffsets[@]}";
198
- do
199
- (( hostOffset <= targetOffset )) || continue;
200
- local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]";
201
- local pkgsSlice="${!pkgsRef}[@]";
202
- for pkg in ${!pkgsSlice+"${!pkgsSlice}"};
203
- do
204
- activatePackage "$pkg" "$hostOffset" "$targetOffset";
205
- done;
206
- done;
207
- done
208
- }
209
- _addRpathPrefix ()
210
- {
211
-
212
- if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then
213
- export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}";
214
- fi
215
- }
216
- _addToEnv ()
217
- {
218
-
219
- local depHostOffset depTargetOffset;
220
- local pkg;
221
- for depHostOffset in "${allPlatOffsets[@]}";
222
- do
223
- local hookVar="${pkgHookVarVars[depHostOffset + 1]}";
224
- local pkgsVar="${pkgAccumVarVars[depHostOffset + 1]}";
225
- for depTargetOffset in "${allPlatOffsets[@]}";
226
- do
227
- (( depHostOffset <= depTargetOffset )) || continue;
228
- local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]";
229
- if [[ -z "${strictDeps-}" ]]; then
230
- local visitedPkgs="";
231
- for pkg in "${pkgsBuildBuild[@]}" "${pkgsBuildHost[@]}" "${pkgsBuildTarget[@]}" "${pkgsHostHost[@]}" "${pkgsHostTarget[@]}" "${pkgsTargetTarget[@]}";
232
- do
233
- if [[ "$visitedPkgs" = *"$pkg"* ]]; then
234
- continue;
235
- fi;
236
- runHook "${!hookRef}" "$pkg";
237
- visitedPkgs+=" $pkg";
238
- done;
239
- else
240
- local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]";
241
- local pkgsSlice="${!pkgsRef}[@]";
242
- for pkg in ${!pkgsSlice+"${!pkgsSlice}"};
243
- do
244
- runHook "${!hookRef}" "$pkg";
245
- done;
246
- fi;
247
- done;
248
- done
249
- }
250
- _allFlags ()
251
- {
252
-
253
- export system pname name version;
254
- while IFS='' read -r varName; do
255
- nixTalkativeLog "@${varName}@ -> ${!varName}";
256
- args+=("--subst-var" "$varName");
257
- done < <(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }')
258
- }
259
- _assignFirst ()
260
- {
261
-
262
- local varName="$1";
263
- local _var;
264
- local REMOVE=REMOVE;
265
- shift;
266
- for _var in "$@";
267
- do
268
- if [ -n "${!_var-}" ]; then
269
- eval "${varName}"="${_var}";
270
- return;
271
- fi;
272
- done;
273
- echo;
274
- echo "error: _assignFirst: could not find a non-empty variable whose name to assign to ${varName}.";
275
- echo " The following variables were all unset or empty:";
276
- echo " $*";
277
- if [ -z "${out:-}" ]; then
278
- echo ' If you do not want an "out" output in your derivation, make sure to define';
279
- echo ' the other specific required outputs. This can be achieved by picking one';
280
- echo " of the above as an output.";
281
- echo ' You do not have to remove "out" if you want to have a different default';
282
- echo ' output, because the first output is taken as a default.';
283
- echo;
284
- fi;
285
- return 1
286
- }
287
- _callImplicitHook ()
288
- {
289
-
290
- local def="$1";
291
- local hookName="$2";
292
- if declare -F "$hookName" > /dev/null; then
293
- nixTalkativeLog "calling implicit '$hookName' function hook";
294
- "$hookName";
295
- else
296
- if type -p "$hookName" > /dev/null; then
297
- nixTalkativeLog "sourcing implicit '$hookName' script hook";
298
- source "$hookName";
299
- else
300
- if [ -n "${!hookName:-}" ]; then
301
- nixTalkativeLog "evaling implicit '$hookName' string hook";
302
- eval "${!hookName}";
303
- else
304
- return "$def";
305
- fi;
306
- fi;
307
- fi
308
- }
309
- _defaultUnpack ()
310
- {
311
-
312
- local fn="$1";
313
- local destination;
314
- if [ -d "$fn" ]; then
315
- destination="$(stripHash "$fn")";
316
- if [ -e "$destination" ]; then
317
- echo "Cannot copy $fn to $destination: destination already exists!";
318
- echo "Did you specify two \"srcs\" with the same \"name\"?";
319
- return 1;
320
- fi;
321
- cp -r --preserve=timestamps --reflink=auto -- "$fn" "$destination";
322
- else
323
- case "$fn" in
324
- *.tar.xz | *.tar.lzma | *.txz)
325
- ( XZ_OPT="--threads=$NIX_BUILD_CORES" xz -d < "$fn";
326
- true ) | tar xf - --mode=+w --warning=no-timestamp
327
- ;;
328
- *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz)
329
- tar xf "$fn" --mode=+w --warning=no-timestamp
330
- ;;
331
- *)
332
- return 1
333
- ;;
334
- esac;
335
- fi
336
- }
337
- _doStrip ()
338
- {
339
-
340
- local -ra flags=(dontStripHost dontStripTarget);
341
- local -ra debugDirs=(stripDebugList stripDebugListTarget);
342
- local -ra allDirs=(stripAllList stripAllListTarget);
343
- local -ra stripCmds=(STRIP STRIP_FOR_TARGET);
344
- local -ra ranlibCmds=(RANLIB RANLIB_FOR_TARGET);
345
- stripDebugList=${stripDebugList[*]:-lib lib32 lib64 libexec bin sbin Applications Library/Frameworks};
346
- stripDebugListTarget=${stripDebugListTarget[*]:-};
347
- stripAllList=${stripAllList[*]:-};
348
- stripAllListTarget=${stripAllListTarget[*]:-};
349
- local i;
350
- for i in ${!stripCmds[@]};
351
- do
352
- local -n flag="${flags[$i]}";
353
- local -n debugDirList="${debugDirs[$i]}";
354
- local -n allDirList="${allDirs[$i]}";
355
- local -n stripCmd="${stripCmds[$i]}";
356
- local -n ranlibCmd="${ranlibCmds[$i]}";
357
- if [[ -n "${dontStrip-}" || -n "${flag-}" ]] || ! type -f "${stripCmd-}" 2> /dev/null 1>&2; then
358
- continue;
359
- fi;
360
- stripDirs "$stripCmd" "$ranlibCmd" "$debugDirList" "${stripDebugFlags[*]:--S -p}";
361
- stripDirs "$stripCmd" "$ranlibCmd" "$allDirList" "${stripAllFlags[*]:--s -p}";
362
- done
363
- }
364
- _eval ()
365
- {
366
-
367
- if declare -F "$1" > /dev/null 2>&1; then
368
- "$@";
369
- else
370
- eval "$1";
371
- fi
372
- }
373
- _logHook ()
374
- {
375
-
376
- if [[ -z ${NIX_LOG_FD-} ]]; then
377
- return;
378
- fi;
379
- local hookKind="$1";
380
- local hookExpr="$2";
381
- shift 2;
382
- if declare -F "$hookExpr" > /dev/null 2>&1; then
383
- nixTalkativeLog "calling '$hookKind' function hook '$hookExpr'" "$@";
384
- else
385
- if type -p "$hookExpr" > /dev/null; then
386
- nixTalkativeLog "sourcing '$hookKind' script hook '$hookExpr'";
387
- else
388
- if [[ "$hookExpr" != "_callImplicitHook"* ]]; then
389
- local exprToOutput;
390
- if [[ ${NIX_DEBUG:-0} -ge 5 ]]; then
391
- exprToOutput="$hookExpr";
392
- else
393
- local hookExprLine;
394
- while IFS= read -r hookExprLine; do
395
- hookExprLine="${hookExprLine#"${hookExprLine%%[![:space:]]*}"}";
396
- if [[ -n "$hookExprLine" ]]; then
397
- exprToOutput+="$hookExprLine\\n ";
398
- fi;
399
- done <<< "$hookExpr";
400
- exprToOutput="${exprToOutput%%\\n }";
401
- fi;
402
- nixTalkativeLog "evaling '$hookKind' string hook '$exprToOutput'";
403
- fi;
404
- fi;
405
- fi
406
- }
407
- _makeSymlinksRelative ()
408
- {
409
-
410
- local prefixes;
411
- prefixes=();
412
- for output in $(getAllOutputNames);
413
- do
414
- [ ! -e "${!output}" ] && continue;
415
- prefixes+=("${!output}");
416
- done;
417
- find "${prefixes[@]}" -type l -printf '%H\0%p\0' | xargs -0 -n2 -r -P "$NIX_BUILD_CORES" sh -c '
418
- output="$1"
419
- link="$2"
420
-
421
- linkTarget=$(readlink "$link")
422
-
423
- # only touch links that point inside the same output tree
424
- [[ $linkTarget == "$output"/* ]] || exit 0
425
-
426
- if [ ! -e "$linkTarget" ]; then
427
- echo "the symlink $link is broken, it points to $linkTarget (which is missing)"
428
- fi
429
-
430
- echo "making symlink relative: $link"
431
- ln -snrf "$linkTarget" "$link"
432
- ' _
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 -n -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
- definePhases ()
1007
- {
1008
-
1009
- if [ -z "${phases[*]:-}" ]; then
1010
- phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase ${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase ${preDistPhases[*]:-} distPhase ${postPhases[*]:-}";
1011
- fi
1012
- }
1013
- distPhase ()
1014
- {
1015
-
1016
- runHook preDist;
1017
- local flagsArray=();
1018
- concatTo flagsArray distFlags distFlagsArray distTarget=dist;
1019
- echo 'dist flags: %q' "${flagsArray[@]}";
1020
- make ${makefile:+-f $makefile} "${flagsArray[@]}";
1021
- if [ "${dontCopyDist:-0}" != 1 ]; then
1022
- mkdir -p "$out/tarballs";
1023
- cp -pvd ${tarballs[*]:-*.tar.gz} "$out/tarballs";
1024
- fi;
1025
- runHook postDist
1026
- }
1027
- dumpVars ()
1028
- {
1029
-
1030
- if [[ "${noDumpEnvVars:-0}" != 1 && -d "$NIX_BUILD_TOP" ]]; then
1031
- local old_umask;
1032
- old_umask=$(umask);
1033
- umask 0077;
1034
- export 2> /dev/null > "$NIX_BUILD_TOP/env-vars";
1035
- umask "$old_umask";
1036
- fi
1037
- }
1038
- echoCmd ()
1039
- {
1040
-
1041
- printf "%s:" "$1";
1042
- shift;
1043
- printf ' %q' "$@";
1044
- echo
1045
- }
1046
- exitHandler ()
1047
- {
1048
-
1049
- exitCode="$?";
1050
- set +e;
1051
- if [ -n "${showBuildStats:-}" ]; then
1052
- read -r -d '' -a buildTimes < <(times);
1053
- echo "build times:";
1054
- echo "user time for the shell ${buildTimes[0]}";
1055
- echo "system time for the shell ${buildTimes[1]}";
1056
- echo "user time for all child processes ${buildTimes[2]}";
1057
- echo "system time for all child processes ${buildTimes[3]}";
1058
- fi;
1059
- if (( "$exitCode" != 0 )); then
1060
- runHook failureHook;
1061
- if [ -n "${succeedOnFailure:-}" ]; then
1062
- echo "build failed with exit code $exitCode (ignored)";
1063
- mkdir -p "$out/nix-support";
1064
- printf "%s" "$exitCode" > "$out/nix-support/failed";
1065
- exit 0;
1066
- fi;
1067
- else
1068
- runHook exitHook;
1069
- fi;
1070
- return "$exitCode"
1071
- }
1072
- findInputs ()
1073
- {
1074
-
1075
- local -r pkg="$1";
1076
- local -r hostOffset="$2";
1077
- local -r targetOffset="$3";
1078
- (( hostOffset <= targetOffset )) || exit 1;
1079
- local varVar="${pkgAccumVarVars[hostOffset + 1]}";
1080
- local varRef="$varVar[$((targetOffset - hostOffset))]";
1081
- local var="${!varRef}";
1082
- unset -v varVar varRef;
1083
- local varSlice="$var[*]";
1084
- case " ${!varSlice-} " in
1085
- *" $pkg "*)
1086
- return 0
1087
- ;;
1088
- esac;
1089
- unset -v varSlice;
1090
- eval "$var"'+=("$pkg")';
1091
- if ! [ -e "$pkg" ]; then
1092
- echo "build input $pkg does not exist" 1>&2;
1093
- exit 1;
1094
- fi;
1095
- function mapOffset ()
1096
- {
1097
- local -r inputOffset="$1";
1098
- local -n outputOffset="$2";
1099
- if (( inputOffset <= 0 )); then
1100
- outputOffset=$((inputOffset + hostOffset));
1101
- else
1102
- outputOffset=$((inputOffset - 1 + targetOffset));
1103
- fi
1104
- };
1105
- local relHostOffset;
1106
- for relHostOffset in "${allPlatOffsets[@]}";
1107
- do
1108
- local files="${propagatedDepFilesVars[relHostOffset + 1]}";
1109
- local hostOffsetNext;
1110
- mapOffset "$relHostOffset" hostOffsetNext;
1111
- (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue;
1112
- local relTargetOffset;
1113
- for relTargetOffset in "${allPlatOffsets[@]}";
1114
- do
1115
- (( "$relHostOffset" <= "$relTargetOffset" )) || continue;
1116
- local fileRef="${files}[$relTargetOffset - $relHostOffset]";
1117
- local file="${!fileRef}";
1118
- unset -v fileRef;
1119
- local targetOffsetNext;
1120
- mapOffset "$relTargetOffset" targetOffsetNext;
1121
- (( -1 <= hostOffsetNext && hostOffsetNext <= 1 )) || continue;
1122
- [[ -f "$pkg/nix-support/$file" ]] || continue;
1123
- local pkgNext;
1124
- read -r -d '' pkgNext < "$pkg/nix-support/$file" || true;
1125
- for pkgNext in $pkgNext;
1126
- do
1127
- findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext";
1128
- done;
1129
- done;
1130
- done
1131
- }
1132
- fixLibtool ()
1133
- {
1134
-
1135
- local search_path;
1136
- for flag in $NIX_LDFLAGS;
1137
- do
1138
- case $flag in
1139
- -L*)
1140
- search_path+=" ${flag#-L}"
1141
- ;;
1142
- esac;
1143
- done;
1144
- sed -i "$1" -e "s^eval \(sys_lib_search_path=\).*^\1'${search_path:-}'^" -e 's^eval sys_lib_.+search_path=.*^^'
1145
- }
1146
- fixupPhase ()
1147
- {
1148
-
1149
- local output;
1150
- for output in $(getAllOutputNames);
1151
- do
1152
- if [ -e "${!output}" ]; then
1153
- chmod -R u+w,u-s,g-s "${!output}";
1154
- fi;
1155
- done;
1156
- runHook preFixup;
1157
- local output;
1158
- for output in $(getAllOutputNames);
1159
- do
1160
- prefix="${!output}" runHook fixupOutput;
1161
- done;
1162
- recordPropagatedDependencies;
1163
- if [ -n "${setupHook:-}" ]; then
1164
- mkdir -p "${!outputDev}/nix-support";
1165
- substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook";
1166
- fi;
1167
- if [ -n "${setupHooks:-}" ]; then
1168
- mkdir -p "${!outputDev}/nix-support";
1169
- local hook;
1170
- for hook in ${setupHooks[@]};
1171
- do
1172
- local content;
1173
- consumeEntire content < "$hook";
1174
- substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook";
1175
- unset -v content;
1176
- done;
1177
- unset -v hook;
1178
- fi;
1179
- if [ -n "${propagatedUserEnvPkgs[*]:-}" ]; then
1180
- mkdir -p "${!outputBin}/nix-support";
1181
- printWords "${propagatedUserEnvPkgs[@]}" > "${!outputBin}/nix-support/propagated-user-env-packages";
1182
- fi;
1183
- runHook postFixup
1184
- }
1185
- genericBuild ()
1186
- {
1187
-
1188
- export GZIP_NO_TIMESTAMPS=1;
1189
- if [ -f "${buildCommandPath:-}" ]; then
1190
- source "$buildCommandPath";
1191
- return;
1192
- fi;
1193
- if [ -n "${buildCommand:-}" ]; then
1194
- eval "$buildCommand";
1195
- return;
1196
- fi;
1197
- definePhases;
1198
- for curPhase in ${phases[*]};
1199
- do
1200
- runPhase "$curPhase";
1201
- done
1202
- }
1203
- getAllOutputNames ()
1204
- {
1205
-
1206
- if [ -n "$__structuredAttrs" ]; then
1207
- echo "${!outputs[*]}";
1208
- else
1209
- echo "$outputs";
1210
- fi
1211
- }
1212
- getHostRole ()
1213
- {
1214
-
1215
- getRole "$hostOffset"
1216
- }
1217
- getHostRoleEnvHook ()
1218
- {
1219
-
1220
- getRole "$depHostOffset"
1221
- }
1222
- getRole ()
1223
- {
1224
-
1225
- case $1 in
1226
- -1)
1227
- role_post='_FOR_BUILD'
1228
- ;;
1229
- 0)
1230
- role_post=''
1231
- ;;
1232
- 1)
1233
- role_post='_FOR_TARGET'
1234
- ;;
1235
- *)
1236
- echo "binutils-wrapper-2.44: used as improper sort of dependency" 1>&2;
1237
- return 1
1238
- ;;
1239
- esac
1240
- }
1241
- getTargetRole ()
1242
- {
1243
-
1244
- getRole "$targetOffset"
1245
- }
1246
- getTargetRoleEnvHook ()
1247
- {
1248
-
1249
- getRole "$depTargetOffset"
1250
- }
1251
- getTargetRoleWrapper ()
1252
- {
1253
-
1254
- case $targetOffset in
1255
- -1)
1256
- export NIX_BINTOOLS_WRAPPER_TARGET_BUILD_x86_64_unknown_linux_gnu=1
1257
- ;;
1258
- 0)
1259
- export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1
1260
- ;;
1261
- 1)
1262
- export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu=1
1263
- ;;
1264
- *)
1265
- echo "binutils-wrapper-2.44: used as improper sort of dependency" 1>&2;
1266
- return 1
1267
- ;;
1268
- esac
1269
- }
1270
- installCheckPhase ()
1271
- {
1272
-
1273
- runHook preInstallCheck;
1274
- if [[ -z "${foundMakefile:-}" ]]; then
1275
- echo "no Makefile or custom installCheckPhase, doing nothing";
1276
- else
1277
- if [[ -z "${installCheckTarget:-}" ]] && ! make -n ${makefile:+-f $makefile} "${installCheckTarget:-installcheck}" > /dev/null 2>&1; then
1278
- echo "no installcheck target in ${makefile:-Makefile}, doing nothing";
1279
- else
1280
- local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES}} SHELL="$SHELL");
1281
- concatTo flagsArray makeFlags makeFlagsArray installCheckFlags installCheckFlagsArray installCheckTarget=installcheck;
1282
- echoCmd 'installcheck flags' "${flagsArray[@]}";
1283
- make ${makefile:+-f $makefile} "${flagsArray[@]}";
1284
- unset flagsArray;
1285
- fi;
1286
- fi;
1287
- runHook postInstallCheck
1288
- }
1289
- installPhase ()
1290
- {
1291
-
1292
- runHook preInstall;
1293
- if [[ -z "${makeFlags-}" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then
1294
- echo "no Makefile or custom installPhase, doing nothing";
1295
- runHook postInstall;
1296
- return;
1297
- else
1298
- foundMakefile=1;
1299
- fi;
1300
- if [ -n "$prefix" ]; then
1301
- mkdir -p "$prefix";
1302
- fi;
1303
- local flagsArray=(${enableParallelInstalling:+-j${NIX_BUILD_CORES}} SHELL="$SHELL");
1304
- concatTo flagsArray makeFlags makeFlagsArray installFlags installFlagsArray installTargets=install;
1305
- echoCmd 'install flags' "${flagsArray[@]}";
1306
- make ${makefile:+-f $makefile} "${flagsArray[@]}";
1307
- unset flagsArray;
1308
- runHook postInstall
1309
- }
1310
- isELF ()
1311
- {
1312
-
1313
- local fn="$1";
1314
- local fd;
1315
- local magic;
1316
- exec {fd}< "$fn";
1317
- LANG=C read -r -n 4 -u "$fd" magic;
1318
- exec {fd}>&-;
1319
- if [ "$magic" = 'ELF' ]; then
1320
- return 0;
1321
- else
1322
- return 1;
1323
- fi
1324
- }
1325
- isMachO ()
1326
- {
1327
-
1328
- local fn="$1";
1329
- local fd;
1330
- local magic;
1331
- exec {fd}< "$fn";
1332
- LANG=C read -r -n 4 -u "$fd" magic;
1333
- exec {fd}>&-;
1334
- if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xcf") || "$magic" = $(echo -ne "\xcf\xfa\xed\xfe") ]]; then
1335
- return 0;
1336
- else
1337
- if [[ "$magic" = $(echo -ne "\xfe\xed\xfa\xce") || "$magic" = $(echo -ne "\xce\xfa\xed\xfe") ]]; then
1338
- return 0;
1339
- else
1340
- if [[ "$magic" = $(echo -ne "\xca\xfe\xba\xbe") || "$magic" = $(echo -ne "\xbe\xba\xfe\xca") ]]; then
1341
- return 0;
1342
- else
1343
- return 1;
1344
- fi;
1345
- fi;
1346
- fi
1347
- }
1348
- isScript ()
1349
- {
1350
-
1351
- local fn="$1";
1352
- local fd;
1353
- local magic;
1354
- exec {fd}< "$fn";
1355
- LANG=C read -r -n 2 -u "$fd" magic;
1356
- exec {fd}>&-;
1357
- if [[ "$magic" =~ \#! ]]; then
1358
- return 0;
1359
- else
1360
- return 1;
1361
- fi
1362
- }
1363
- mapOffset ()
1364
- {
1365
-
1366
- local -r inputOffset="$1";
1367
- local -n outputOffset="$2";
1368
- if (( inputOffset <= 0 )); then
1369
- outputOffset=$((inputOffset + hostOffset));
1370
- else
1371
- outputOffset=$((inputOffset - 1 + targetOffset));
1372
- fi
1373
- }
1374
- moveToOutput ()
1375
- {
1376
-
1377
- local patt="$1";
1378
- local dstOut="$2";
1379
- local output;
1380
- for output in $(getAllOutputNames);
1381
- do
1382
- if [ "${!output}" = "$dstOut" ]; then
1383
- continue;
1384
- fi;
1385
- local srcPath;
1386
- for srcPath in "${!output}"/$patt;
1387
- do
1388
- if [ ! -e "$srcPath" ] && [ ! -L "$srcPath" ]; then
1389
- continue;
1390
- fi;
1391
- if [ "$dstOut" = REMOVE ]; then
1392
- echo "Removing $srcPath";
1393
- rm -r "$srcPath";
1394
- else
1395
- local dstPath="$dstOut${srcPath#${!output}}";
1396
- echo "Moving $srcPath to $dstPath";
1397
- if [ -d "$dstPath" ] && [ -d "$srcPath" ]; then
1398
- rmdir "$srcPath" --ignore-fail-on-non-empty;
1399
- if [ -d "$srcPath" ]; then
1400
- mv -t "$dstPath" "$srcPath"/*;
1401
- rmdir "$srcPath";
1402
- fi;
1403
- else
1404
- mkdir -p "$(readlink -m "$dstPath/..")";
1405
- mv "$srcPath" "$dstPath";
1406
- fi;
1407
- fi;
1408
- local srcParent="$(readlink -m "$srcPath/..")";
1409
- if [ -n "$(find "$srcParent" -maxdepth 0 -type d -empty 2> /dev/null)" ]; then
1410
- echo "Removing empty $srcParent/ and (possibly) its parents";
1411
- rmdir -p --ignore-fail-on-non-empty "$srcParent" 2> /dev/null || true;
1412
- fi;
1413
- done;
1414
- done
1415
- }
1416
- nixChattyLog ()
1417
- {
1418
-
1419
- _nixLogWithLevel 5 "$*"
1420
- }
1421
- nixDebugLog ()
1422
- {
1423
-
1424
- _nixLogWithLevel 6 "$*"
1425
- }
1426
- nixErrorLog ()
1427
- {
1428
-
1429
- _nixLogWithLevel 0 "$*"
1430
- }
1431
- nixInfoLog ()
1432
- {
1433
-
1434
- _nixLogWithLevel 3 "$*"
1435
- }
1436
- nixLog ()
1437
- {
1438
-
1439
- [[ -z ${NIX_LOG_FD-} ]] && return 0;
1440
- local callerName="${FUNCNAME[1]}";
1441
- if [[ $callerName == "_callImplicitHook" ]]; then
1442
- callerName="${hookName:?}";
1443
- fi;
1444
- printf "%s: %s\n" "$callerName" "$*" >&"$NIX_LOG_FD"
1445
- }
1446
- nixNoticeLog ()
1447
- {
1448
-
1449
- _nixLogWithLevel 2 "$*"
1450
- }
1451
- nixTalkativeLog ()
1452
- {
1453
-
1454
- _nixLogWithLevel 4 "$*"
1455
- }
1456
- nixVomitLog ()
1457
- {
1458
-
1459
- _nixLogWithLevel 7 "$*"
1460
- }
1461
- nixWarnLog ()
1462
- {
1463
-
1464
- _nixLogWithLevel 1 "$*"
1465
- }
1466
- noBrokenSymlinks ()
1467
- {
1468
-
1469
- local -r output="${1:?}";
1470
- local path;
1471
- local pathParent;
1472
- local symlinkTarget;
1473
- local -i numDanglingSymlinks=0;
1474
- local -i numReflexiveSymlinks=0;
1475
- local -i numUnreadableSymlinks=0;
1476
- if [[ ! -e $output ]]; then
1477
- nixWarnLog "skipping non-existent output $output";
1478
- return 0;
1479
- fi;
1480
- nixInfoLog "running on $output";
1481
- while IFS= read -r -d '' path; do
1482
- pathParent="$(dirname "$path")";
1483
- if ! symlinkTarget="$(readlink "$path")"; then
1484
- nixErrorLog "the symlink $path is unreadable";
1485
- numUnreadableSymlinks+=1;
1486
- continue;
1487
- fi;
1488
- if [[ $symlinkTarget == /* ]]; then
1489
- nixInfoLog "symlink $path points to absolute target $symlinkTarget";
1490
- else
1491
- nixInfoLog "symlink $path points to relative target $symlinkTarget";
1492
- symlinkTarget="$(realpath --no-symlinks --canonicalize-missing "$pathParent/$symlinkTarget")";
1493
- fi;
1494
- if [[ $symlinkTarget = "$TMPDIR"/* ]]; then
1495
- nixErrorLog "the symlink $path points to $TMPDIR directory: $symlinkTarget";
1496
- numDanglingSymlinks+=1;
1497
- continue;
1498
- fi;
1499
- if [[ $symlinkTarget != "$NIX_STORE"/* ]]; then
1500
- nixInfoLog "symlink $path points outside the Nix store; ignoring";
1501
- continue;
1502
- fi;
1503
- if [[ $path == "$symlinkTarget" ]]; then
1504
- nixErrorLog "the symlink $path is reflexive";
1505
- numReflexiveSymlinks+=1;
1506
- else
1507
- if [[ ! -e $symlinkTarget ]]; then
1508
- nixErrorLog "the symlink $path points to a missing target: $symlinkTarget";
1509
- numDanglingSymlinks+=1;
1510
- else
1511
- nixDebugLog "the symlink $path is irreflexive and points to a target which exists";
1512
- fi;
1513
- fi;
1514
- done < <(find "$output" -type l -print0);
1515
- if ((numDanglingSymlinks > 0 || numReflexiveSymlinks > 0 || numUnreadableSymlinks > 0)); then
1516
- nixErrorLog "found $numDanglingSymlinks dangling symlinks, $numReflexiveSymlinks reflexive symlinks and $numUnreadableSymlinks unreadable symlinks";
1517
- exit 1;
1518
- fi;
1519
- return 0
1520
- }
1521
- noBrokenSymlinksInAllOutputs ()
1522
- {
1523
-
1524
- if [[ -z ${dontCheckForBrokenSymlinks-} ]]; then
1525
- for output in $(getAllOutputNames);
1526
- do
1527
- noBrokenSymlinks "${!output}";
1528
- done;
1529
- fi
1530
- }
1531
- patchELF ()
1532
- {
1533
-
1534
- local dir="$1";
1535
- [ -e "$dir" ] || return 0;
1536
- echo "shrinking RPATHs of ELF executables and libraries in $dir";
1537
- local i;
1538
- while IFS= read -r -d '' i; do
1539
- if [[ "$i" =~ .build-id ]]; then
1540
- continue;
1541
- fi;
1542
- if ! isELF "$i"; then
1543
- continue;
1544
- fi;
1545
- echo "shrinking $i";
1546
- patchelf --shrink-rpath "$i" || true;
1547
- done < <(find "$dir" -type f -print0)
1548
- }
1549
- patchPhase ()
1550
- {
1551
-
1552
- runHook prePatch;
1553
- local -a patchesArray;
1554
- concatTo patchesArray patches;
1555
- local -a flagsArray;
1556
- concatTo flagsArray patchFlags=-p1;
1557
- for i in "${patchesArray[@]}";
1558
- do
1559
- echo "applying patch $i";
1560
- local uncompress=cat;
1561
- case "$i" in
1562
- *.gz)
1563
- uncompress="gzip -d"
1564
- ;;
1565
- *.bz2)
1566
- uncompress="bzip2 -d"
1567
- ;;
1568
- *.xz)
1569
- uncompress="xz -d"
1570
- ;;
1571
- *.lzma)
1572
- uncompress="lzma -d"
1573
- ;;
1574
- esac;
1575
- $uncompress < "$i" 2>&1 | patch "${flagsArray[@]}";
1576
- done;
1577
- runHook postPatch
1578
- }
1579
- patchShebangs ()
1580
- {
1581
-
1582
- local pathName;
1583
- local update=false;
1584
- while [[ $# -gt 0 ]]; do
1585
- case "$1" in
1586
- --host)
1587
- pathName=HOST_PATH;
1588
- shift
1589
- ;;
1590
- --build)
1591
- pathName=PATH;
1592
- shift
1593
- ;;
1594
- --update)
1595
- update=true;
1596
- shift
1597
- ;;
1598
- --)
1599
- shift;
1600
- break
1601
- ;;
1602
- -* | --*)
1603
- echo "Unknown option $1 supplied to patchShebangs" 1>&2;
1604
- return 1
1605
- ;;
1606
- *)
1607
- break
1608
- ;;
1609
- esac;
1610
- done;
1611
- echo "patching script interpreter paths in $@";
1612
- local f;
1613
- local oldPath;
1614
- local newPath;
1615
- local arg0;
1616
- local args;
1617
- local oldInterpreterLine;
1618
- local newInterpreterLine;
1619
- if [[ $# -eq 0 ]]; then
1620
- echo "No arguments supplied to patchShebangs" 1>&2;
1621
- return 0;
1622
- fi;
1623
- local f;
1624
- while IFS= read -r -d '' f; do
1625
- isScript "$f" || continue;
1626
- read -r oldInterpreterLine < "$f" || [ "$oldInterpreterLine" ];
1627
- read -r oldPath arg0 args <<< "${oldInterpreterLine:2}";
1628
- if [[ -z "${pathName:-}" ]]; then
1629
- if [[ -n $strictDeps && $f == "$NIX_STORE"* ]]; then
1630
- pathName=HOST_PATH;
1631
- else
1632
- pathName=PATH;
1633
- fi;
1634
- fi;
1635
- if [[ "$oldPath" == *"/bin/env" ]]; then
1636
- if [[ $arg0 == "-S" ]]; then
1637
- arg0=${args%% *};
1638
- [[ "$args" == *" "* ]] && args=${args#* } || args=;
1639
- newPath="$(PATH="${!pathName}" type -P "env" || true)";
1640
- args="-S $(PATH="${!pathName}" type -P "$arg0" || true) $args";
1641
- else
1642
- if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then
1643
- echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 1>&2;
1644
- exit 1;
1645
- else
1646
- newPath="$(PATH="${!pathName}" type -P "$arg0" || true)";
1647
- fi;
1648
- fi;
1649
- else
1650
- if [[ -z $oldPath ]]; then
1651
- oldPath="/bin/sh";
1652
- fi;
1653
- newPath="$(PATH="${!pathName}" type -P "$(basename "$oldPath")" || true)";
1654
- args="$arg0 $args";
1655
- fi;
1656
- newInterpreterLine="$newPath $args";
1657
- newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}};
1658
- if [[ -n "$oldPath" && ( "$update" == true || "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ) ]]; then
1659
- if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then
1660
- echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\"";
1661
- escapedInterpreterLine=${newInterpreterLine//\\/\\\\};
1662
- timestamp=$(stat --printf "%y" "$f");
1663
- tmpFile=$(mktemp -t patchShebangs.XXXXXXXXXX);
1664
- sed -e "1 s|.*|#\!$escapedInterpreterLine|" "$f" > "$tmpFile";
1665
- local restoreReadOnly;
1666
- if [[ ! -w "$f" ]]; then
1667
- chmod +w "$f";
1668
- restoreReadOnly=true;
1669
- fi;
1670
- cat "$tmpFile" > "$f";
1671
- rm "$tmpFile";
1672
- if [[ -n "${restoreReadOnly:-}" ]]; then
1673
- chmod -w "$f";
1674
- fi;
1675
- touch --date "$timestamp" "$f";
1676
- fi;
1677
- fi;
1678
- done < <(find "$@" -type f -perm -0100 -print0)
1679
- }
1680
- patchShebangsAuto ()
1681
- {
1682
-
1683
- if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then
1684
- if [[ "$output" != out && "$output" = "$outputDev" ]]; then
1685
- patchShebangs --build "$prefix";
1686
- else
1687
- patchShebangs --host "$prefix";
1688
- fi;
1689
- fi
1690
- }
1691
- prependToVar ()
1692
- {
1693
-
1694
- local -n nameref="$1";
1695
- local useArray type;
1696
- if [ -n "$__structuredAttrs" ]; then
1697
- useArray=true;
1698
- else
1699
- useArray=false;
1700
- fi;
1701
- if type=$(declare -p "$1" 2> /dev/null); then
1702
- case "${type#* }" in
1703
- -A*)
1704
- echo "prependToVar(): ERROR: trying to use prependToVar on an associative array." 1>&2;
1705
- return 1
1706
- ;;
1707
- -a*)
1708
- useArray=true
1709
- ;;
1710
- *)
1711
- useArray=false
1712
- ;;
1713
- esac;
1714
- fi;
1715
- shift;
1716
- if $useArray; then
1717
- nameref=("$@" ${nameref+"${nameref[@]}"});
1718
- else
1719
- nameref="$* ${nameref-}";
1720
- fi
1721
- }
1722
- printLines ()
1723
- {
1724
-
1725
- (( "$#" > 0 )) || return 0;
1726
- printf '%s\n' "$@"
1727
- }
1728
- printPhases ()
1729
- {
1730
-
1731
- definePhases;
1732
- local phase;
1733
- for phase in ${phases[*]};
1734
- do
1735
- printf '%s\n' "$phase";
1736
- done
1737
- }
1738
- printWords ()
1739
- {
1740
-
1741
- (( "$#" > 0 )) || return 0;
1742
- printf '%s ' "$@"
1743
- }
1744
- recordPropagatedDependencies ()
1745
- {
1746
-
1747
- declare -ra flatVars=(depsBuildBuildPropagated propagatedNativeBuildInputs depsBuildTargetPropagated depsHostHostPropagated propagatedBuildInputs depsTargetTargetPropagated);
1748
- declare -ra flatFiles=("${propagatedBuildDepFiles[@]}" "${propagatedHostDepFiles[@]}" "${propagatedTargetDepFiles[@]}");
1749
- local propagatedInputsIndex;
1750
- for propagatedInputsIndex in "${!flatVars[@]}";
1751
- do
1752
- local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]";
1753
- local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}";
1754
- [[ -n "${!propagatedInputsSlice}" ]] || continue;
1755
- mkdir -p "${!outputDev}/nix-support";
1756
- printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile";
1757
- done
1758
- }
1759
- runHook ()
1760
- {
1761
-
1762
- local hookName="$1";
1763
- shift;
1764
- local hooksSlice="${hookName%Hook}Hooks[@]";
1765
- local hook;
1766
- for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"};
1767
- do
1768
- _logHook "$hookName" "$hook" "$@";
1769
- _eval "$hook" "$@";
1770
- done;
1771
- return 0
1772
- }
1773
- runOneHook ()
1774
- {
1775
-
1776
- local hookName="$1";
1777
- shift;
1778
- local hooksSlice="${hookName%Hook}Hooks[@]";
1779
- local hook ret=1;
1780
- for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"};
1781
- do
1782
- _logHook "$hookName" "$hook" "$@";
1783
- if _eval "$hook" "$@"; then
1784
- ret=0;
1785
- break;
1786
- fi;
1787
- done;
1788
- return "$ret"
1789
- }
1790
- runPhase ()
1791
- {
1792
-
1793
- local curPhase="$*";
1794
- if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then
1795
- return;
1796
- fi;
1797
- if [[ "$curPhase" = patchPhase && -n "${dontPatch:-}" ]]; then
1798
- return;
1799
- fi;
1800
- if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then
1801
- return;
1802
- fi;
1803
- if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then
1804
- return;
1805
- fi;
1806
- if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then
1807
- return;
1808
- fi;
1809
- if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then
1810
- return;
1811
- fi;
1812
- if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then
1813
- return;
1814
- fi;
1815
- if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then
1816
- return;
1817
- fi;
1818
- if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then
1819
- return;
1820
- fi;
1821
- showPhaseHeader "$curPhase";
1822
- dumpVars;
1823
- local startTime endTime;
1824
- startTime=$(date +"%s");
1825
- eval "${!curPhase:-$curPhase}";
1826
- endTime=$(date +"%s");
1827
- showPhaseFooter "$curPhase" "$startTime" "$endTime";
1828
- if [ "$curPhase" = unpackPhase ]; then
1829
- [ -n "${sourceRoot:-}" ] && chmod +x -- "${sourceRoot}";
1830
- cd -- "${sourceRoot:-.}";
1831
- fi
1832
- }
1833
- showPhaseFooter ()
1834
- {
1835
-
1836
- local phase="$1";
1837
- local startTime="$2";
1838
- local endTime="$3";
1839
- local delta=$(( endTime - startTime ));
1840
- (( delta < 30 )) && return;
1841
- local H=$((delta/3600));
1842
- local M=$((delta%3600/60));
1843
- local S=$((delta%60));
1844
- echo -n "$phase completed in ";
1845
- (( H > 0 )) && echo -n "$H hours ";
1846
- (( M > 0 )) && echo -n "$M minutes ";
1847
- echo "$S seconds"
1848
- }
1849
- showPhaseHeader ()
1850
- {
1851
-
1852
- local phase="$1";
1853
- echo "Running phase: $phase";
1854
- if [[ -z ${NIX_LOG_FD-} ]]; then
1855
- return;
1856
- fi;
1857
- printf "@nix { \"action\": \"setPhase\", \"phase\": \"%s\" }\n" "$phase" >&"$NIX_LOG_FD"
1858
- }
1859
- stripDirs ()
1860
- {
1861
-
1862
- local cmd="$1";
1863
- local ranlibCmd="$2";
1864
- local paths="$3";
1865
- local stripFlags="$4";
1866
- local excludeFlags=();
1867
- local pathsNew=;
1868
- [ -z "$cmd" ] && echo "stripDirs: Strip command is empty" 1>&2 && exit 1;
1869
- [ -z "$ranlibCmd" ] && echo "stripDirs: Ranlib command is empty" 1>&2 && exit 1;
1870
- local pattern;
1871
- if [ -n "${stripExclude:-}" ]; then
1872
- for pattern in "${stripExclude[@]}";
1873
- do
1874
- excludeFlags+=(-a '!' '(' -name "$pattern" -o -wholename "$prefix/$pattern" ')');
1875
- done;
1876
- fi;
1877
- local p;
1878
- for p in ${paths};
1879
- do
1880
- if [ -e "$prefix/$p" ]; then
1881
- pathsNew="${pathsNew} $prefix/$p";
1882
- fi;
1883
- done;
1884
- paths=${pathsNew};
1885
- if [ -n "${paths}" ]; then
1886
- echo "stripping (with command $cmd and flags $stripFlags) in $paths";
1887
- local striperr;
1888
- striperr="$(mktemp --tmpdir="$TMPDIR" 'striperr.XXXXXX')";
1889
- 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=$?;
1890
- [[ "$exit_code" = 123 || -z "$exit_code" ]] || ( cat "$striperr" 1>&2 && exit 1 );
1891
- rm "$striperr";
1892
- find $paths -name '*.a' -type f -exec $ranlibCmd '{}' \; 2> /dev/null;
1893
- fi
1894
- }
1895
- stripHash ()
1896
- {
1897
-
1898
- local strippedName casematchOpt=0;
1899
- strippedName="$(basename -- "$1")";
1900
- shopt -q nocasematch && casematchOpt=1;
1901
- shopt -u nocasematch;
1902
- if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then
1903
- echo "${strippedName:33}";
1904
- else
1905
- echo "$strippedName";
1906
- fi;
1907
- if (( casematchOpt )); then
1908
- shopt -s nocasematch;
1909
- fi
1910
- }
1911
- substitute ()
1912
- {
1913
-
1914
- local input="$1";
1915
- local output="$2";
1916
- shift 2;
1917
- if [ ! -f "$input" ]; then
1918
- echo "substitute(): ERROR: file '$input' does not exist" 1>&2;
1919
- return 1;
1920
- fi;
1921
- local content;
1922
- consumeEntire content < "$input";
1923
- if [ -e "$output" ]; then
1924
- chmod +w "$output";
1925
- fi;
1926
- substituteStream content "file '$input'" "$@" > "$output"
1927
- }
1928
- substituteAll ()
1929
- {
1930
-
1931
- local input="$1";
1932
- local output="$2";
1933
- local -a args=();
1934
- _allFlags;
1935
- substitute "$input" "$output" "${args[@]}"
1936
- }
1937
- substituteAllInPlace ()
1938
- {
1939
-
1940
- local fileName="$1";
1941
- shift;
1942
- substituteAll "$fileName" "$fileName" "$@"
1943
- }
1944
- substituteAllStream ()
1945
- {
1946
-
1947
- local -a args=();
1948
- _allFlags;
1949
- substituteStream "$1" "$2" "${args[@]}"
1950
- }
1951
- substituteInPlace ()
1952
- {
1953
-
1954
- local -a fileNames=();
1955
- for arg in "$@";
1956
- do
1957
- if [[ "$arg" = "--"* ]]; then
1958
- break;
1959
- fi;
1960
- fileNames+=("$arg");
1961
- shift;
1962
- done;
1963
- if ! [[ "${#fileNames[@]}" -gt 0 ]]; then
1964
- echo "substituteInPlace called without any files to operate on (files must come before options!)" 1>&2;
1965
- return 1;
1966
- fi;
1967
- for file in "${fileNames[@]}";
1968
- do
1969
- substitute "$file" "$file" "$@";
1970
- done
1971
- }
1972
- substituteStream ()
1973
- {
1974
-
1975
- local var=$1;
1976
- local description=$2;
1977
- shift 2;
1978
- while (( "$#" )); do
1979
- local replace_mode="$1";
1980
- case "$1" in
1981
- --replace)
1982
- if ! "$_substituteStream_has_warned_replace_deprecation"; then
1983
- echo "substituteStream() in derivation $name: WARNING: '--replace' is deprecated, use --replace-{fail,warn,quiet}. ($description)" 1>&2;
1984
- _substituteStream_has_warned_replace_deprecation=true;
1985
- fi;
1986
- replace_mode='--replace-warn'
1987
- ;&
1988
- --replace-quiet | --replace-warn | --replace-fail)
1989
- pattern="$2";
1990
- replacement="$3";
1991
- shift 3;
1992
- if ! [[ "${!var}" == *"$pattern"* ]]; then
1993
- if [ "$replace_mode" == --replace-warn ]; then
1994
- printf "substituteStream() in derivation $name: WARNING: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2;
1995
- else
1996
- if [ "$replace_mode" == --replace-fail ]; then
1997
- printf "substituteStream() in derivation $name: ERROR: pattern %q doesn't match anything in %s\n" "$pattern" "$description" 1>&2;
1998
- return 1;
1999
- fi;
2000
- fi;
2001
- fi;
2002
- eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
2003
- ;;
2004
- --subst-var)
2005
- local varName="$2";
2006
- shift 2;
2007
- if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
2008
- echo "substituteStream() in derivation $name: ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." 1>&2;
2009
- return 1;
2010
- fi;
2011
- if [ -z ${!varName+x} ]; then
2012
- echo "substituteStream() in derivation $name: ERROR: variable \$$varName is unset" 1>&2;
2013
- return 1;
2014
- fi;
2015
- pattern="@$varName@";
2016
- replacement="${!varName}";
2017
- eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'
2018
- ;;
2019
- --subst-var-by)
2020
- pattern="@$2@";
2021
- replacement="$3";
2022
- eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}';
2023
- shift 3
2024
- ;;
2025
- *)
2026
- echo "substituteStream() in derivation $name: ERROR: Invalid command line argument: $1" 1>&2;
2027
- return 1
2028
- ;;
2029
- esac;
2030
- done;
2031
- printf "%s" "${!var}"
2032
- }
2033
- unpackFile ()
2034
- {
2035
-
2036
- curSrc="$1";
2037
- echo "unpacking source archive $curSrc";
2038
- if ! runOneHook unpackCmd "$curSrc"; then
2039
- echo "do not know how to unpack source archive $curSrc";
2040
- exit 1;
2041
- fi
2042
- }
2043
- unpackPhase ()
2044
- {
2045
-
2046
- runHook preUnpack;
2047
- if [ -z "${srcs:-}" ]; then
2048
- if [ -z "${src:-}" ]; then
2049
- echo 'variable $src or $srcs should point to the source';
2050
- exit 1;
2051
- fi;
2052
- srcs="$src";
2053
- fi;
2054
- local -a srcsArray;
2055
- concatTo srcsArray srcs;
2056
- local dirsBefore="";
2057
- for i in *;
2058
- do
2059
- if [ -d "$i" ]; then
2060
- dirsBefore="$dirsBefore $i ";
2061
- fi;
2062
- done;
2063
- for i in "${srcsArray[@]}";
2064
- do
2065
- unpackFile "$i";
2066
- done;
2067
- : "${sourceRoot=}";
2068
- if [ -n "${setSourceRoot:-}" ]; then
2069
- runOneHook setSourceRoot;
2070
- else
2071
- if [ -z "$sourceRoot" ]; then
2072
- for i in *;
2073
- do
2074
- if [ -d "$i" ]; then
2075
- case $dirsBefore in
2076
- *\ $i\ *)
2077
-
2078
- ;;
2079
- *)
2080
- if [ -n "$sourceRoot" ]; then
2081
- echo "unpacker produced multiple directories";
2082
- exit 1;
2083
- fi;
2084
- sourceRoot="$i"
2085
- ;;
2086
- esac;
2087
- fi;
2088
- done;
2089
- fi;
2090
- fi;
2091
- if [ -z "$sourceRoot" ]; then
2092
- echo "unpacker appears to have produced no directories";
2093
- exit 1;
2094
- fi;
2095
- echo "source root is $sourceRoot";
2096
- if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then
2097
- chmod -R u+w -- "$sourceRoot";
2098
- fi;
2099
- runHook postUnpack
2100
- }
2101
- updateAutotoolsGnuConfigScriptsPhase ()
2102
- {
2103
-
2104
- if [ -n "${dontUpdateAutotoolsGnuConfigScripts-}" ]; then
2105
- return;
2106
- fi;
2107
- for script in config.sub config.guess;
2108
- do
2109
- for f in $(find . -type f -name "$script");
2110
- do
2111
- echo "Updating Autotools / GNU config script to a newer upstream version: $f";
2112
- cp -f "/nix/store/axmfg44mziw9bngfj937li7c7l39x6w1-gnu-config-2024-01-01/$script" "$f";
2113
- done;
2114
- done
2115
- }
2116
- updateSourceDateEpoch ()
2117
- {
2118
-
2119
- local path="$1";
2120
- [[ $path == -* ]] && path="./$path";
2121
- 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));
2122
- local time="${res[0]//\.[0-9]*/}";
2123
- local newestFile="${res[1]}";
2124
- if [ "${time:-0}" -gt "$SOURCE_DATE_EPOCH" ]; then
2125
- echo "setting SOURCE_DATE_EPOCH to timestamp $time of file $newestFile";
2126
- export SOURCE_DATE_EPOCH="$time";
2127
- local now="$(date +%s)";
2128
- if [ "$time" -gt $((now - 60)) ]; then
2129
- echo "warning: file $newestFile may be generated; SOURCE_DATE_EPOCH may be non-deterministic";
2130
- fi;
2131
- fi
2132
- }
2133
- PATH="$PATH${nix_saved_PATH:+:$nix_saved_PATH}"
2134
- XDG_DATA_DIRS="$XDG_DATA_DIRS${nix_saved_XDG_DATA_DIRS:+:$nix_saved_XDG_DATA_DIRS}"
2135
- export NIX_BUILD_TOP="$(mktemp -d -t nix-shell.XXXXXX)"
2136
- export TMP="$NIX_BUILD_TOP"
2137
- export TMPDIR="$NIX_BUILD_TOP"
2138
- export TEMP="$NIX_BUILD_TOP"
2139
- export TEMPDIR="$NIX_BUILD_TOP"
2140
- eval "${shellHook:-}"