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