diff options
Diffstat (limited to '.direnv')
l--------- | .direnv/flake-profile | 1 | ||||
-rw-r--r-- | .direnv/flake-profile.rc | 1504 |
2 files changed, 1505 insertions, 0 deletions
diff --git a/.direnv/flake-profile b/.direnv/flake-profile new file mode 120000 index 0000000..624f00f --- /dev/null +++ b/.direnv/flake-profile | |||
@@ -0,0 +1 @@ | |||
/nix/store/hk8227smba1l2lrk4np5fqy2hkb0jaf3-nix-shell-env \ No newline at end of file | |||
diff --git a/.direnv/flake-profile.rc b/.direnv/flake-profile.rc new file mode 100644 index 0000000..49f03d2 --- /dev/null +++ b/.direnv/flake-profile.rc | |||
@@ -0,0 +1,1504 @@ | |||
1 | unset shellHook | ||
2 | nix_saved_PATH="$PATH" | ||
3 | AR=ar | ||
4 | export AR | ||
5 | AS=as | ||
6 | export AS | ||
7 | BASH=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash | ||
8 | CC=gcc | ||
9 | export CC | ||
10 | CONFIG_SHELL=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash | ||
11 | export CONFIG_SHELL | ||
12 | CXX=g++ | ||
13 | export CXX | ||
14 | DIRSTACK=() | ||
15 | GROUPS=() | ||
16 | HOSTTYPE=x86_64 | ||
17 | HOST_PATH=/nix/store/ypsd29c5hgj1x7xz5ddffanxw5d8fh7b-coreutils-8.32/bin:/nix/store/nq9l23mrm8irvl9qvxgvxqqkm5sfnc9d-findutils-4.7.0/bin:/nix/store/7yq29nnglh2s576n7vdmzqryym22f8rj-diffutils-3.7/bin:/nix/store/0839nqri8w69c91amlsq9bawaqlzpmh9-gnused-4.8/bin:/nix/store/wmiyjdsaydyv024al5ddqd3liljrfvk7-gnugrep-3.6/bin:/nix/store/snmar11l5w9jrxva2s5d6143nqmdgzqb-gawk-5.1.0/bin:/nix/store/cisss0pcfh72kmnsv4qa6h41wcwb9mkv-gnutar-1.32/bin:/nix/store/prdifiyrxwgf6sp4rwmrqvfdnvf72gw2-gzip-1.10/bin:/nix/store/pp9shwhcdxxbhgp96fcaj0g8x5g54zrl-bzip2-1.0.6.0.1-bin/bin:/nix/store/fydw5vhlhpq438cxv4vwpa8pf8p8fv5s-gnumake-4.3/bin:/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin:/nix/store/qcw3qagp709qwfza259zqss5qh4wg789-patch-2.7.6/bin:/nix/store/q0jqhjabwaaak30l4sq3z0xi6jrkpnbn-xz-5.2.5-bin/bin | ||
18 | export HOST_PATH | ||
19 | IFS=$' \t\n' | ||
20 | IN_NIX_SHELL=impure | ||
21 | export IN_NIX_SHELL | ||
22 | LD=ld | ||
23 | export LD | ||
24 | MACHTYPE=x86_64-unknown-linux-gnu | ||
25 | NIX_BINTOOLS=/nix/store/f4w8p656gg6v2k1v0whwmyk09kz3k8ic-binutils-wrapper-2.35.1 | ||
26 | export NIX_BINTOOLS | ||
27 | NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 | ||
28 | export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu | ||
29 | NIX_BUILD_CORES=8 | ||
30 | export NIX_BUILD_CORES | ||
31 | NIX_CC=/nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0 | ||
32 | export NIX_CC | ||
33 | NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 | ||
34 | export NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu | ||
35 | NIX_CFLAGS_COMPILE=' -frandom-seed=hk8227smba -isystem /nix/store/91ym2jzh08470r4jb1d5pmh22vg2bpck-openssl-1.1.1i-dev/include -isystem /nix/store/saiwalr8jq58mbyipkn824r93gjjnw5x-ncurses-6.2-dev/include -isystem /nix/store/91ym2jzh08470r4jb1d5pmh22vg2bpck-openssl-1.1.1i-dev/include -isystem /nix/store/saiwalr8jq58mbyipkn824r93gjjnw5x-ncurses-6.2-dev/include' | ||
36 | export NIX_CFLAGS_COMPILE | ||
37 | NIX_ENFORCE_NO_NATIVE=1 | ||
38 | export NIX_ENFORCE_NO_NATIVE | ||
39 | NIX_HARDENING_ENABLE='fortify stackprotector pic strictoverflow format relro bindnow' | ||
40 | export NIX_HARDENING_ENABLE | ||
41 | NIX_INDENT_MAKE=1 | ||
42 | export NIX_INDENT_MAKE | ||
43 | NIX_LDFLAGS='-rpath /home/np/code/rust/obi/outputs/out/lib64 -rpath /home/np/code/rust/obi/outputs/out/lib -L/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84/lib -L/nix/store/kchm26396krqwdn2dkx6l0hb79lwlhr1-openssl-1.1.1i/lib -L/nix/store/d3nz4c5xf1bqz8rwr8m4gbsrny9ffidk-ncurses-6.2/lib -L/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84/lib -L/nix/store/kchm26396krqwdn2dkx6l0hb79lwlhr1-openssl-1.1.1i/lib -L/nix/store/d3nz4c5xf1bqz8rwr8m4gbsrny9ffidk-ncurses-6.2/lib' | ||
44 | export NIX_LDFLAGS | ||
45 | NIX_LIB64_IN_SELF_RPATH=1 | ||
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 | OPTERR=1 | ||
56 | OPTIND=1 | ||
57 | OSTYPE=linux-gnu | ||
58 | PATH=/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84/bin:/nix/store/pj3m562kh9lr7wjk3hlyandhd1qpapgh-rust-analyzer-unstable-2021-02-22/bin:/nix/store/9p0yf4yzsc8by6xviags56c3mb3fxkkw-cargo-1.49.0/bin:/nix/store/71707dbkha4mryph7ywp48wi2r1sc0hf-openssl-1.1.1i-bin/bin:/nix/store/saiwalr8jq58mbyipkn824r93gjjnw5x-ncurses-6.2-dev/bin:/nix/store/d3nz4c5xf1bqz8rwr8m4gbsrny9ffidk-ncurses-6.2/bin:/nix/store/d7lyvmvzf1a8qqhsxhdc3r6dwbdmfcap-patchelf-0.12/bin:/nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0/bin:/nix/store/wxri3dc14yd1w997vjfvsnn6qml64l4r-gcc-10.2.0/bin:/nix/store/fr2k1vwmyd5ngmb3y0v090nh21nn6gqp-glibc-2.32-35-bin/bin:/nix/store/ypsd29c5hgj1x7xz5ddffanxw5d8fh7b-coreutils-8.32/bin:/nix/store/f4w8p656gg6v2k1v0whwmyk09kz3k8ic-binutils-wrapper-2.35.1/bin:/nix/store/9f8y44vmjnwdjvzlff0gm3f3g6ycyyqy-binutils-2.35.1/bin:/nix/store/fr2k1vwmyd5ngmb3y0v090nh21nn6gqp-glibc-2.32-35-bin/bin:/nix/store/ypsd29c5hgj1x7xz5ddffanxw5d8fh7b-coreutils-8.32/bin:/nix/store/ypsd29c5hgj1x7xz5ddffanxw5d8fh7b-coreutils-8.32/bin:/nix/store/nq9l23mrm8irvl9qvxgvxqqkm5sfnc9d-findutils-4.7.0/bin:/nix/store/7yq29nnglh2s576n7vdmzqryym22f8rj-diffutils-3.7/bin:/nix/store/0839nqri8w69c91amlsq9bawaqlzpmh9-gnused-4.8/bin:/nix/store/wmiyjdsaydyv024al5ddqd3liljrfvk7-gnugrep-3.6/bin:/nix/store/snmar11l5w9jrxva2s5d6143nqmdgzqb-gawk-5.1.0/bin:/nix/store/cisss0pcfh72kmnsv4qa6h41wcwb9mkv-gnutar-1.32/bin:/nix/store/prdifiyrxwgf6sp4rwmrqvfdnvf72gw2-gzip-1.10/bin:/nix/store/pp9shwhcdxxbhgp96fcaj0g8x5g54zrl-bzip2-1.0.6.0.1-bin/bin:/nix/store/fydw5vhlhpq438cxv4vwpa8pf8p8fv5s-gnumake-4.3/bin:/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin:/nix/store/qcw3qagp709qwfza259zqss5qh4wg789-patch-2.7.6/bin:/nix/store/q0jqhjabwaaak30l4sq3z0xi6jrkpnbn-xz-5.2.5-bin/bin | ||
59 | export PATH | ||
60 | PIPESTATUS=([0]="0") | ||
61 | PS4='+ ' | ||
62 | RANLIB=ranlib | ||
63 | export RANLIB | ||
64 | READELF=readelf | ||
65 | export READELF | ||
66 | RUST_SRC_PATH=/nix/store/ncxadjgpdacbf69yhpgwvwnqhmh5yk96-rust-lib-src | ||
67 | export RUST_SRC_PATH | ||
68 | SHELL=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash | ||
69 | export SHELL | ||
70 | SIZE=size | ||
71 | export SIZE | ||
72 | SOURCE_DATE_EPOCH=315532800 | ||
73 | export SOURCE_DATE_EPOCH | ||
74 | STRINGS=strings | ||
75 | export STRINGS | ||
76 | STRIP=strip | ||
77 | export STRIP | ||
78 | XDG_DATA_DIRS=/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84/share:/nix/store/9p0yf4yzsc8by6xviags56c3mb3fxkkw-cargo-1.49.0/share:/nix/store/d3nz4c5xf1bqz8rwr8m4gbsrny9ffidk-ncurses-6.2/share:/nix/store/d7lyvmvzf1a8qqhsxhdc3r6dwbdmfcap-patchelf-0.12/share | ||
79 | export XDG_DATA_DIRS | ||
80 | _=export | ||
81 | buildInputs= | ||
82 | export buildInputs | ||
83 | builder=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash | ||
84 | export builder | ||
85 | commonStripFlags=--enable-deterministic-archives | ||
86 | configureFlags= | ||
87 | export configureFlags | ||
88 | defaultBuildInputs= | ||
89 | defaultNativeBuildInputs='/nix/store/d7lyvmvzf1a8qqhsxhdc3r6dwbdmfcap-patchelf-0.12 /nix/store/mjjy30kxz775bhhi6j9phw81qh6dsbrf-move-docs.sh /nix/store/kxw6q8v6isaqjm702d71n2421cxamq68-make-symlinks-relative.sh /nix/store/cl3qd985p1yxyfkj96v0hqxiy3w69xq5-compress-man-pages.sh /nix/store/h54dzwd7rdh2jlcv91424csl6d0ccgjy-strip.sh /nix/store/bnj8d7mvbkg3vdb07yz74yhl3g107qq5-patch-shebangs.sh /nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh /nix/store/8zxndz5ag0p6s526c2xyllhk1nrn4c3i-audit-tmpdir.sh /nix/store/c8n9kcdddp9np665xz6ri61b383nxvz8-move-systemd-user-units.sh /nix/store/1i5y55x4b4m9qkx5dqbmr1r6bvrqbanw-multiple-outputs.sh /nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh /nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh /nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh /nix/store/pr6nzbscdpg94yvr151lrif2kg0csx7b-reproducible-builds.sh /nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0' | ||
90 | depsBuildBuild= | ||
91 | export depsBuildBuild | ||
92 | depsBuildBuildPropagated= | ||
93 | export depsBuildBuildPropagated | ||
94 | depsBuildTarget= | ||
95 | export depsBuildTarget | ||
96 | depsBuildTargetPropagated= | ||
97 | export depsBuildTargetPropagated | ||
98 | depsHostHost= | ||
99 | export depsHostHost | ||
100 | depsHostHostPropagated= | ||
101 | export depsHostHostPropagated | ||
102 | depsTargetTarget= | ||
103 | export depsTargetTarget | ||
104 | depsTargetTargetPropagated= | ||
105 | export depsTargetTargetPropagated | ||
106 | doCheck= | ||
107 | export doCheck | ||
108 | doInstallCheck= | ||
109 | export doInstallCheck | ||
110 | dontAddDisableDepTrack=1 | ||
111 | export dontAddDisableDepTrack | ||
112 | envHostHostHooks=([0]="ccWrapper_addCVars" [1]="bintoolsWrapper_addLDVars") | ||
113 | envHostTargetHooks=([0]="ccWrapper_addCVars" [1]="bintoolsWrapper_addLDVars") | ||
114 | fixupOutputHooks=([0]="if [ -z \"\${dontPatchELF-}\" ]; then patchELF \"\$prefix\"; fi" [1]="_makeSymlinksRelative" [2]="if [ -z \"\${dontGzipMan-}\" ]; then compressManPages \"\$prefix\"; fi" [3]="_doStrip" [4]="patchShebangsAuto" [5]="_pruneLibtoolFiles" [6]="if [[ -z \"\${noAuditTmpdir-}\" && -e \"\$prefix\" ]]; then auditTmpdir \"\$prefix\"; fi" [7]="_moveSystemdUserUnits" [8]="_moveSbin" [9]="_moveLib64") | ||
115 | initialPath='/nix/store/ypsd29c5hgj1x7xz5ddffanxw5d8fh7b-coreutils-8.32 /nix/store/nq9l23mrm8irvl9qvxgvxqqkm5sfnc9d-findutils-4.7.0 /nix/store/7yq29nnglh2s576n7vdmzqryym22f8rj-diffutils-3.7 /nix/store/0839nqri8w69c91amlsq9bawaqlzpmh9-gnused-4.8 /nix/store/wmiyjdsaydyv024al5ddqd3liljrfvk7-gnugrep-3.6 /nix/store/snmar11l5w9jrxva2s5d6143nqmdgzqb-gawk-5.1.0 /nix/store/cisss0pcfh72kmnsv4qa6h41wcwb9mkv-gnutar-1.32 /nix/store/prdifiyrxwgf6sp4rwmrqvfdnvf72gw2-gzip-1.10 /nix/store/pp9shwhcdxxbhgp96fcaj0g8x5g54zrl-bzip2-1.0.6.0.1-bin /nix/store/fydw5vhlhpq438cxv4vwpa8pf8p8fv5s-gnumake-4.3 /nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23 /nix/store/qcw3qagp709qwfza259zqss5qh4wg789-patch-2.7.6 /nix/store/q0jqhjabwaaak30l4sq3z0xi6jrkpnbn-xz-5.2.5-bin' | ||
116 | name=nix-shell | ||
117 | export name | ||
118 | nativeBuildInputs='/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84 /nix/store/pgzjwsl6ilg93ifsx70ck5l2yv85fknm-rust-src-1.50.0-nightly-2020-12-22-bb1fbbf84 /nix/store/pj3m562kh9lr7wjk3hlyandhd1qpapgh-rust-analyzer-unstable-2021-02-22 /nix/store/9p0yf4yzsc8by6xviags56c3mb3fxkkw-cargo-1.49.0 /nix/store/91ym2jzh08470r4jb1d5pmh22vg2bpck-openssl-1.1.1i-dev /nix/store/saiwalr8jq58mbyipkn824r93gjjnw5x-ncurses-6.2-dev' | ||
119 | export nativeBuildInputs | ||
120 | nobuildPhase=$'echo\necho "This derivation is not meant to be built, aborting";\necho\nexit 1\n' | ||
121 | export nobuildPhase | ||
122 | out=/home/np/code/rust/obi/outputs/out | ||
123 | export out | ||
124 | outputBin=out | ||
125 | outputDev=out | ||
126 | outputDevdoc=REMOVE | ||
127 | outputDevman=out | ||
128 | outputDoc=out | ||
129 | outputInclude=out | ||
130 | outputInfo=out | ||
131 | outputLib=out | ||
132 | outputMan=out | ||
133 | outputs=out | ||
134 | export outputs | ||
135 | patches= | ||
136 | export patches | ||
137 | phases=nobuildPhase | ||
138 | export phases | ||
139 | pkg=/nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0 | ||
140 | pkgsBuildHost=([0]="/nix/store/ni0nxz7jnd3scrfqsdr6cragl95fqmyb-rust-1.50.0-nightly-2020-12-22-bb1fbbf84" [1]="/nix/store/pgzjwsl6ilg93ifsx70ck5l2yv85fknm-rust-src-1.50.0-nightly-2020-12-22-bb1fbbf84" [2]="/nix/store/pj3m562kh9lr7wjk3hlyandhd1qpapgh-rust-analyzer-unstable-2021-02-22" [3]="/nix/store/9p0yf4yzsc8by6xviags56c3mb3fxkkw-cargo-1.49.0" [4]="/nix/store/91ym2jzh08470r4jb1d5pmh22vg2bpck-openssl-1.1.1i-dev" [5]="/nix/store/71707dbkha4mryph7ywp48wi2r1sc0hf-openssl-1.1.1i-bin" [6]="/nix/store/kchm26396krqwdn2dkx6l0hb79lwlhr1-openssl-1.1.1i" [7]="/nix/store/saiwalr8jq58mbyipkn824r93gjjnw5x-ncurses-6.2-dev" [8]="/nix/store/d3nz4c5xf1bqz8rwr8m4gbsrny9ffidk-ncurses-6.2" [9]="/nix/store/d7lyvmvzf1a8qqhsxhdc3r6dwbdmfcap-patchelf-0.12" [10]="/nix/store/mjjy30kxz775bhhi6j9phw81qh6dsbrf-move-docs.sh" [11]="/nix/store/kxw6q8v6isaqjm702d71n2421cxamq68-make-symlinks-relative.sh" [12]="/nix/store/cl3qd985p1yxyfkj96v0hqxiy3w69xq5-compress-man-pages.sh" [13]="/nix/store/h54dzwd7rdh2jlcv91424csl6d0ccgjy-strip.sh" [14]="/nix/store/bnj8d7mvbkg3vdb07yz74yhl3g107qq5-patch-shebangs.sh" [15]="/nix/store/cickvswrvann041nqxb0rxilc46svw1n-prune-libtool-files.sh" [16]="/nix/store/8zxndz5ag0p6s526c2xyllhk1nrn4c3i-audit-tmpdir.sh" [17]="/nix/store/c8n9kcdddp9np665xz6ri61b383nxvz8-move-systemd-user-units.sh" [18]="/nix/store/1i5y55x4b4m9qkx5dqbmr1r6bvrqbanw-multiple-outputs.sh" [19]="/nix/store/kd4xwxjpjxi71jkm6ka0np72if9rm3y0-move-sbin.sh" [20]="/nix/store/fyaryjvghbkpfnsyw97hb3lyb37s1pd6-move-lib64.sh" [21]="/nix/store/ngg1cv31c8c7bcm2n8ww4g06nq7s4zhm-set-source-date-epoch-to-latest.sh" [22]="/nix/store/pr6nzbscdpg94yvr151lrif2kg0csx7b-reproducible-builds.sh" [23]="/nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0" [24]="/nix/store/f4w8p656gg6v2k1v0whwmyk09kz3k8ic-binutils-wrapper-2.35.1") | ||
141 | postFixupHooks=([0]="_multioutPropagateDev") | ||
142 | postUnpackHooks=([0]="_updateSourceDateEpochFromSourceRoot") | ||
143 | preConfigureHooks=([0]="_multioutConfig") | ||
144 | preFixupHooks=([0]="_moveToShare" [1]="_multioutDocs" [2]="_multioutDevs") | ||
145 | prefix=/home/np/code/rust/obi/outputs/out | ||
146 | propagatedBuildDepFiles=([0]="propagated-build-build-deps" [1]="propagated-native-build-inputs" [2]="propagated-build-target-deps") | ||
147 | propagatedBuildInputs= | ||
148 | export propagatedBuildInputs | ||
149 | propagatedHostDepFiles=([0]="propagated-host-host-deps" [1]="propagated-build-inputs") | ||
150 | propagatedNativeBuildInputs= | ||
151 | export propagatedNativeBuildInputs | ||
152 | propagatedTargetDepFiles=([0]="propagated-target-target-deps") | ||
153 | shell=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash | ||
154 | export shell | ||
155 | shellHook= | ||
156 | export shellHook | ||
157 | stdenv=/nix/store/sx5hrbrr1g47klxk7x429qd1xwhq9dqq-stdenv-linux | ||
158 | export stdenv | ||
159 | strictDeps= | ||
160 | export strictDeps | ||
161 | system=x86_64-linux | ||
162 | export system | ||
163 | unpackCmdHooks=([0]="_defaultUnpack") | ||
164 | PATH="$PATH:$nix_saved_PATH" | ||
165 | _activatePkgs () | ||
166 | { | ||
167 | local -i hostOffset targetOffset; | ||
168 | local pkg; | ||
169 | for hostOffset in "${allPlatOffsets[@]}"; | ||
170 | do | ||
171 | local pkgsVar="${pkgAccumVarVars[$hostOffset + 1]}"; | ||
172 | for targetOffset in "${allPlatOffsets[@]}"; | ||
173 | do | ||
174 | (( "$hostOffset" <= "$targetOffset" )) || continue; | ||
175 | local pkgsRef="${pkgsVar}[$targetOffset - $hostOffset]"; | ||
176 | local pkgsSlice="${!pkgsRef}[@]"; | ||
177 | for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; | ||
178 | do | ||
179 | activatePackage "$pkg" "$hostOffset" "$targetOffset"; | ||
180 | done; | ||
181 | done; | ||
182 | done | ||
183 | } | ||
184 | _addRpathPrefix () | ||
185 | { | ||
186 | if [ "${NIX_NO_SELF_RPATH:-0}" != 1 ]; then | ||
187 | export NIX_LDFLAGS="-rpath $1/lib ${NIX_LDFLAGS-}"; | ||
188 | if [ -n "${NIX_LIB64_IN_SELF_RPATH:-}" ]; then | ||
189 | export NIX_LDFLAGS="-rpath $1/lib64 ${NIX_LDFLAGS-}"; | ||
190 | fi; | ||
191 | if [ -n "${NIX_LIB32_IN_SELF_RPATH:-}" ]; then | ||
192 | export NIX_LDFLAGS="-rpath $1/lib32 ${NIX_LDFLAGS-}"; | ||
193 | fi; | ||
194 | fi | ||
195 | } | ||
196 | _addToEnv () | ||
197 | { | ||
198 | local -i depHostOffset depTargetOffset; | ||
199 | local pkg; | ||
200 | for depHostOffset in "${allPlatOffsets[@]}"; | ||
201 | do | ||
202 | local hookVar="${pkgHookVarVars[$depHostOffset + 1]}"; | ||
203 | local pkgsVar="${pkgAccumVarVars[$depHostOffset + 1]}"; | ||
204 | for depTargetOffset in "${allPlatOffsets[@]}"; | ||
205 | do | ||
206 | (( "$depHostOffset" <= "$depTargetOffset" )) || continue; | ||
207 | local hookRef="${hookVar}[$depTargetOffset - $depHostOffset]"; | ||
208 | if [[ -z "${strictDeps-}" ]]; then | ||
209 | local visitedPkgs=""; | ||
210 | for pkg in ${pkgsBuildBuild+"${pkgsBuildBuild[@]}"} ${pkgsBuildHost+"${pkgsBuildHost[@]}"} ${pkgsBuildTarget+"${pkgsBuildTarget[@]}"} ${pkgsHostHost+"${pkgsHostHost[@]}"} ${pkgsHostTarget+"${pkgsHostTarget[@]}"} ${pkgsTargetTarget+"${pkgsTargetTarget[@]}"}; | ||
211 | do | ||
212 | if [[ "$visitedPkgs" = *"$pkg"* ]]; then | ||
213 | continue; | ||
214 | fi; | ||
215 | runHook "${!hookRef}" "$pkg"; | ||
216 | visitedPkgs+=" $pkg"; | ||
217 | done; | ||
218 | else | ||
219 | local pkgsRef="${pkgsVar}[$depTargetOffset - $depHostOffset]"; | ||
220 | local pkgsSlice="${!pkgsRef}[@]"; | ||
221 | for pkg in ${!pkgsSlice+"${!pkgsSlice}"}; | ||
222 | do | ||
223 | runHook "${!hookRef}" "$pkg"; | ||
224 | done; | ||
225 | fi; | ||
226 | done; | ||
227 | done | ||
228 | } | ||
229 | _allFlags () | ||
230 | { | ||
231 | for varName in $(awk 'BEGIN { for (v in ENVIRON) if (v ~ /^[a-z][a-zA-Z0-9_]*$/) print v }'); | ||
232 | do | ||
233 | if (( "${NIX_DEBUG:-0}" >= 1 )); then | ||
234 | printf "@%s@ -> %q\n" "${varName}" "${!varName}"; | ||
235 | fi; | ||
236 | args+=("--subst-var" "$varName"); | ||
237 | done | ||
238 | } | ||
239 | _assignFirst () | ||
240 | { | ||
241 | local varName="$1"; | ||
242 | local REMOVE=REMOVE; | ||
243 | shift; | ||
244 | while (( $# )); do | ||
245 | if [ -n "${!1-}" ]; then | ||
246 | eval "${varName}"="$1"; | ||
247 | return; | ||
248 | fi; | ||
249 | shift; | ||
250 | done; | ||
251 | echo "Error: _assignFirst found no valid variant!"; | ||
252 | return 1 | ||
253 | } | ||
254 | _callImplicitHook () | ||
255 | { | ||
256 | local def="$1"; | ||
257 | local hookName="$2"; | ||
258 | if declare -F "$hookName" > /dev/null; then | ||
259 | "$hookName"; | ||
260 | else | ||
261 | if type -p "$hookName" > /dev/null; then | ||
262 | source "$hookName"; | ||
263 | else | ||
264 | if [ -n "${!hookName:-}" ]; then | ||
265 | eval "${!hookName}"; | ||
266 | else | ||
267 | return "$def"; | ||
268 | fi; | ||
269 | fi; | ||
270 | fi | ||
271 | } | ||
272 | _defaultUnpack () | ||
273 | { | ||
274 | local fn="$1"; | ||
275 | if [ -d "$fn" ]; then | ||
276 | cp -pr --reflink=auto -- "$fn" "$(stripHash "$fn")"; | ||
277 | else | ||
278 | case "$fn" in | ||
279 | *.tar.xz | *.tar.lzma | *.txz) | ||
280 | xz -d < "$fn" | tar xf - | ||
281 | ;; | ||
282 | *.tar | *.tar.* | *.tgz | *.tbz2 | *.tbz) | ||
283 | tar xf "$fn" | ||
284 | ;; | ||
285 | *) | ||
286 | return 1 | ||
287 | ;; | ||
288 | esac; | ||
289 | fi | ||
290 | } | ||
291 | _doStrip () | ||
292 | { | ||
293 | local -ra flags=(dontStripHost dontStripTarget); | ||
294 | local -ra stripCmds=(STRIP TARGET_STRIP); | ||
295 | if [[ "${STRIP-}" == "${TARGET_STRIP-}" ]]; then | ||
296 | dontStripTarget+=1; | ||
297 | fi; | ||
298 | local i; | ||
299 | for i in ${!stripCmds[@]}; | ||
300 | do | ||
301 | local -n flag="${flags[$i]}"; | ||
302 | local -n stripCmd="${stripCmds[$i]}"; | ||
303 | if [[ -n "${dontStrip-}" || -n "${flag-}" ]] || ! type -f "${stripCmd-}" 2> /dev/null; then | ||
304 | continue; | ||
305 | fi; | ||
306 | stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}; | ||
307 | if [ -n "$stripDebugList" ]; then | ||
308 | stripDirs "$stripCmd" "$stripDebugList" "${stripDebugFlags:--S}"; | ||
309 | fi; | ||
310 | stripAllList=${stripAllList:-}; | ||
311 | if [ -n "$stripAllList" ]; then | ||
312 | stripDirs "$stripCmd" "$stripAllList" "${stripAllFlags:--s}"; | ||
313 | fi; | ||
314 | done | ||
315 | } | ||
316 | _eval () | ||
317 | { | ||
318 | if declare -F "$1" > /dev/null 2>&1; then | ||
319 | "$@"; | ||
320 | else | ||
321 | eval "$1"; | ||
322 | fi | ||
323 | } | ||
324 | _makeSymlinksRelative () | ||
325 | { | ||
326 | local symlinkTarget; | ||
327 | if [ -n "${dontRewriteSymlinks-}" ]; then | ||
328 | return 0; | ||
329 | fi; | ||
330 | while IFS= read -r -d '' f; do | ||
331 | symlinkTarget=$(readlink "$f"); | ||
332 | if [[ "$symlinkTarget"/ != "$prefix"/* ]]; then | ||
333 | continue; | ||
334 | fi; | ||
335 | if [ ! -e "$symlinkTarget" ]; then | ||
336 | echo "the symlink $f is broken, it points to $symlinkTarget (which is missing)"; | ||
337 | fi; | ||
338 | echo "rewriting symlink $f to be relative to $prefix"; | ||
339 | ln -snrf "$symlinkTarget" "$f"; | ||
340 | done < <(find $prefix -type l -print0) | ||
341 | } | ||
342 | _moveLib64 () | ||
343 | { | ||
344 | if [ "${dontMoveLib64-}" = 1 ]; then | ||
345 | return; | ||
346 | fi; | ||
347 | if [ ! -e "$prefix/lib64" -o -L "$prefix/lib64" ]; then | ||
348 | return; | ||
349 | fi; | ||
350 | echo "moving $prefix/lib64/* to $prefix/lib"; | ||
351 | mkdir -p $prefix/lib; | ||
352 | shopt -s dotglob; | ||
353 | for i in $prefix/lib64/*; | ||
354 | do | ||
355 | mv --no-clobber "$i" $prefix/lib; | ||
356 | done; | ||
357 | shopt -u dotglob; | ||
358 | rmdir $prefix/lib64; | ||
359 | ln -s lib $prefix/lib64 | ||
360 | } | ||
361 | _moveSbin () | ||
362 | { | ||
363 | if [ "${dontMoveSbin-}" = 1 ]; then | ||
364 | return; | ||
365 | fi; | ||
366 | if [ ! -e "$prefix/sbin" -o -L "$prefix/sbin" ]; then | ||
367 | return; | ||
368 | fi; | ||
369 | echo "moving $prefix/sbin/* to $prefix/bin"; | ||
370 | mkdir -p $prefix/bin; | ||
371 | shopt -s dotglob; | ||
372 | for i in $prefix/sbin/*; | ||
373 | do | ||
374 | mv "$i" $prefix/bin; | ||
375 | done; | ||
376 | shopt -u dotglob; | ||
377 | rmdir $prefix/sbin; | ||
378 | ln -s bin $prefix/sbin | ||
379 | } | ||
380 | _moveSystemdUserUnits () | ||
381 | { | ||
382 | if [ "${dontMoveSystemdUserUnits:-0}" = 1 ]; then | ||
383 | return; | ||
384 | fi; | ||
385 | if [ ! -e "${prefix:?}/lib/systemd/user" ]; then | ||
386 | return; | ||
387 | fi; | ||
388 | local source="$prefix/lib/systemd/user"; | ||
389 | local target="$prefix/share/systemd/user"; | ||
390 | echo "moving $source/* to $target"; | ||
391 | mkdir -p "$target"; | ||
392 | ( shopt -s dotglob; | ||
393 | for i in "$source"/*; | ||
394 | do | ||
395 | mv "$i" "$target"; | ||
396 | done ); | ||
397 | rmdir "$source"; | ||
398 | ln -s "$target" "$source" | ||
399 | } | ||
400 | _moveToShare () | ||
401 | { | ||
402 | forceShare=${forceShare:=man doc info}; | ||
403 | if [ -z "$forceShare" -o -z "$out" ]; then | ||
404 | return; | ||
405 | fi; | ||
406 | for d in $forceShare; | ||
407 | do | ||
408 | if [ -d "$out/$d" ]; then | ||
409 | if [ -d "$out/share/$d" ]; then | ||
410 | echo "both $d/ and share/$d/ exist!"; | ||
411 | else | ||
412 | echo "moving $out/$d to $out/share/$d"; | ||
413 | mkdir -p $out/share; | ||
414 | mv $out/$d $out/share/; | ||
415 | fi; | ||
416 | fi; | ||
417 | done | ||
418 | } | ||
419 | _multioutConfig () | ||
420 | { | ||
421 | if [ "$outputs" = "out" ] || [ -z "${setOutputFlags-1}" ]; then | ||
422 | return; | ||
423 | fi; | ||
424 | if [ -z "$shareDocName" ]; then | ||
425 | local confScript="$configureScript"; | ||
426 | if [ -z "$confScript" ] && [ -x ./configure ]; then | ||
427 | confScript=./configure; | ||
428 | fi; | ||
429 | if [ -f "$confScript" ]; then | ||
430 | local shareDocName="$(sed -n "s/^PACKAGE_TARNAME='\(.*\)'$/\1/p" < "$confScript")"; | ||
431 | fi; | ||
432 | if [ -z "$shareDocName" ] || echo "$shareDocName" | grep -q '[^a-zA-Z0-9_-]'; then | ||
433 | shareDocName="$(echo "$name" | sed 's/-[^a-zA-Z].*//')"; | ||
434 | fi; | ||
435 | fi; | ||
436 | configureFlags=" --bindir=${!outputBin}/bin --sbindir=${!outputBin}/sbin --includedir=${!outputInclude}/include --oldincludedir=${!outputInclude}/include --mandir=${!outputMan}/share/man --infodir=${!outputInfo}/share/info --docdir=${!outputDoc}/share/doc/${shareDocName} --libdir=${!outputLib}/lib --libexecdir=${!outputLib}/libexec --localedir=${!outputLib}/share/locale $configureFlags"; | ||
437 | installFlags=" pkgconfigdir=${!outputDev}/lib/pkgconfig m4datadir=${!outputDev}/share/aclocal aclocaldir=${!outputDev}/share/aclocal $installFlags" | ||
438 | } | ||
439 | _multioutDevs () | ||
440 | { | ||
441 | if [ "$outputs" = "out" ] || [ -z "${moveToDev-1}" ]; then | ||
442 | return; | ||
443 | fi; | ||
444 | moveToOutput include "${!outputInclude}"; | ||
445 | moveToOutput lib/pkgconfig "${!outputDev}"; | ||
446 | moveToOutput share/pkgconfig "${!outputDev}"; | ||
447 | moveToOutput lib/cmake "${!outputDev}"; | ||
448 | moveToOutput share/aclocal "${!outputDev}"; | ||
449 | for f in "${!outputDev}"/{lib,share}/pkgconfig/*.pc; | ||
450 | do | ||
451 | echo "Patching '$f' includedir to output ${!outputInclude}"; | ||
452 | sed -i "/^includedir=/s,=\${prefix},=${!outputInclude}," "$f"; | ||
453 | done | ||
454 | } | ||
455 | _multioutDocs () | ||
456 | { | ||
457 | local REMOVE=REMOVE; | ||
458 | moveToOutput share/info "${!outputInfo}"; | ||
459 | moveToOutput share/doc "${!outputDoc}"; | ||
460 | moveToOutput share/gtk-doc "${!outputDevdoc}"; | ||
461 | moveToOutput share/devhelp/books "${!outputDevdoc}"; | ||
462 | moveToOutput share/man "${!outputMan}"; | ||
463 | moveToOutput share/man/man3 "${!outputDevman}" | ||
464 | } | ||
465 | _multioutPropagateDev () | ||
466 | { | ||
467 | if [ "$outputs" = "out" ]; then | ||
468 | return; | ||
469 | fi; | ||
470 | local outputFirst; | ||
471 | for outputFirst in $outputs; | ||
472 | do | ||
473 | break; | ||
474 | done; | ||
475 | local propagaterOutput="$outputDev"; | ||
476 | if [ -z "$propagaterOutput" ]; then | ||
477 | propagaterOutput="$outputFirst"; | ||
478 | fi; | ||
479 | if [ -z "${propagatedBuildOutputs+1}" ]; then | ||
480 | local po_dirty="$outputBin $outputInclude $outputLib"; | ||
481 | set +o pipefail; | ||
482 | propagatedBuildOutputs=`echo "$po_dirty" | tr -s ' ' '\n' | grep -v -F "$propagaterOutput" | sort -u | tr '\n' ' ' `; | ||
483 | set -o pipefail; | ||
484 | fi; | ||
485 | if [ -z "$propagatedBuildOutputs" ]; then | ||
486 | return; | ||
487 | fi; | ||
488 | mkdir -p "${!propagaterOutput}"/nix-support; | ||
489 | for output in $propagatedBuildOutputs; | ||
490 | do | ||
491 | echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/propagated-build-inputs; | ||
492 | done | ||
493 | } | ||
494 | _overrideFirst () | ||
495 | { | ||
496 | if [ -z "${!1-}" ]; then | ||
497 | _assignFirst "$@"; | ||
498 | fi | ||
499 | } | ||
500 | _pruneLibtoolFiles () | ||
501 | { | ||
502 | if [ "${dontPruneLibtoolFiles-}" ] || [ ! -e "$prefix" ]; then | ||
503 | return; | ||
504 | fi; | ||
505 | 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" \; | ||
506 | } | ||
507 | _updateSourceDateEpochFromSourceRoot () | ||
508 | { | ||
509 | if [ -n "$sourceRoot" ]; then | ||
510 | updateSourceDateEpoch "$sourceRoot"; | ||
511 | fi | ||
512 | } | ||
513 | activatePackage () | ||
514 | { | ||
515 | local pkg="$1"; | ||
516 | local -ri hostOffset="$2"; | ||
517 | local -ri targetOffset="$3"; | ||
518 | (( "$hostOffset" <= "$targetOffset" )) || exit -1; | ||
519 | if [ -f "$pkg" ]; then | ||
520 | source "$pkg"; | ||
521 | fi; | ||
522 | if [[ -z "${strictDeps-}" || "$hostOffset" -le -1 ]]; then | ||
523 | addToSearchPath _PATH "$pkg/bin"; | ||
524 | fi; | ||
525 | if [[ "$hostOffset" -le -1 ]]; then | ||
526 | addToSearchPath _XDG_DATA_DIRS "$pkg/share"; | ||
527 | fi; | ||
528 | if [[ "$hostOffset" -eq 0 && -d "$pkg/bin" ]]; then | ||
529 | addToSearchPath _HOST_PATH "$pkg/bin"; | ||
530 | fi; | ||
531 | if [[ -f "$pkg/nix-support/setup-hook" ]]; then | ||
532 | source "$pkg/nix-support/setup-hook"; | ||
533 | fi | ||
534 | } | ||
535 | addEnvHooks () | ||
536 | { | ||
537 | local depHostOffset="$1"; | ||
538 | shift; | ||
539 | local pkgHookVarsSlice="${pkgHookVarVars[$depHostOffset + 1]}[@]"; | ||
540 | local pkgHookVar; | ||
541 | for pkgHookVar in "${!pkgHookVarsSlice}"; | ||
542 | do | ||
543 | eval "${pkgHookVar}s"'+=("$@")'; | ||
544 | done | ||
545 | } | ||
546 | addToSearchPath () | ||
547 | { | ||
548 | addToSearchPathWithCustomDelimiter ":" "$@" | ||
549 | } | ||
550 | addToSearchPathWithCustomDelimiter () | ||
551 | { | ||
552 | local delimiter="$1"; | ||
553 | local varName="$2"; | ||
554 | local dir="$3"; | ||
555 | if [ -d "$dir" ]; then | ||
556 | export "${varName}=${!varName:+${!varName}${delimiter}}${dir}"; | ||
557 | fi | ||
558 | } | ||
559 | auditTmpdir () | ||
560 | { | ||
561 | local dir="$1"; | ||
562 | [ -e "$dir" ] || return 0; | ||
563 | header "checking for references to $TMPDIR/ in $dir..."; | ||
564 | local i; | ||
565 | while IFS= read -r -d '' i; do | ||
566 | if [[ "$i" =~ .build-id ]]; then | ||
567 | continue; | ||
568 | fi; | ||
569 | if isELF "$i"; then | ||
570 | if { | ||
571 | printf :; | ||
572 | patchelf --print-rpath "$i" | ||
573 | } | grep -q -F ":$TMPDIR/"; then | ||
574 | echo "RPATH of binary $i contains a forbidden reference to $TMPDIR/"; | ||
575 | exit 1; | ||
576 | fi; | ||
577 | fi; | ||
578 | if isScript "$i"; then | ||
579 | if [ -e "$(dirname "$i")/.$(basename "$i")-wrapped" ]; then | ||
580 | if grep -q -F "$TMPDIR/" "$i"; then | ||
581 | echo "wrapper script $i contains a forbidden reference to $TMPDIR/"; | ||
582 | exit 1; | ||
583 | fi; | ||
584 | fi; | ||
585 | fi; | ||
586 | done < <(find "$dir" -type f -print0); | ||
587 | stopNest | ||
588 | } | ||
589 | bintoolsWrapper_addLDVars () | ||
590 | { | ||
591 | local role_post; | ||
592 | getHostRoleEnvHook; | ||
593 | if [[ -d "$1/lib64" && ! -L "$1/lib64" ]]; then | ||
594 | export NIX_LDFLAGS${role_post}+=" -L$1/lib64"; | ||
595 | fi; | ||
596 | if [[ -d "$1/lib" ]]; then | ||
597 | local -a glob=($1/lib/lib*); | ||
598 | if [ "${#glob[*]}" -gt 0 ]; then | ||
599 | export NIX_LDFLAGS${role_post}+=" -L$1/lib"; | ||
600 | fi; | ||
601 | fi | ||
602 | } | ||
603 | buildPhase () | ||
604 | { | ||
605 | runHook preBuild; | ||
606 | : ${makeFlags=}; | ||
607 | if [[ -z "$makeFlags" && -z "${makefile:-}" && ! ( -e Makefile || -e makefile || -e GNUmakefile ) ]]; then | ||
608 | echo "no Makefile, doing nothing"; | ||
609 | else | ||
610 | foundMakefile=1; | ||
611 | local flagsArray=(${enableParallelBuilding:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} SHELL=$SHELL $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} $buildFlags ${buildFlagsArray+"${buildFlagsArray[@]}"}); | ||
612 | echoCmd 'build flags' "${flagsArray[@]}"; | ||
613 | make ${makefile:+-f $makefile} "${flagsArray[@]}"; | ||
614 | unset flagsArray; | ||
615 | fi; | ||
616 | runHook postBuild | ||
617 | } | ||
618 | ccWrapper_addCVars () | ||
619 | { | ||
620 | local role_post; | ||
621 | getHostRoleEnvHook; | ||
622 | if [ -d "$1/include" ]; then | ||
623 | export NIX_CFLAGS_COMPILE${role_post}+=" -isystem $1/include"; | ||
624 | fi; | ||
625 | if [ -d "$1/Library/Frameworks" ]; then | ||
626 | export NIX_CFLAGS_COMPILE${role_post}+=" -iframework $1/Library/Frameworks"; | ||
627 | fi | ||
628 | } | ||
629 | checkPhase () | ||
630 | { | ||
631 | runHook preCheck; | ||
632 | if [[ -z "${foundMakefile:-}" ]]; then | ||
633 | echo "no Makefile or custom checkPhase, doing nothing"; | ||
634 | runHook postCheck; | ||
635 | return; | ||
636 | fi; | ||
637 | if [[ -z "${checkTarget:-}" ]]; then | ||
638 | if make -n ${makefile:+-f $makefile} check > /dev/null 2>&1; then | ||
639 | checkTarget=check; | ||
640 | else | ||
641 | if make -n ${makefile:+-f $makefile} test > /dev/null 2>&1; then | ||
642 | checkTarget=test; | ||
643 | fi; | ||
644 | fi; | ||
645 | fi; | ||
646 | if [[ -z "${checkTarget:-}" ]]; then | ||
647 | echo "no check/test target in ${makefile:-Makefile}, doing nothing"; | ||
648 | else | ||
649 | local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} SHELL=$SHELL $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} ${checkFlags:-VERBOSE=y} ${checkFlagsArray+"${checkFlagsArray[@]}"} ${checkTarget}); | ||
650 | echoCmd 'check flags' "${flagsArray[@]}"; | ||
651 | make ${makefile:+-f $makefile} "${flagsArray[@]}"; | ||
652 | unset flagsArray; | ||
653 | fi; | ||
654 | runHook postCheck | ||
655 | } | ||
656 | closeNest () | ||
657 | { | ||
658 | true | ||
659 | } | ||
660 | compressManPages () | ||
661 | { | ||
662 | local dir="$1"; | ||
663 | if [ -L "$dir"/share ] || [ -L "$dir"/share/man ] || [ ! -d "$dir/share/man" ]; then | ||
664 | return; | ||
665 | fi; | ||
666 | echo "gzipping man pages under $dir/share/man/"; | ||
667 | find "$dir"/share/man/ -type f -a '!' -regex '.*\.\(bz2\|gz\)$' -print0 | while IFS= read -r -d '' f; do | ||
668 | if gzip -c -n "$f" > "$f".gz; then | ||
669 | rm "$f"; | ||
670 | else | ||
671 | rm "$f".gz; | ||
672 | fi; | ||
673 | done; | ||
674 | find "$dir"/share/man/ -type l -a '!' -regex '.*\.\(bz2\|gz\)$' -print0 | sort -z | while IFS= read -r -d '' f; do | ||
675 | local target; | ||
676 | target="$(readlink -f "$f")"; | ||
677 | if [ -f "$target".gz ]; then | ||
678 | ln -sf "$target".gz "$f".gz && rm "$f"; | ||
679 | fi; | ||
680 | done | ||
681 | } | ||
682 | configurePhase () | ||
683 | { | ||
684 | runHook preConfigure; | ||
685 | : ${configureScript=}; | ||
686 | : ${configureFlags=}; | ||
687 | if [[ -z "$configureScript" && -x ./configure ]]; then | ||
688 | configureScript=./configure; | ||
689 | fi; | ||
690 | if [ -z "${dontFixLibtool:-}" ]; then | ||
691 | local i; | ||
692 | find . -iname "ltmain.sh" -print0 | while IFS='' read -r -d '' i; do | ||
693 | echo "fixing libtool script $i"; | ||
694 | fixLibtool "$i"; | ||
695 | done; | ||
696 | fi; | ||
697 | if [[ -z "${dontAddPrefix:-}" && -n "$prefix" ]]; then | ||
698 | configureFlags="${prefixKey:---prefix=}$prefix $configureFlags"; | ||
699 | fi; | ||
700 | if [ -z "${dontAddDisableDepTrack:-}" ]; then | ||
701 | if [ -f "$configureScript" ] && grep -q dependency-tracking "$configureScript"; then | ||
702 | configureFlags="--disable-dependency-tracking $configureFlags"; | ||
703 | fi; | ||
704 | fi; | ||
705 | if [ -z "${dontDisableStatic:-}" ]; then | ||
706 | if [ -f "$configureScript" ] && grep -q enable-static "$configureScript"; then | ||
707 | configureFlags="--disable-static $configureFlags"; | ||
708 | fi; | ||
709 | fi; | ||
710 | if [ -n "$configureScript" ]; then | ||
711 | local flagsArray=($configureFlags ${configureFlagsArray+"${configureFlagsArray[@]}"}); | ||
712 | echoCmd 'configure flags' "${flagsArray[@]}"; | ||
713 | $configureScript "${flagsArray[@]}"; | ||
714 | unset flagsArray; | ||
715 | else | ||
716 | echo "no configure script, doing nothing"; | ||
717 | fi; | ||
718 | runHook postConfigure | ||
719 | } | ||
720 | consumeEntire () | ||
721 | { | ||
722 | if IFS='' read -r -N 0 $1; then | ||
723 | echo "consumeEntire(): ERROR: Input null bytes, won't process" 1>&2; | ||
724 | return 1; | ||
725 | fi | ||
726 | } | ||
727 | distPhase () | ||
728 | { | ||
729 | runHook preDist; | ||
730 | local flagsArray=($distFlags ${distFlagsArray+"${distFlagsArray[@]}"} ${distTarget:-dist}); | ||
731 | echo 'dist flags: %q' "${flagsArray[@]}"; | ||
732 | make ${makefile:+-f $makefile} "${flagsArray[@]}"; | ||
733 | if [ "${dontCopyDist:-0}" != 1 ]; then | ||
734 | mkdir -p "$out/tarballs"; | ||
735 | cp -pvd ${tarballs:-*.tar.gz} "$out/tarballs"; | ||
736 | fi; | ||
737 | runHook postDist | ||
738 | } | ||
739 | dumpVars () | ||
740 | { | ||
741 | if [ "${noDumpEnvVars:-0}" != 1 ]; then | ||
742 | export 2> /dev/null >| "$NIX_BUILD_TOP/env-vars" || true; | ||
743 | fi | ||
744 | } | ||
745 | echoCmd () | ||
746 | { | ||
747 | printf "%s:" "$1"; | ||
748 | shift; | ||
749 | printf ' %q' "$@"; | ||
750 | echo | ||
751 | } | ||
752 | exitHandler () | ||
753 | { | ||
754 | exitCode="$?"; | ||
755 | set +e; | ||
756 | if [ -n "${showBuildStats:-}" ]; then | ||
757 | times > "$NIX_BUILD_TOP/.times"; | ||
758 | local -a times=($(cat "$NIX_BUILD_TOP/.times")); | ||
759 | echo "build time elapsed: " "${times[@]}"; | ||
760 | fi; | ||
761 | if (( "$exitCode" != 0 )); then | ||
762 | runHook failureHook; | ||
763 | if [ -n "${succeedOnFailure:-}" ]; then | ||
764 | echo "build failed with exit code $exitCode (ignored)"; | ||
765 | mkdir -p "$out/nix-support"; | ||
766 | printf "%s" "$exitCode" > "$out/nix-support/failed"; | ||
767 | exit 0; | ||
768 | fi; | ||
769 | else | ||
770 | runHook exitHook; | ||
771 | fi; | ||
772 | exit "$exitCode" | ||
773 | } | ||
774 | findInputs () | ||
775 | { | ||
776 | local -r pkg="$1"; | ||
777 | local -ri hostOffset="$2"; | ||
778 | local -ri targetOffset="$3"; | ||
779 | (( "$hostOffset" <= "$targetOffset" )) || exit -1; | ||
780 | local varVar="${pkgAccumVarVars[$hostOffset + 1]}"; | ||
781 | local varRef="$varVar[\$targetOffset - \$hostOffset]"; | ||
782 | local var="${!varRef}"; | ||
783 | unset -v varVar varRef; | ||
784 | local varSlice="$var[*]"; | ||
785 | case "${!varSlice-}" in | ||
786 | *" $pkg "*) | ||
787 | return 0 | ||
788 | ;; | ||
789 | esac; | ||
790 | unset -v varSlice; | ||
791 | eval "$var"'+=("$pkg")'; | ||
792 | if ! [ -e "$pkg" ]; then | ||
793 | echo "build input $pkg does not exist" 1>&2; | ||
794 | exit 1; | ||
795 | fi; | ||
796 | local -i mapOffsetResult; | ||
797 | function mapOffset () | ||
798 | { | ||
799 | local -ri inputOffset="$1"; | ||
800 | if (( "$inputOffset" <= 0 )); then | ||
801 | local -ri outputOffset="$inputOffset + $hostOffset"; | ||
802 | else | ||
803 | local -ri outputOffset="$inputOffset - 1 + $targetOffset"; | ||
804 | fi; | ||
805 | mapOffsetResult="$outputOffset" | ||
806 | }; | ||
807 | local -i relHostOffset; | ||
808 | for relHostOffset in "${allPlatOffsets[@]}"; | ||
809 | do | ||
810 | local files="${propagatedDepFilesVars[$relHostOffset + 1]}"; | ||
811 | mapOffset relHostOffset; | ||
812 | local -i hostOffsetNext="$mapOffsetResult"; | ||
813 | [[ "${allPlatOffsets[*]}" = *"$hostOffsetNext"* ]] || continue; | ||
814 | local -i relTargetOffset; | ||
815 | for relTargetOffset in "${allPlatOffsets[@]}"; | ||
816 | do | ||
817 | (( "$relHostOffset" <= "$relTargetOffset" )) || continue; | ||
818 | local fileRef="${files}[$relTargetOffset - $relHostOffset]"; | ||
819 | local file="${!fileRef}"; | ||
820 | unset -v fileRef; | ||
821 | mapOffset relTargetOffset; | ||
822 | local -i targetOffsetNext="$mapOffsetResult"; | ||
823 | [[ "${allPlatOffsets[*]}" = *"$targetOffsetNext"* ]] || continue; | ||
824 | [[ -f "$pkg/nix-support/$file" ]] || continue; | ||
825 | local pkgNext; | ||
826 | read -r -d '' pkgNext < "$pkg/nix-support/$file" || true; | ||
827 | for pkgNext in $pkgNext; | ||
828 | do | ||
829 | findInputs "$pkgNext" "$hostOffsetNext" "$targetOffsetNext"; | ||
830 | done; | ||
831 | done; | ||
832 | done | ||
833 | } | ||
834 | fixLibtool () | ||
835 | { | ||
836 | sed -i -e 's^eval sys_lib_.*search_path=.*^^' "$1" | ||
837 | } | ||
838 | fixupPhase () | ||
839 | { | ||
840 | local output; | ||
841 | for output in $outputs; | ||
842 | do | ||
843 | if [ -e "${!output}" ]; then | ||
844 | chmod -R u+w "${!output}"; | ||
845 | fi; | ||
846 | done; | ||
847 | runHook preFixup; | ||
848 | local output; | ||
849 | for output in $outputs; | ||
850 | do | ||
851 | prefix="${!output}" runHook fixupOutput; | ||
852 | done; | ||
853 | declare -ra flatVars=(depsBuildBuildPropagated propagatedNativeBuildInputs depsBuildTargetPropagated depsHostHostPropagated propagatedBuildInputs depsTargetTargetPropagated); | ||
854 | declare -ra flatFiles=("${propagatedBuildDepFiles[@]}" "${propagatedHostDepFiles[@]}" "${propagatedTargetDepFiles[@]}"); | ||
855 | local propagatedInputsIndex; | ||
856 | for propagatedInputsIndex in "${!flatVars[@]}"; | ||
857 | do | ||
858 | local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]"; | ||
859 | local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}"; | ||
860 | [[ -n "${!propagatedInputsSlice}" ]] || continue; | ||
861 | mkdir -p "${!outputDev}/nix-support"; | ||
862 | printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile"; | ||
863 | done; | ||
864 | if [ -n "${setupHook:-}" ]; then | ||
865 | mkdir -p "${!outputDev}/nix-support"; | ||
866 | substituteAll "$setupHook" "${!outputDev}/nix-support/setup-hook"; | ||
867 | fi; | ||
868 | if [ -n "${setupHooks:-}" ]; then | ||
869 | mkdir -p "${!outputDev}/nix-support"; | ||
870 | local hook; | ||
871 | for hook in $setupHooks; | ||
872 | do | ||
873 | local content; | ||
874 | consumeEntire content < "$hook"; | ||
875 | substituteAllStream content "file '$hook'" >> "${!outputDev}/nix-support/setup-hook"; | ||
876 | unset -v content; | ||
877 | done; | ||
878 | unset -v hook; | ||
879 | fi; | ||
880 | if [ -n "${propagatedUserEnvPkgs:-}" ]; then | ||
881 | mkdir -p "${!outputBin}/nix-support"; | ||
882 | printWords $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"; | ||
883 | fi; | ||
884 | runHook postFixup | ||
885 | } | ||
886 | genericBuild () | ||
887 | { | ||
888 | if [ -f "${buildCommandPath:-}" ]; then | ||
889 | source "$buildCommandPath"; | ||
890 | return; | ||
891 | fi; | ||
892 | if [ -n "${buildCommand:-}" ]; then | ||
893 | eval "$buildCommand"; | ||
894 | return; | ||
895 | fi; | ||
896 | if [ -z "${phases:-}" ]; then | ||
897 | phases="${prePhases:-} unpackPhase patchPhase ${preConfigurePhases:-} configurePhase ${preBuildPhases:-} buildPhase checkPhase ${preInstallPhases:-} installPhase ${preFixupPhases:-} fixupPhase installCheckPhase ${preDistPhases:-} distPhase ${postPhases:-}"; | ||
898 | fi; | ||
899 | for curPhase in $phases; | ||
900 | do | ||
901 | if [[ "$curPhase" = unpackPhase && -n "${dontUnpack:-}" ]]; then | ||
902 | continue; | ||
903 | fi; | ||
904 | if [[ "$curPhase" = patchPhase && -n "${dontPatch:-}" ]]; then | ||
905 | continue; | ||
906 | fi; | ||
907 | if [[ "$curPhase" = configurePhase && -n "${dontConfigure:-}" ]]; then | ||
908 | continue; | ||
909 | fi; | ||
910 | if [[ "$curPhase" = buildPhase && -n "${dontBuild:-}" ]]; then | ||
911 | continue; | ||
912 | fi; | ||
913 | if [[ "$curPhase" = checkPhase && -z "${doCheck:-}" ]]; then | ||
914 | continue; | ||
915 | fi; | ||
916 | if [[ "$curPhase" = installPhase && -n "${dontInstall:-}" ]]; then | ||
917 | continue; | ||
918 | fi; | ||
919 | if [[ "$curPhase" = fixupPhase && -n "${dontFixup:-}" ]]; then | ||
920 | continue; | ||
921 | fi; | ||
922 | if [[ "$curPhase" = installCheckPhase && -z "${doInstallCheck:-}" ]]; then | ||
923 | continue; | ||
924 | fi; | ||
925 | if [[ "$curPhase" = distPhase && -z "${doDist:-}" ]]; then | ||
926 | continue; | ||
927 | fi; | ||
928 | if [[ -n $NIX_LOG_FD ]]; then | ||
929 | echo "@nix { \"action\": \"setPhase\", \"phase\": \"$curPhase\" }" 1>&$NIX_LOG_FD; | ||
930 | fi; | ||
931 | showPhaseHeader "$curPhase"; | ||
932 | dumpVars; | ||
933 | eval "${!curPhase:-$curPhase}"; | ||
934 | if [ "$curPhase" = unpackPhase ]; then | ||
935 | cd "${sourceRoot:-.}"; | ||
936 | fi; | ||
937 | done | ||
938 | } | ||
939 | getHostRole () | ||
940 | { | ||
941 | getRole "$hostOffset" | ||
942 | } | ||
943 | getHostRoleEnvHook () | ||
944 | { | ||
945 | getRole "$depHostOffset" | ||
946 | } | ||
947 | getRole () | ||
948 | { | ||
949 | case $1 in | ||
950 | -1) | ||
951 | role_post='_FOR_BUILD' | ||
952 | ;; | ||
953 | 0) | ||
954 | role_post='' | ||
955 | ;; | ||
956 | 1) | ||
957 | role_post='_FOR_TARGET' | ||
958 | ;; | ||
959 | *) | ||
960 | echo "binutils-wrapper-2.35.1: used as improper sort of dependency" > 2; | ||
961 | return 1 | ||
962 | ;; | ||
963 | esac | ||
964 | } | ||
965 | getTargetRole () | ||
966 | { | ||
967 | getRole "$targetOffset" | ||
968 | } | ||
969 | getTargetRoleEnvHook () | ||
970 | { | ||
971 | getRole "$depTargetOffset" | ||
972 | } | ||
973 | getTargetRoleWrapper () | ||
974 | { | ||
975 | case $targetOffset in | ||
976 | -1) | ||
977 | export NIX_BINTOOLS_WRAPPER_TARGET_BUILD_x86_64_unknown_linux_gnu=1 | ||
978 | ;; | ||
979 | 0) | ||
980 | export NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu=1 | ||
981 | ;; | ||
982 | 1) | ||
983 | export NIX_BINTOOLS_WRAPPER_TARGET_TARGET_x86_64_unknown_linux_gnu=1 | ||
984 | ;; | ||
985 | *) | ||
986 | echo "binutils-wrapper-2.35.1: used as improper sort of dependency" > 2; | ||
987 | return 1 | ||
988 | ;; | ||
989 | esac | ||
990 | } | ||
991 | header () | ||
992 | { | ||
993 | echo "$1" | ||
994 | } | ||
995 | installCheckPhase () | ||
996 | { | ||
997 | runHook preInstallCheck; | ||
998 | if [[ -z "${foundMakefile:-}" ]]; then | ||
999 | echo "no Makefile or custom installCheckPhase, doing nothing"; | ||
1000 | else | ||
1001 | if [[ -z "${installCheckTarget:-}" ]] && ! make -n ${makefile:+-f $makefile} ${installCheckTarget:-installcheck} > /dev/null 2>&1; then | ||
1002 | echo "no installcheck target in ${makefile:-Makefile}, doing nothing"; | ||
1003 | else | ||
1004 | local flagsArray=(${enableParallelChecking:+-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES}} SHELL=$SHELL $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} $installCheckFlags ${installCheckFlagsArray+"${installCheckFlagsArray[@]}"} ${installCheckTarget:-installcheck}); | ||
1005 | echoCmd 'installcheck flags' "${flagsArray[@]}"; | ||
1006 | make ${makefile:+-f $makefile} "${flagsArray[@]}"; | ||
1007 | unset flagsArray; | ||
1008 | fi; | ||
1009 | fi; | ||
1010 | runHook postInstallCheck | ||
1011 | } | ||
1012 | installPhase () | ||
1013 | { | ||
1014 | runHook preInstall; | ||
1015 | if [ -n "$prefix" ]; then | ||
1016 | mkdir -p "$prefix"; | ||
1017 | fi; | ||
1018 | local flagsArray=(SHELL=$SHELL $makeFlags ${makeFlagsArray+"${makeFlagsArray[@]}"} $installFlags ${installFlagsArray+"${installFlagsArray[@]}"} ${installTargets:-install}); | ||
1019 | echoCmd 'install flags' "${flagsArray[@]}"; | ||
1020 | make ${makefile:+-f $makefile} "${flagsArray[@]}"; | ||
1021 | unset flagsArray; | ||
1022 | runHook postInstall | ||
1023 | } | ||
1024 | isELF () | ||
1025 | { | ||
1026 | local fn="$1"; | ||
1027 | local fd; | ||
1028 | local magic; | ||
1029 | exec {fd}< "$fn"; | ||
1030 | read -r -n 4 -u "$fd" magic; | ||
1031 | exec {fd}>&-; | ||
1032 | if [ "$magic" = 'ELF' ]; then | ||
1033 | return 0; | ||
1034 | else | ||
1035 | return 1; | ||
1036 | fi | ||
1037 | } | ||
1038 | isScript () | ||
1039 | { | ||
1040 | local fn="$1"; | ||
1041 | local fd; | ||
1042 | local magic; | ||
1043 | exec {fd}< "$fn"; | ||
1044 | read -r -n 2 -u "$fd" magic; | ||
1045 | exec {fd}>&-; | ||
1046 | if [[ "$magic" =~ \#! ]]; then | ||
1047 | return 0; | ||
1048 | else | ||
1049 | return 1; | ||
1050 | fi | ||
1051 | } | ||
1052 | mapOffset () | ||
1053 | { | ||
1054 | local -ri inputOffset="$1"; | ||
1055 | if (( "$inputOffset" <= 0 )); then | ||
1056 | local -ri outputOffset="$inputOffset + $hostOffset"; | ||
1057 | else | ||
1058 | local -ri outputOffset="$inputOffset - 1 + $targetOffset"; | ||
1059 | fi; | ||
1060 | mapOffsetResult="$outputOffset" | ||
1061 | } | ||
1062 | moveToOutput () | ||
1063 | { | ||
1064 | local patt="$1"; | ||
1065 | local dstOut="$2"; | ||
1066 | local output; | ||
1067 | for output in $outputs; | ||
1068 | do | ||
1069 | if [ "${!output}" = "$dstOut" ]; then | ||
1070 | continue; | ||
1071 | fi; | ||
1072 | local srcPath; | ||
1073 | for srcPath in "${!output}"/$patt; | ||
1074 | do | ||
1075 | if [ ! -e "$srcPath" ] && [ ! -L "$srcPath" ]; then | ||
1076 | continue; | ||
1077 | fi; | ||
1078 | if [ "$dstOut" = REMOVE ]; then | ||
1079 | echo "Removing $srcPath"; | ||
1080 | rm -r "$srcPath"; | ||
1081 | else | ||
1082 | local dstPath="$dstOut${srcPath#${!output}}"; | ||
1083 | echo "Moving $srcPath to $dstPath"; | ||
1084 | if [ -d "$dstPath" ] && [ -d "$srcPath" ]; then | ||
1085 | rmdir "$srcPath" --ignore-fail-on-non-empty; | ||
1086 | if [ -d "$srcPath" ]; then | ||
1087 | mv -t "$dstPath" "$srcPath"/*; | ||
1088 | rmdir "$srcPath"; | ||
1089 | fi; | ||
1090 | else | ||
1091 | mkdir -p "$(readlink -m "$dstPath/..")"; | ||
1092 | mv "$srcPath" "$dstPath"; | ||
1093 | fi; | ||
1094 | fi; | ||
1095 | local srcParent="$(readlink -m "$srcPath/..")"; | ||
1096 | if rmdir "$srcParent"; then | ||
1097 | echo "Removing empty $srcParent/ and (possibly) its parents"; | ||
1098 | rmdir -p --ignore-fail-on-non-empty "$(readlink -m "$srcParent/..")" 2> /dev/null || true; | ||
1099 | fi; | ||
1100 | done; | ||
1101 | done | ||
1102 | } | ||
1103 | patchELF () | ||
1104 | { | ||
1105 | local dir="$1"; | ||
1106 | [ -e "$dir" ] || return 0; | ||
1107 | header "shrinking RPATHs of ELF executables and libraries in $dir"; | ||
1108 | local i; | ||
1109 | while IFS= read -r -d '' i; do | ||
1110 | if [[ "$i" =~ .build-id ]]; then | ||
1111 | continue; | ||
1112 | fi; | ||
1113 | if ! isELF "$i"; then | ||
1114 | continue; | ||
1115 | fi; | ||
1116 | echo "shrinking $i"; | ||
1117 | patchelf --shrink-rpath "$i" || true; | ||
1118 | done < <(find "$dir" -type f -print0); | ||
1119 | stopNest | ||
1120 | } | ||
1121 | patchPhase () | ||
1122 | { | ||
1123 | runHook prePatch; | ||
1124 | for i in ${patches:-}; | ||
1125 | do | ||
1126 | header "applying patch $i" 3; | ||
1127 | local uncompress=cat; | ||
1128 | case "$i" in | ||
1129 | *.gz) | ||
1130 | uncompress="gzip -d" | ||
1131 | ;; | ||
1132 | *.bz2) | ||
1133 | uncompress="bzip2 -d" | ||
1134 | ;; | ||
1135 | *.xz) | ||
1136 | uncompress="xz -d" | ||
1137 | ;; | ||
1138 | *.lzma) | ||
1139 | uncompress="lzma -d" | ||
1140 | ;; | ||
1141 | esac; | ||
1142 | $uncompress < "$i" 2>&1 | patch ${patchFlags:--p1}; | ||
1143 | done; | ||
1144 | runHook postPatch | ||
1145 | } | ||
1146 | patchShebangs () | ||
1147 | { | ||
1148 | local pathName; | ||
1149 | if [[ "$1" == "--host" ]]; then | ||
1150 | pathName=HOST_PATH; | ||
1151 | shift; | ||
1152 | else | ||
1153 | if [[ "$1" == "--build" ]]; then | ||
1154 | pathName=PATH; | ||
1155 | shift; | ||
1156 | fi; | ||
1157 | fi; | ||
1158 | echo "patching script interpreter paths in $@"; | ||
1159 | local f; | ||
1160 | local oldPath; | ||
1161 | local newPath; | ||
1162 | local arg0; | ||
1163 | local args; | ||
1164 | local oldInterpreterLine; | ||
1165 | local newInterpreterLine; | ||
1166 | if [[ $# -eq 0 ]]; then | ||
1167 | echo "No arguments supplied to patchShebangs" 1>&2; | ||
1168 | return 0; | ||
1169 | fi; | ||
1170 | local f; | ||
1171 | while IFS= read -r -d '' f; do | ||
1172 | isScript "$f" || continue; | ||
1173 | read -r oldInterpreterLine < "$f"; | ||
1174 | read -r oldPath arg0 args <<< "${oldInterpreterLine:2}"; | ||
1175 | if [[ -z "$pathName" ]]; then | ||
1176 | if [[ -n $strictDeps && $f == "$NIX_STORE"* ]]; then | ||
1177 | pathName=HOST_PATH; | ||
1178 | else | ||
1179 | pathName=PATH; | ||
1180 | fi; | ||
1181 | fi; | ||
1182 | if [[ "$oldPath" == *"/bin/env" ]]; then | ||
1183 | if [[ $arg0 == "-"* || $arg0 == *"="* ]]; then | ||
1184 | echo "$f: unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)" 1>&2; | ||
1185 | exit 1; | ||
1186 | fi; | ||
1187 | newPath="$(PATH="${!pathName}" command -v "$arg0" || true)"; | ||
1188 | else | ||
1189 | if [[ -z $oldPath ]]; then | ||
1190 | oldPath="/bin/sh"; | ||
1191 | fi; | ||
1192 | newPath="$(PATH="${!pathName}" command -v "$(basename "$oldPath")" || true)"; | ||
1193 | args="$arg0 $args"; | ||
1194 | fi; | ||
1195 | newInterpreterLine="$newPath $args"; | ||
1196 | newInterpreterLine=${newInterpreterLine%${newInterpreterLine##*[![:space:]]}}; | ||
1197 | if [[ -n "$oldPath" && "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]]; then | ||
1198 | if [[ -n "$newPath" && "$newPath" != "$oldPath" ]]; then | ||
1199 | echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""; | ||
1200 | escapedInterpreterLine=${newInterpreterLine//\\/\\\\}; | ||
1201 | timestamp=$(stat --printf "%y" "$f"); | ||
1202 | sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"; | ||
1203 | touch --date "$timestamp" "$f"; | ||
1204 | fi; | ||
1205 | fi; | ||
1206 | done < <(find "$@" -type f -perm -0100 -print0); | ||
1207 | stopNest | ||
1208 | } | ||
1209 | patchShebangsAuto () | ||
1210 | { | ||
1211 | if [[ -z "${dontPatchShebangs-}" && -e "$prefix" ]]; then | ||
1212 | if [[ "$output" != out && "$output" = "$outputDev" ]]; then | ||
1213 | patchShebangs --build "$prefix"; | ||
1214 | else | ||
1215 | patchShebangs --host "$prefix"; | ||
1216 | fi; | ||
1217 | fi | ||
1218 | } | ||
1219 | printLines () | ||
1220 | { | ||
1221 | (( "$#" > 0 )) || return 0; | ||
1222 | printf '%s\n' "$@" | ||
1223 | } | ||
1224 | printWords () | ||
1225 | { | ||
1226 | (( "$#" > 0 )) || return 0; | ||
1227 | printf '%s ' "$@" | ||
1228 | } | ||
1229 | runHook () | ||
1230 | { | ||
1231 | local hookName="$1"; | ||
1232 | shift; | ||
1233 | local hooksSlice="${hookName%Hook}Hooks[@]"; | ||
1234 | local hook; | ||
1235 | for hook in "_callImplicitHook 0 $hookName" ${!hooksSlice+"${!hooksSlice}"}; | ||
1236 | do | ||
1237 | _eval "$hook" "$@"; | ||
1238 | done; | ||
1239 | return 0 | ||
1240 | } | ||
1241 | runOneHook () | ||
1242 | { | ||
1243 | local hookName="$1"; | ||
1244 | shift; | ||
1245 | local hooksSlice="${hookName%Hook}Hooks[@]"; | ||
1246 | local hook ret=1; | ||
1247 | for hook in "_callImplicitHook 1 $hookName" ${!hooksSlice+"${!hooksSlice}"}; | ||
1248 | do | ||
1249 | if _eval "$hook" "$@"; then | ||
1250 | ret=0; | ||
1251 | break; | ||
1252 | fi; | ||
1253 | done; | ||
1254 | return "$ret" | ||
1255 | } | ||
1256 | showPhaseHeader () | ||
1257 | { | ||
1258 | local phase="$1"; | ||
1259 | case "$phase" in | ||
1260 | unpackPhase) | ||
1261 | header "unpacking sources" | ||
1262 | ;; | ||
1263 | patchPhase) | ||
1264 | header "patching sources" | ||
1265 | ;; | ||
1266 | configurePhase) | ||
1267 | header "configuring" | ||
1268 | ;; | ||
1269 | buildPhase) | ||
1270 | header "building" | ||
1271 | ;; | ||
1272 | checkPhase) | ||
1273 | header "running tests" | ||
1274 | ;; | ||
1275 | installPhase) | ||
1276 | header "installing" | ||
1277 | ;; | ||
1278 | fixupPhase) | ||
1279 | header "post-installation fixup" | ||
1280 | ;; | ||
1281 | installCheckPhase) | ||
1282 | header "running install tests" | ||
1283 | ;; | ||
1284 | *) | ||
1285 | header "$phase" | ||
1286 | ;; | ||
1287 | esac | ||
1288 | } | ||
1289 | stopNest () | ||
1290 | { | ||
1291 | true | ||
1292 | } | ||
1293 | stripDirs () | ||
1294 | { | ||
1295 | local cmd="$1"; | ||
1296 | local dirs="$2"; | ||
1297 | local stripFlags="$3"; | ||
1298 | local dirsNew=; | ||
1299 | local d; | ||
1300 | for d in ${dirs}; | ||
1301 | do | ||
1302 | if [ -d "$prefix/$d" ]; then | ||
1303 | dirsNew="${dirsNew} $prefix/$d "; | ||
1304 | fi; | ||
1305 | done; | ||
1306 | dirs=${dirsNew}; | ||
1307 | if [ -n "${dirs}" ]; then | ||
1308 | header "stripping (with command $cmd and flags $stripFlags) in$dirs"; | ||
1309 | find $dirs -type f -exec $cmd $commonStripFlags $stripFlags '{}' \; 2> /dev/null; | ||
1310 | stopNest; | ||
1311 | fi | ||
1312 | } | ||
1313 | stripHash () | ||
1314 | { | ||
1315 | local strippedName casematchOpt=0; | ||
1316 | strippedName="$(basename -- "$1")"; | ||
1317 | shopt -q nocasematch && casematchOpt=1; | ||
1318 | shopt -u nocasematch; | ||
1319 | if [[ "$strippedName" =~ ^[a-z0-9]{32}- ]]; then | ||
1320 | echo "${strippedName:33}"; | ||
1321 | else | ||
1322 | echo "$strippedName"; | ||
1323 | fi; | ||
1324 | if (( casematchOpt )); then | ||
1325 | shopt -s nocasematch; | ||
1326 | fi | ||
1327 | } | ||
1328 | substitute () | ||
1329 | { | ||
1330 | local input="$1"; | ||
1331 | local output="$2"; | ||
1332 | shift 2; | ||
1333 | if [ ! -f "$input" ]; then | ||
1334 | echo "substitute(): ERROR: file '$input' does not exist" 1>&2; | ||
1335 | return 1; | ||
1336 | fi; | ||
1337 | local content; | ||
1338 | consumeEntire content < "$input"; | ||
1339 | if [ -e "$output" ]; then | ||
1340 | chmod +w "$output"; | ||
1341 | fi; | ||
1342 | substituteStream content "file '$input'" "$@" > "$output" | ||
1343 | } | ||
1344 | substituteAll () | ||
1345 | { | ||
1346 | local input="$1"; | ||
1347 | local output="$2"; | ||
1348 | local -a args=(); | ||
1349 | _allFlags; | ||
1350 | substitute "$input" "$output" "${args[@]}" | ||
1351 | } | ||
1352 | substituteAllInPlace () | ||
1353 | { | ||
1354 | local fileName="$1"; | ||
1355 | shift; | ||
1356 | substituteAll "$fileName" "$fileName" "$@" | ||
1357 | } | ||
1358 | substituteAllStream () | ||
1359 | { | ||
1360 | local -a args=(); | ||
1361 | _allFlags; | ||
1362 | substituteStream "$1" "$2" "${args[@]}" | ||
1363 | } | ||
1364 | substituteInPlace () | ||
1365 | { | ||
1366 | local fileName="$1"; | ||
1367 | shift; | ||
1368 | substitute "$fileName" "$fileName" "$@" | ||
1369 | } | ||
1370 | substituteStream () | ||
1371 | { | ||
1372 | local var=$1; | ||
1373 | local description=$2; | ||
1374 | shift 2; | ||
1375 | while (( "$#" )); do | ||
1376 | case "$1" in | ||
1377 | --replace) | ||
1378 | pattern="$2"; | ||
1379 | replacement="$3"; | ||
1380 | shift 3; | ||
1381 | local savedvar; | ||
1382 | savedvar="${!var}"; | ||
1383 | eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; | ||
1384 | if [ "$pattern" != "$replacement" ]; then | ||
1385 | if [ "${!var}" == "$savedvar" ]; then | ||
1386 | echo "substituteStream(): WARNING: pattern '$pattern' doesn't match anything in $description" 1>&2; | ||
1387 | fi; | ||
1388 | fi | ||
1389 | ;; | ||
1390 | --subst-var) | ||
1391 | local varName="$2"; | ||
1392 | shift 2; | ||
1393 | if ! [[ "$varName" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then | ||
1394 | echo "substituteStream(): ERROR: substitution variables must be valid Bash names, \"$varName\" isn't." 1>&2; | ||
1395 | return 1; | ||
1396 | fi; | ||
1397 | if [ -z ${!varName+x} ]; then | ||
1398 | echo "substituteStream(): ERROR: variable \$$varName is unset" 1>&2; | ||
1399 | return 1; | ||
1400 | fi; | ||
1401 | pattern="@$varName@"; | ||
1402 | replacement="${!varName}"; | ||
1403 | eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}' | ||
1404 | ;; | ||
1405 | --subst-var-by) | ||
1406 | pattern="@$2@"; | ||
1407 | replacement="$3"; | ||
1408 | eval "$var"'=${'"$var"'//"$pattern"/"$replacement"}'; | ||
1409 | shift 3 | ||
1410 | ;; | ||
1411 | *) | ||
1412 | echo "substituteStream(): ERROR: Invalid command line argument: $1" 1>&2; | ||
1413 | return 1 | ||
1414 | ;; | ||
1415 | esac; | ||
1416 | done; | ||
1417 | printf "%s" "${!var}" | ||
1418 | } | ||
1419 | unpackFile () | ||
1420 | { | ||
1421 | curSrc="$1"; | ||
1422 | header "unpacking source archive $curSrc" 3; | ||
1423 | if ! runOneHook unpackCmd "$curSrc"; then | ||
1424 | echo "do not know how to unpack source archive $curSrc"; | ||
1425 | exit 1; | ||
1426 | fi | ||
1427 | } | ||
1428 | unpackPhase () | ||
1429 | { | ||
1430 | runHook preUnpack; | ||
1431 | if [ -z "${srcs:-}" ]; then | ||
1432 | if [ -z "${src:-}" ]; then | ||
1433 | echo 'variable $src or $srcs should point to the source'; | ||
1434 | exit 1; | ||
1435 | fi; | ||
1436 | srcs="$src"; | ||
1437 | fi; | ||
1438 | local dirsBefore=""; | ||
1439 | for i in *; | ||
1440 | do | ||
1441 | if [ -d "$i" ]; then | ||
1442 | dirsBefore="$dirsBefore $i "; | ||
1443 | fi; | ||
1444 | done; | ||
1445 | for i in $srcs; | ||
1446 | do | ||
1447 | unpackFile "$i"; | ||
1448 | done; | ||
1449 | : ${sourceRoot=}; | ||
1450 | if [ -n "${setSourceRoot:-}" ]; then | ||
1451 | runOneHook setSourceRoot; | ||
1452 | else | ||
1453 | if [ -z "$sourceRoot" ]; then | ||
1454 | for i in *; | ||
1455 | do | ||
1456 | if [ -d "$i" ]; then | ||
1457 | case $dirsBefore in | ||
1458 | *\ $i\ *) | ||
1459 | |||
1460 | ;; | ||
1461 | *) | ||
1462 | if [ -n "$sourceRoot" ]; then | ||
1463 | echo "unpacker produced multiple directories"; | ||
1464 | exit 1; | ||
1465 | fi; | ||
1466 | sourceRoot="$i" | ||
1467 | ;; | ||
1468 | esac; | ||
1469 | fi; | ||
1470 | done; | ||
1471 | fi; | ||
1472 | fi; | ||
1473 | if [ -z "$sourceRoot" ]; then | ||
1474 | echo "unpacker appears to have produced no directories"; | ||
1475 | exit 1; | ||
1476 | fi; | ||
1477 | echo "source root is $sourceRoot"; | ||
1478 | if [ "${dontMakeSourcesWritable:-0}" != 1 ]; then | ||
1479 | chmod -R u+w -- "$sourceRoot"; | ||
1480 | fi; | ||
1481 | runHook postUnpack | ||
1482 | } | ||
1483 | updateSourceDateEpoch () | ||
1484 | { | ||
1485 | local path="$1"; | ||
1486 | 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)); | ||
1487 | local time="${res[0]//\.[0-9]*/}"; | ||
1488 | local newestFile="${res[1]}"; | ||
1489 | if [ "${time:-0}" -gt "$SOURCE_DATE_EPOCH" ]; then | ||
1490 | echo "setting SOURCE_DATE_EPOCH to timestamp $time of file $newestFile"; | ||
1491 | export SOURCE_DATE_EPOCH="$time"; | ||
1492 | local now="$(date +%s)"; | ||
1493 | if [ "$time" -gt $((now - 60)) ]; then | ||
1494 | echo "warning: file $newestFile may be generated; SOURCE_DATE_EPOCH may be non-deterministic"; | ||
1495 | fi; | ||
1496 | fi | ||
1497 | } | ||
1498 | |||
1499 | export NIX_BUILD_TOP="$(mktemp -d --tmpdir nix-shell.XXXXXX)" | ||
1500 | export TMP="$NIX_BUILD_TOP" | ||
1501 | export TMPDIR="$NIX_BUILD_TOP" | ||
1502 | export TEMP="$NIX_BUILD_TOP" | ||
1503 | export TEMPDIR="$NIX_BUILD_TOP" | ||
1504 | eval "$shellHook" | ||