Build Raspberry PI 3 Image

Hello Community!

Trying to follow the build instructions from here: NixOS on ARM - NixOS Wiki - Section: Compiling through binfmt QEMU

The sd_img.nix I’m using is here: https://github.com/OptimisticShaggy/docker/blob/a591622bc94e639f5af7273c7b8be9c09a157697/Nix%20OS/pi3/sd-image.nix

Specific Command I’m using:

nix-build ‘<nixpkgs/nixos>’ -A config.system.build.sdImage -I nixos-config=./sd-image.nix --argstr system aarch64-linux

I am getting the error:

trace: warning: system.stateVersion is not set, defaulting to 22.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
error: The option system.build.installBootLoader' is defined multiple times. Only one bootloader can be enabled at a time. This requirement has not been checked until NixOS 22.05. Earlier versions defaulted to the last definition. Change your configuration to enable only one bootloader. Definition values: - In /nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/loader/generic-extlinux-compatible’: “/nix/store/bacnhmfkhscndg6nwp9y82bfcv6mxqg0-extlinux-conf-builder.sh -g 20 -t 5 -c”
- In `/nix/var/nix/profiles/per-user/root/channels/nixos/nixos/modules/system/boot/loader/raspberrypi/raspberrypi.nix’: “/nix/store/d4ifhim9cccnqjd9c8br7nd3kz4ddl7r-uboot-builder.sh -g 20 -t 5 -c”
(use ‘–show-trace’ to show detailed location information)

What is wrong with my configuration file?

Short version: You’re trying to set the bootloader and the sd image config you’re importing as also doing so, creating a conflict.

You may find this interesting https://github.com/gytis-ivaskevicius/orangepi-r1-plus-nixos-image

Hey Tejing,

Thanks for pointing that out, helped me realize what is already trying to be built!

Hey gytis-ivaskevicius,

I did; thanks for the share, will hang onto this.

After going back to using a different Nix, I used this image instead: https://github.com/OptimisticShaggy/docker/blob/8cfc46a78e70415aeb8e2bfb30821c9bd13690de/Nix%20OS/pi3/sd-img.nix

This is the output from the Build:


....many /nix/store packages....

  /nix/store/z8byzdc46w0drcq0pkq13lrzlryj1wcb-nspr-4.34
  /nix/store/zbj1pgvig7066pp4hqywh546wj3jg77w-libass-0.15.2.tar.xz
  /nix/store/zrfmyw18rix85qadjypkpirybl4jkca9-qemu-host-cpu-only-7.0.0
building '/nix/store/z2ckpncryqnq8jyx6cnc0bkqaj8mri5l-bash-5.1-p16-aarch64-unknown-linux-gnu.drv'...
building '/nix/store/4hak9b8afym27lw34ncr6nf8qydgnmkw-busybox-aarch64-unknown-linux-gnu-1.35.0.drv'...building '/nix/store/h9nxxxiaihl4w5dzrgsynmnzmz83jqcy-net-tools-aarch64-unknown-linux-gnu-2.10.drv'...building '/nix/store/sqm9ywi49acd0h85zcfbwisxfl5m10j7-bzip2-aarch64-unknown-linux-gnu-1.0.6.0.2.drv'...
building '/nix/store/099ry4cikff1nwx204n40ngjp8iab8ws-ccrypt-aarch64-unknown-linux-gnu-1.11.drv'...
building '/nix/store/j8pxdgazygpzqb0rgz2qkhvn8plysigm-cpio-aarch64-unknown-linux-gnu-2.13.drv'...
building '/nix/store/9la95bxq104hn71dqkfbcxd0g4gbn72s-ddrescue-aarch64-unknown-linux-gnu-1.26.drv'...
building '/nix/store/cgpryndwzhdbkhnifp70rb52fx5qraa8-gawk-aarch64-unknown-linux-gnu-5.1.1.drv'...
unpacking sources
unpacking source archive /nix/store/5sgii519481kdsdg9kk027jlr7z641wd-bash-5.1.tar.gz
source root is bash-5.1
setting SOURCE_DATE_EPOCH to timestamp 1607093479 of file bash-5.1/Makefile.in
patching sources
applying patch /nix/store/5ibv7vnqs9qq75qwp9p276l9r35ldccm-bash51-001
patching file Makefile.in
patching file builtins/Makefile.in
patching file patchlevel.h
applying patch /nix/store/z1wfvm57izp9mdx3svdm8ayvw9f24bsr-bash51-002
patching file builtins/wait.def
patching file patchlevel.h
applying patch /nix/store/db77yl7pra8dk4jkdg82gja84ara63nj-bash51-003
patching file subst.c
patching file patchlevel.h
applying patch /nix/store/h1xsw38qjfclxwji7pa2ysvgdrgwbmaj-bash51-004
patching file arrayfunc.c
patching file arrayfunc.h
patching file subst.c
patching file patchlevel.h
applying patch /nix/store/99jb0lrxv2w0iby2pyj69qg5d8gjbpgg-bash51-005
patching file subst.c
patching file arrayfunc.c
patching file patchlevel.h
applying patch /nix/store/c13hmsqmwb8ip2bjba4xxzmxjwyqn0qw-bash51-006
patching file subst.c
patching file patchlevel.h
applying patch /nix/store/clfxvc0dwwbnrs9n9ingq542yv1mavvd-bash51-007
patching file lib/readline/bind.c
patching file patchlevel.h
applying patch /nix/store/8ryxppqg6lay7vj105sd175svh9is18w-bash51-008
patching file execute_cmd.c
patching file patchlevel.h
applying patch /nix/store/46wm974l1ywf7h84bizls4hiv2mc8caj-bash51-009
patching file lib/malloc/malloc.c
patching file patchlevel.h
applying patch /nix/store/1zph6k1xylkaajdcx6g10m1himcm1bmh-bash51-010
patching file builtins/wait.def
patching file patchlevel.h
applying patch /nix/store/dfzijgqay55f61yldz74dlzcj3kc84n9-bash51-011
patching file parse.y
patching file y.tab.c
patching file patchlevel.h
applying patch /nix/store/rl9348bn6clw01gzy8bdmdzjxync1rsp-bash51-012
patching file command.h
patching file execute_cmd.c
patching file jobs.c
patching file nojobs.c
patching file sig.c
patching file subst.c
patching file trap.c
patching file patchlevel.h
applying patch /nix/store/z4amhpapl83iwjxkq9p9lylkh0ffyq1d-bash51-013
patching file subst.c
patching file patchlevel.h
applying patch /nix/store/wanyhkgjwxccvyqla6r236423cda6c6v-bash51-014
patching file subst.c
patching file patchlevel.h
applying patch /nix/store/k3hwb5acr6xjycj853fczqby0c9d6mmq-bash51-015
patching file lib/readline/display.c
patching file patchlevel.h
applying patch /nix/store/526apfg6pqnq86vflaiv4j2hikl8cjyx-bash51-016
patching file parse.y
patching file y.tab.c
patching file patchlevel.h
applying patch /nix/store/nm5946y3ffkynrz67vz47ik0ygvg6byn-pgrp-pipe-5.1.patch
patching file ./configure
Hunk #1 succeeded at 20407 with fuzz 2 (offset 4095 lines).
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./support/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./support/config.guess
configuring
unpacking sources
unpacking source archive /nix/store/y54zv60b3c52hkimv5gak0g74ansd6ya-busybox-1.35.0.tar.bz2
source root is busybox-1.35.0
setting SOURCE_DATE_EPOCH to timestamp 1640537755 of file busybox-1.35.0/Makefile
patching sources
applying patch /nix/store/7wpjbl21q85z0vrqdx4c7lxg6n4rgwh7-busybox-in-store.patch
patching file libbb/appletlib.c
Hunk #1 succeeded at 975 (offset 28 lines).
Hunk #2 succeeded at 1099 (offset 54 lines).
applying patch /nix/store/z7d0iap9j4r6kbdlrnsq4m7pbgy8nd6p-CVE-2022-28391.patch
patching file libbb/xconnect.c
applying patch /nix/store/4py33501xzlyp3v5gmcv09znpvhmimmd-CVE-2022-28391.patch
patching file networking/nslookup.c
applying patch /nix/store/wmw6a6pcmwaqwqvhfjzclk1jmr0am383-clang-cross.patch
patching file Makefile
patching file scripts/Makefile.IMA
patching script interpreter paths in .
./modutils/depmod_process.sh: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
./include/applets.h.sh: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
./make_single_applets.sh: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
./util-linux/mkfs_ext2_test.sh: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
./shell/hush_leaktool.sh: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
./shell/hush_test/run-all: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
unpacking sources
unpacking source archive /nix/store/lx8mjbgf29ccsiniz7cl4y8fxq707cy9-net-tools-2.10.tar.xz
source root is net-tools-2.10
setting SOURCE_DATE_EPOCH to timestamp 1609975361 of file net-tools-2.10/po/pt_BR.mo
patching sources
updateAutotoolsGnuConfigScriptsPhase
configuring
no configure script, doing nothing
building
build flags: SHELL=/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/bash CC=aarch64-unknown-linux-gnu-cc AR=aarch64-unknown-linux-gnu-ar BASEDIR=\$\(out\) mandir=/share/man HAVE_ARP_TOOLS=1 HAVE_PLIP_TOOLS=1 HAVE_SERIAL_TOOLS=1 HAVE_HOSTNAME_TOOLS=1 HAVE_HOSTNAME_SYMLINKS=1 HAVE_MII=1
make[1]: Entering directory '/build/net-tools-2.10/lib'
aarch64-unknown-linux-gnu-cc -O2 -g -Wall -fno-strict-aliasing  -I.. -I../include  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I. -I/build/net-tools-2.10/include -Ilib
 -c -o activate.o activate.c
aarch64-unknown-linux-gnu-cc -O2 -g -Wall -fno-strict-aliasing  -I.. -I../include  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I. -I/build/net-tools-2.10/include -Ilib
 -c -o af.o af.c
unpacking sources
unpacking source archive /nix/store/8lchadwcwrn4icgnsfmfalzmaxx653nm-bzip2-1.0.6.0.2.tar.gz
source root is bzip2-1.0.6.0.2
setting SOURCE_DATE_EPOCH to timestamp 1510165913 of file bzip2-1.0.6.0.2/configure
patching sources
applying patch /nix/store/r8acyr4xb2yw1k73qjzm9sxmpws27gjr-CVE-2016-3189.patch
patching file bzip2recover.c
applying patch /nix/store/wnf28g32lllbi3i80n97gyzfj2sf9zyx-cve-2019-12900.patch
patching file decompress.c
autoreconfPhase
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
unpacking sources
unpacking source archive /nix/store/56j48vrlqpgbnl7wgjb32nb6b93v1im7-ccrypt-1.11.tar.gz
source root is ccrypt-1.11
setting SOURCE_DATE_EPOCH to timestamp 1532724196 of file ccrypt-1.11/README
patching sources
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./config.sub
Updating Autotools / GNU config script to a newer upstream version: ./config.guess
configuring
fixing libtool script ./ltmain.sh
configure flags: --disable-static --disable-dependency-tracking --prefix=/nix/store/j313yn9vxh46iimbwcbwvgxq1vxcjrww-ccrypt-aarch64-unknown-linux-gnu-1.11 --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu
unpacking sources
unpacking source archive /nix/store/1f3g83maxsjcpa7lgsxv4i52fqszldp7-cpio-2.13.tar.bz2
unpacking sources
unpacking source archive /nix/store/zpzqdhfl6zxwmrsq56y43rbckcs8ipf2-ddrescue-1.26.tar.lz
source root is ddrescue-1.26
setting SOURCE_DATE_EPOCH to timestamp 1642774848 of file ddrescue-1.26/doc/ddrescuelog.1
patching sources
updateAutotoolsGnuConfigScriptsPhase
unpacking sources
configure flags: --disable-static --prefix=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu --bindir=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu/bin --sbindir=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu/sbin --includedir=/nix/store/52jcmfi3xvh1ajicf89k6wsylcsfkdpw-bash-5.1-p16-aarch64-unknown-linux-gnu-dev/include --oldincludedir=/nix/store/52jcmfi3xvh1ajicf89k6wsylcsfkdpw-bash-5.1-p16-aarch64-unknown-linux-gnu-dev/include --mandir=/nix/store/qk6248rqqdcbfylpww8kw4f6ayfi8q3g-bash-5.1-p16-aarch64-unknown-linux-gnu-man/share/man --infodir=/nix/store/z5dj9zrrkkaw93hgv8jbbhxg8h62v7f5-bash-5.1-p16-aarch64-unknown-linux-gnu-info/share/info --docdir=/nix/store/48b9ld1qqy4v3f624dxh9m8gcichkr8s-bash-5.1-p16-aarch64-unknown-linux-gnu-doc/share/doc/bash --libdir=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu/lib --libexecdir=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu/libexec --localedir=/nix/store/pv01ng0nhyaipj831pnnnhysmdfsn8dh-bash-5.1-p16-aarch64-unknown-linux-gnu/share/locale --disable-readline bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing bash_cv_getcwd_malloc=yes --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu
unpacking source archive /nix/store/n96s4cryw417jh2y7h01wdvm24pmkw2p-gawk-5.1.1.tar.xz
autoreconf: running: aclocal --force -I m4
configuring
./shell/hush_test/hush-signals/signal4.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
source root is cpio-2.13
setting SOURCE_DATE_EPOCH to timestamp 1573027160 of file cpio-2.13/ChangeLog
configure flags: --prefix=/nix/store/bh0xqkhbjas6j3ya7zrzcnf4f08d0zbk-ddrescue-aarch64-unknown-linux-gnu-1.26 CXX=aarch64-unknown-linux-gnu-c++ --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu
./shell/hush_test/hush-signals/signal2.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
patching sources
applying patch /nix/store/w8vah9dvrl4s6gvk4901dhwmrq2i6qpz-CVE-2021-38185-1.patch
configure: WARNING: unrecognized option: '--build=aarch64-unknown-linux-gnu'
patching file src/copyin.c
Hunk #2 succeeded at 780 (offset -1 lines).
Hunk #3 succeeded at 1196 with fuzz 2 (offset -14 lines).
patching file src/copyout.c
configure: WARNING: unrecognized option: '--host=aarch64-unknown-linux-gnu'
patching file src/copypass.c
patching file src/dstring.c
creating config.status
patching file src/dstring.h
patching file src/util.c
applying patch /nix/store/77v8hkqyhkvpxzw9qjcn79sy4ni0dzpf-CVE-2021-38185-2.patch
configure: WARNING: unrecognized options: --disable-static
./shell/hush_test/hush-signals/reap1.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
patching file src/dstring.c
applying patch /nix/store/s6qs7177l83ra8z7knssd6a1bq4p0i58-CVE-2021-38185-3.patch
creating Makefile
VPATH = .
prefix = /nix/store/bh0xqkhbjas6j3ya7zrzcnf4f08d0zbk-ddrescue-aarch64-unknown-linux-gnu-1.26
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
datarootdir = $(prefix)/share
infodir = $(datarootdir)/info
mandir = $(datarootdir)/man
CXX = aarch64-unknown-linux-gnu-c++
CPPFLAGS =
CXXFLAGS = -O2
LDFLAGS =
patching file src/dstring.c
applying patch /nix/store/dwmri6gq6g5jyvbz94i5cdxrg6p7zn26-fno-common-fix.patch
OK. Now you can run make.
patching file src/global.c
./shell/hush_test/hush-signals/signal3.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
building
updateAutotoolsGnuConfigScriptsPhase
build flags: SHELL=/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/bash
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.sub
aarch64-unknown-linux-gnu-c++  -O2 -c -o arg_parser.o arg_parser.cc
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.guess
configuring
./shell/hush_test/hush-misc/nommu3.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
configure flags: --disable-dependency-tracking --prefix=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13 --bindir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/bin --sbindir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/sbin --includedir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/include --oldincludedir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/include --mandir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/share/man --infodir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/share/info --docdir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/share/doc/cpio --libdir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/lib --libexecdir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/libexec --localedir=/nix/store/hf0ab279hv4xkbgwj1wnixp8ysbflk2h-cpio-aarch64-unknown-linux-gnu-2.13/share/locale --build=aarch64-unknown-linux-gnu --host=aarch64-unknown-linux-gnu
./shell/ash_test/ash-signals/signal4.tests: interpreter directive changed from "#!/bin/sh" to "/nix/store/a60niv1y5ryigs8f2j97aiabb8190zra-bash-5.1-p16/bin/sh"
arg_parser.cc:20:10: fatal error: cstring: No such file or directory
   20 | #include <cstring>
      |          ^~~~~~~~~
compilation terminated.
make: *** [Makefile:64: arg_parser.o] Error 1
error: builder for '/nix/store/9la95bxq104hn71dqkfbcxd0g4gbn72s-ddrescue-aarch64-unknown-linux-gnu-1.26.drv' failed with exit code 2
copying path '/nix/store/5zxlm42h1ypvxsm0jz3lxpq5ava18ya1-fftw-single-3.3.10' from 'https://cache.nixos.org'...
copying path '/nix/store/yc0nvb1wq5zr227dcfqh1kkczvxz45ni-gnu-config-2021-01-25' from 'https://cache.nixos.org'...
copying path '/nix/store/59g3mvnwsjm83h9h67vyrw0r1ab40xbr-gperf-3.1.tar.gz' from 'https://cache.nixos.org'...
error: 1 dependencies of derivation '/nix/store/4hyb3dx86g1l2vp0cwdf19vjfn0nawmf-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/6kjvnjgdmlwbddgkdwxwwgm1rxpri4qp-system-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/g4y7nhcn64pn4qh5j8hpnral72fpiyi8-system-path.drv' failed to build
copying path '/nix/store/dgx44s213hbzy535n7m9bsf8n9jvw7b6-graphite2-1.3.14' from 'https://cache.nixos.org'...
copying path '/nix/store/366q28w1fn667n3qnhdnqlci49fnvicc-graphite2-1.3.14.tgz' from 'https://cache.nixos.org'...
error: 1 dependencies of derivation '/nix/store/1njyq9zsp1s7in0mxw3mkyglykn000k5-nixos-system-nixos-22.05.866.1f8d88087a3.drv' failed to build
error: build of '/nix/store/1njyq9zsp1s7in0mxw3mkyglykn000k5-nixos-system-nixos-22.05.866.1f8d88087a3.drv', '/nix/store/8xi90wi7gv7ln1sx9bl797ip6apia3lj-nixos-vm.drv', '/nix/store/bfyacyjxkrk1s5n9y4ka0j33jxdlvp3k-nixos-vm.drv' failed

What is wrong here?