aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-26 04:47:12 +0000
committerAkshay <[email protected]>2021-02-26 04:47:12 +0000
commit7979dd9cc3d2c3c2782cdabc2411b3acf7b7d5f2 (patch)
tree3daf3f78f75c1c95767be76cf028bc5ca951addf
init with spec info
l---------.direnv/flake-profile1
-rw-r--r--.direnv/flake-profile.rc1504
-rw-r--r--.gitignore2
-rw-r--r--Cargo.toml9
-rw-r--r--flake.lock91
-rw-r--r--flake.nix55
-rw-r--r--spec.md45
-rw-r--r--src/lib.rs7
8 files changed, 1714 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 @@
1unset shellHook
2nix_saved_PATH="$PATH"
3AR=ar
4export AR
5AS=as
6export AS
7BASH=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash
8CC=gcc
9export CC
10CONFIG_SHELL=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash
11export CONFIG_SHELL
12CXX=g++
13export CXX
14DIRSTACK=()
15GROUPS=()
16HOSTTYPE=x86_64
17HOST_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
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/f4w8p656gg6v2k1v0whwmyk09kz3k8ic-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/i9a3zzf2spmw67jppvkj2yavnbka62id-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=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'
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/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'
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/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
59export PATH
60PIPESTATUS=([0]="0")
61PS4='+ '
62RANLIB=ranlib
63export RANLIB
64READELF=readelf
65export READELF
66RUST_SRC_PATH=/nix/store/ncxadjgpdacbf69yhpgwvwnqhmh5yk96-rust-lib-src
67export RUST_SRC_PATH
68SHELL=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash
69export SHELL
70SIZE=size
71export SIZE
72SOURCE_DATE_EPOCH=315532800
73export SOURCE_DATE_EPOCH
74STRINGS=strings
75export STRINGS
76STRIP=strip
77export STRIP
78XDG_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
79export XDG_DATA_DIRS
80_=export
81buildInputs=
82export buildInputs
83builder=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash
84export builder
85commonStripFlags=--enable-deterministic-archives
86configureFlags=
87export configureFlags
88defaultBuildInputs=
89defaultNativeBuildInputs='/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'
90depsBuildBuild=
91export depsBuildBuild
92depsBuildBuildPropagated=
93export depsBuildBuildPropagated
94depsBuildTarget=
95export depsBuildTarget
96depsBuildTargetPropagated=
97export depsBuildTargetPropagated
98depsHostHost=
99export depsHostHost
100depsHostHostPropagated=
101export depsHostHostPropagated
102depsTargetTarget=
103export depsTargetTarget
104depsTargetTargetPropagated=
105export depsTargetTargetPropagated
106doCheck=
107export doCheck
108doInstallCheck=
109export doInstallCheck
110dontAddDisableDepTrack=1
111export dontAddDisableDepTrack
112envHostHostHooks=([0]="ccWrapper_addCVars" [1]="bintoolsWrapper_addLDVars")
113envHostTargetHooks=([0]="ccWrapper_addCVars" [1]="bintoolsWrapper_addLDVars")
114fixupOutputHooks=([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")
115initialPath='/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'
116name=nix-shell
117export name
118nativeBuildInputs='/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'
119export nativeBuildInputs
120nobuildPhase=$'echo\necho "This derivation is not meant to be built, aborting";\necho\nexit 1\n'
121export nobuildPhase
122out=/home/np/code/rust/obi/outputs/out
123export out
124outputBin=out
125outputDev=out
126outputDevdoc=REMOVE
127outputDevman=out
128outputDoc=out
129outputInclude=out
130outputInfo=out
131outputLib=out
132outputMan=out
133outputs=out
134export outputs
135patches=
136export patches
137phases=nobuildPhase
138export phases
139pkg=/nix/store/i9a3zzf2spmw67jppvkj2yavnbka62id-gcc-wrapper-10.2.0
140pkgsBuildHost=([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")
141postFixupHooks=([0]="_multioutPropagateDev")
142postUnpackHooks=([0]="_updateSourceDateEpochFromSourceRoot")
143preConfigureHooks=([0]="_multioutConfig")
144preFixupHooks=([0]="_moveToShare" [1]="_multioutDocs" [2]="_multioutDevs")
145prefix=/home/np/code/rust/obi/outputs/out
146propagatedBuildDepFiles=([0]="propagated-build-build-deps" [1]="propagated-native-build-inputs" [2]="propagated-build-target-deps")
147propagatedBuildInputs=
148export propagatedBuildInputs
149propagatedHostDepFiles=([0]="propagated-host-host-deps" [1]="propagated-build-inputs")
150propagatedNativeBuildInputs=
151export propagatedNativeBuildInputs
152propagatedTargetDepFiles=([0]="propagated-target-target-deps")
153shell=/nix/store/yyy7wr7r9jwjjqkr1yn643g3wzv010zd-bash-4.4-p23/bin/bash
154export shell
155shellHook=
156export shellHook
157stdenv=/nix/store/sx5hrbrr1g47klxk7x429qd1xwhq9dqq-stdenv-linux
158export stdenv
159strictDeps=
160export strictDeps
161system=x86_64-linux
162export system
163unpackCmdHooks=([0]="_defaultUnpack")
164PATH="$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}
513activatePackage ()
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}
535addEnvHooks ()
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}
546addToSearchPath ()
547{
548 addToSearchPathWithCustomDelimiter ":" "$@"
549}
550addToSearchPathWithCustomDelimiter ()
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}
559auditTmpdir ()
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}
589bintoolsWrapper_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}
603buildPhase ()
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}
618ccWrapper_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}
629checkPhase ()
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}
656closeNest ()
657{
658 true
659}
660compressManPages ()
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}
682configurePhase ()
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}
720consumeEntire ()
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}
727distPhase ()
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}
739dumpVars ()
740{
741 if [ "${noDumpEnvVars:-0}" != 1 ]; then
742 export 2> /dev/null >| "$NIX_BUILD_TOP/env-vars" || true;
743 fi
744}
745echoCmd ()
746{
747 printf "%s:" "$1";
748 shift;
749 printf ' %q' "$@";
750 echo
751}
752exitHandler ()
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}
774findInputs ()
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}
834fixLibtool ()
835{
836 sed -i -e 's^eval sys_lib_.*search_path=.*^^' "$1"
837}
838fixupPhase ()
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}
886genericBuild ()
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}
939getHostRole ()
940{
941 getRole "$hostOffset"
942}
943getHostRoleEnvHook ()
944{
945 getRole "$depHostOffset"
946}
947getRole ()
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}
965getTargetRole ()
966{
967 getRole "$targetOffset"
968}
969getTargetRoleEnvHook ()
970{
971 getRole "$depTargetOffset"
972}
973getTargetRoleWrapper ()
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}
991header ()
992{
993 echo "$1"
994}
995installCheckPhase ()
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}
1012installPhase ()
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}
1024isELF ()
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}
1038isScript ()
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}
1052mapOffset ()
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}
1062moveToOutput ()
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}
1103patchELF ()
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}
1121patchPhase ()
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}
1146patchShebangs ()
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}
1209patchShebangsAuto ()
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}
1219printLines ()
1220{
1221 (( "$#" > 0 )) || return 0;
1222 printf '%s\n' "$@"
1223}
1224printWords ()
1225{
1226 (( "$#" > 0 )) || return 0;
1227 printf '%s ' "$@"
1228}
1229runHook ()
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}
1241runOneHook ()
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}
1256showPhaseHeader ()
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}
1289stopNest ()
1290{
1291 true
1292}
1293stripDirs ()
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}
1313stripHash ()
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}
1328substitute ()
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}
1344substituteAll ()
1345{
1346 local input="$1";
1347 local output="$2";
1348 local -a args=();
1349 _allFlags;
1350 substitute "$input" "$output" "${args[@]}"
1351}
1352substituteAllInPlace ()
1353{
1354 local fileName="$1";
1355 shift;
1356 substituteAll "$fileName" "$fileName" "$@"
1357}
1358substituteAllStream ()
1359{
1360 local -a args=();
1361 _allFlags;
1362 substituteStream "$1" "$2" "${args[@]}"
1363}
1364substituteInPlace ()
1365{
1366 local fileName="$1";
1367 shift;
1368 substitute "$fileName" "$fileName" "$@"
1369}
1370substituteStream ()
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}
1419unpackFile ()
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}
1428unpackPhase ()
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}
1483updateSourceDateEpoch ()
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
1499export NIX_BUILD_TOP="$(mktemp -d --tmpdir nix-shell.XXXXXX)"
1500export TMP="$NIX_BUILD_TOP"
1501export TMPDIR="$NIX_BUILD_TOP"
1502export TEMP="$NIX_BUILD_TOP"
1503export TEMPDIR="$NIX_BUILD_TOP"
1504eval "$shellHook"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..96ef6c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
1/target
2Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..d3ca6e4
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,9 @@
1[package]
2name = "obi"
3version = "0.1.0"
4authors = ["Akshay <[email protected]>"]
5edition = "2018"
6
7# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8
9[dependencies]
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..405e9d8
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,91 @@
1{
2 "nodes": {
3 "mozillapkgs": {
4 "flake": false,
5 "locked": {
6 "lastModified": 1603906276,
7 "narHash": "sha256-RsNPnEKd7BcogwkqhaV5kI/HuNC4flH/OQCC/4W5y/8=",
8 "owner": "mozilla",
9 "repo": "nixpkgs-mozilla",
10 "rev": "8c007b60731c07dd7a052cce508de3bb1ae849b4",
11 "type": "github"
12 },
13 "original": {
14 "owner": "mozilla",
15 "repo": "nixpkgs-mozilla",
16 "type": "github"
17 }
18 },
19 "naersk": {
20 "inputs": {
21 "nixpkgs": "nixpkgs"
22 },
23 "locked": {
24 "lastModified": 1613655351,
25 "narHash": "sha256-BLBnt3BYsh92qKgqZljckM9s5sZUt30cBQF5b/5pVCU=",
26 "owner": "nmattia",
27 "repo": "naersk",
28 "rev": "1a9e5ddc51bc44c1bf872e02fe2702dc40e8af48",
29 "type": "github"
30 },
31 "original": {
32 "owner": "nmattia",
33 "repo": "naersk",
34 "type": "github"
35 }
36 },
37 "nixpkgs": {
38 "locked": {
39 "lastModified": 1614267055,
40 "narHash": "sha256-DGhx+THNuZK4btDwp++TlJYXfMxiuhMw3nNLt5w1uA8=",
41 "owner": "NixOS",
42 "repo": "nixpkgs",
43 "rev": "1d982f3677cf9df4cbd5095558a6d954d97e3cc2",
44 "type": "github"
45 },
46 "original": {
47 "id": "nixpkgs",
48 "type": "indirect"
49 }
50 },
51 "nixpkgs_2": {
52 "locked": {
53 "lastModified": 1614267055,
54 "narHash": "sha256-DGhx+THNuZK4btDwp++TlJYXfMxiuhMw3nNLt5w1uA8=",
55 "owner": "NixOS",
56 "repo": "nixpkgs",
57 "rev": "1d982f3677cf9df4cbd5095558a6d954d97e3cc2",
58 "type": "github"
59 },
60 "original": {
61 "id": "nixpkgs",
62 "type": "indirect"
63 }
64 },
65 "root": {
66 "inputs": {
67 "mozillapkgs": "mozillapkgs",
68 "naersk": "naersk",
69 "nixpkgs": "nixpkgs_2",
70 "utils": "utils"
71 }
72 },
73 "utils": {
74 "locked": {
75 "lastModified": 1610051610,
76 "narHash": "sha256-U9rPz/usA1/Aohhk7Cmc2gBrEEKRzcW4nwPWMPwja4Y=",
77 "owner": "numtide",
78 "repo": "flake-utils",
79 "rev": "3982c9903e93927c2164caa727cd3f6a0e6d14cc",
80 "type": "github"
81 },
82 "original": {
83 "owner": "numtide",
84 "repo": "flake-utils",
85 "type": "github"
86 }
87 }
88 },
89 "root": "root",
90 "version": 7
91}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..f467cd2
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,55 @@
1{
2 inputs = {
3 utils.url = "github:numtide/flake-utils";
4 naersk.url = "github:nmattia/naersk";
5 mozillapkgs = {
6 url = "github:mozilla/nixpkgs-mozilla";
7 flake = false;
8 };
9 };
10
11 outputs = { self, nixpkgs, utils, naersk, mozillapkgs }:
12 utils.lib.eachDefaultSystem (system: let
13 pkgs = nixpkgs.legacyPackages."${system}";
14
15 # Get a specific rust version
16 mozilla = pkgs.callPackage (mozillapkgs + "/package-set.nix") {};
17 rust = (mozilla.rustChannelOf {
18 date = "2020-12-23";
19 channel = "nightly";
20 sha256 = "LbKHsCOFXWpg/SEyACfzZuWjKbkXdH6EJKOPSGoO01E="; # set zeros after modifying channel or date
21 }).rust;
22 rust-src = (mozilla.rustChannelOf {
23 date = "2020-12-23";
24 channel = "nightly";
25 sha256 = "LbKHsCOFXWpg/SEyACfzZuWjKbkXdH6EJKOPSGoO01E="; # set zeros after modifying channel or date
26 }).rust-src;
27
28 naersk-lib = naersk.lib."${system}".override {
29 cargo = rust;
30 rustc = rust;
31 };
32 in rec {
33 packages.my-project = naersk-lib.buildPackage {
34 pname = "dijo";
35 version = "0.2.6";
36 root = ./.;
37 };
38 defaultPackage = packages.my-project;
39 apps.my-project = utils.lib.mkApp {
40 drv = packages.my-project;
41 };
42 defaultApp = apps.my-project;
43 devShell = pkgs.mkShell {
44 nativeBuildInputs = [
45 rust
46 rust-src
47 pkgs.rust-analyzer
48 pkgs.cargo
49 pkgs.openssl
50 pkgs.ncurses
51 ];
52 RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
53 };
54 });
55 }
diff --git a/spec.md b/spec.md
new file mode 100644
index 0000000..7f455e2
--- /dev/null
+++ b/spec.md
@@ -0,0 +1,45 @@
1# One Bit Image
2
3The One Bit Image is a file format to store single bit depth
4images, similar to 1-bit BMP files. It is a learning
5adventure and does not aim to be ubiquitous or
6well-performing. The name is shortened to `obi`, any files
7that wish to be identified as this format may use the file
8extension `.obi`, for example: `apple.obi`.
9
10## Technical Specification
11
12The file format consists of the following sections:
13
14 - File Header: 10 bytes, 0x0000 - 0x00A0
15 - Image Information Header: 16 bytes, 0x00A0 - 0x01A0
16 - Pixel data: Variable, 0x1A0 - Variable
17
18### File Header (10 bytes)
19
20This header contains the following metadata about the file
21itself:
22
23 - OBI version (2 bytes, 0x0000)
24 - File size in bytes (4 bytes, 0x0020)
25 - Data offset: Offset from the beginning of the file to the
26 beginning of bitmap data (4 bytes, 0x0060)
27
28### Image Information Header (16 bytes)
29
30This header contains metadata about the image:
31
32 - Width: Horizontal size of the bitmap data in pixels (4
33 bytes, 0x00A0).
34 - Height: Vertical size of the bitmap data in pixels (4
35 bytes, 0x00E0).
36 - Compression Algorithm: The following types of compression
37 are supported: RLE, Kosinki etc. Set 0 if no compression
38 (4 bytes, 0x0120).
39 - Image size after compression (set 0 if no compression,
40 i.e., Compression=0). (4 bytes, 0x0160)
41
42### Pixel Data (ImageInformationHeader.Width * ImageInformationHeader.Height bytes)
43
44The image data. Each pixel is a single bit, the size of
45Pixel Data is given by `Width * Height`.
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..31e1bb2
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,7 @@
1#[cfg(test)]
2mod tests {
3 #[test]
4 fn it_works() {
5 assert_eq!(2 + 2, 4);
6 }
7}