Buildroot Nix Shell

I’ve been trying unsucessfully for the last few days to get buildroot to build in a Nix Shell. The first problem I hit is that buildroot hardcodes that file must be in /usr/bin which pushed me to use a buildFHSUserEnvBubblewrap. In order to get make menuconfig to work I had to add /usr/include to C_INCLUDE_PATH and now that seems to work. I’ve been trying different combinations of wrapped/unwrapped compilers and binutils and it seems like using the wrapped version gets me furthest but neither work. The current build error is something to do with timezone_t but I’ve been in states where the issue is O_BINARY is undefined.

Has anyone gotten buildroot to work successfully in nix? Am I headed in the right direction? Does anyone have suggestions for other approaches that I’m not taking?

If anyone is interested, the nix expression I’ve been using is here, it’s probably got some unnecessary stuff in since I’ve been actively trying a bunch of different things. The current build error I’m seeing is below:

make[1]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29'
/usr/bin/make  all-recursive
make[2]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29'
Making all in doc
make[3]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/doc'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/doc'
Making all in gnu
make[3]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
/usr/bin/make  all-recursive
make[4]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
make[5]: Entering directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
  CC       fprintftime.o
  CC       modechange.o
  CC       save-cwd.o
  CC       uniwidth/width.o
  CC       xsize.o
  CC       strftime.o
  CC       xalloc-die.o
  CC       xstrtol.o
  CC       xstrndup.o
  CC       xgetcwd.o
  CC       xstrtoul.o
  CC       xvasprintf.o
  CC       xstrtol-error.o
  CC       xasprintf.o
  CC       asnprintf.o
  CC       chdir-long.o
  CC       xstrtoumax.o
In file included from strftime.c:31:
strftime.h:29:19: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
   29 |                   timezone_t __tz, int __ns);
      |                   ^~~~~~~~~~
      |                   timer_t
In file included from strftime.c:29,
                 from fprintftime.c:2:
fprintftime.h:29:21: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
   29 |                     timezone_t zone, int nanoseconds);
      |                     ^~~~~~~~~~
      |                     timer_t
modechange.c: In function ‘mode_compile’:
modechange.c:161:63: error: ‘S_IRWXUGO’ undeclared (first use in this function); did you mean ‘S_IRWXO’?
  161 |                    ? (mode & (S_ISUID | S_ISGID)) | S_ISVTX | S_IRWXUGO
      |                                                               ^~~~~~~~~
      |                                                               S_IRWXO
modechange.c:161:63: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [Makefile:1834: modechange.o] Error 1
make[5]: *** Waiting for unfinished jobs....
In file included from fprintftime.c:2:
strftime.c:388:28: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
  388 | # define extra_args_spec , timezone_t tz, int ns
      |                            ^~~~~~~~~~
strftime.c:411:37: note: in expansion of macro ‘extra_args_spec’
  411 |                 const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO)
      |                                     ^~~~~~~~~~~~~~~
strftime.c:388:28: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
  388 | # define extra_args_spec , timezone_t tz, int ns
      |                            ^~~~~~~~~~
strftime.c:411:37: note: in expansion of macro ‘extra_args_spec’
  411 |                 const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO)
      |                                     ^~~~~~~~~~~~~~~
strftime.c:388:28: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
  388 | # define extra_args_spec , timezone_t tz, int ns
      |                            ^~~~~~~~~~
strftime.c:1457:34: note: in expansion of macro ‘extra_args_spec’
 1457 |              const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO)
      |                                  ^~~~~~~~~~~~~~~
strftime.c:388:28: error: unknown type name ‘timezone_t’; did you mean ‘timer_t’?
  388 | # define extra_args_spec , timezone_t tz, int ns
      |                            ^~~~~~~~~~
strftime.c:1457:34: note: in expansion of macro ‘extra_args_spec’
 1457 |              const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO)
      |                                  ^~~~~~~~~~~~~~~
make[5]: *** [Makefile:1834: fprintftime.o] Error 1
make[5]: *** [Makefile:1834: strftime.o] Error 1
save-cwd.c: In function ‘save_cwd’:
save-cwd.c:67:26: error: ‘O_SEARCH’ undeclared (first use in this function)
   67 |   cwd->desc = open (".", O_SEARCH);
      |                          ^~~~~~~~
save-cwd.c:67:26: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [Makefile:1834: save-cwd.o] Error 1
chdir-long.c: In function ‘cdb_advance_fd’:
chdir-long.c:76:24: error: ‘O_SEARCH’ undeclared (first use in this function)
   76 |                        O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
      |                        ^~~~~~~~
chdir-long.c:76:24: note: each undeclared identifier is reported only once for each function it appears in
make[5]: *** [Makefile:1834: chdir-long.o] Error 1
make[5]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
make[4]: *** [Makefile:1854: all-recursive] Error 1
make[4]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
make[3]: *** [Makefile:1524: all] Error 2
make[3]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/gnu'
make[2]: *** [Makefile:1338: all-recursive] Error 1
make[2]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29'
make[1]: *** [Makefile:1277: all] Error 2
make[1]: Leaving directory '/home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29'
make: *** [package/pkg-generic.mk:244: /home/larry/projects/elixirNerves/buildroot/output/build/host-tar-1.29/.stamp_built] Error 2

Well it’s over a year later and I’ve finally answered my own question with the flake here, which is based on the menuconfig example from the wiki that I probably just did not understand well enough at the time.

2 Likes