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