Let’s say I have a build script such as this:
${toolchain.gcc}/bin/avr-gcc -mmcu=${MCU} ${CFLAGS} -c ${src}/main.c
${toolchain.gcc}/bin/avr-gcc -mmcu=${MCU} ${CFLAGS} -c ${uart}/include/uart.c
${toolchain.gcc}/bin/avr-gcc ${CFLAGS} -o main.elf uart.o main.o
${toolchain.binutils}/bin/avr-objcopy -O ihex -R .eeprom main.elf main.hex
And my buildDependenices
looks like this:
avr = with pkgs.pkgsCross.avr.buildPackages; [
binutils
gcc
avrdude
];
buildDependencies = [
uart
] ++ avr;
My build script runs just fine until that last avr-objcopy
command. Now, avr-objcopy
is part of binutils
, but pkgs.pkgsCross.avr.buildPackages.binutils
produces a binutils-wrapper
, not binputils
proper. It does depend on the real binutils
, which does contain the avr-objcopy
executable.
I can see that the wrapper derivation has a nix-support
directory that looks like this:
[avr-projects] savanni@garnet:/n/store $ exa -l /nix/store/li13acnmw5yd428572lzlznd4jslg4ms-avr-binutils-wrapper-2.31.1/nix-support/
.r--r--r-- 1.1k root 31 Dec 1969 add-flags.sh
.r--r--r-- 1.7k root 31 Dec 1969 add-hardening.sh
.r--r--r-- 1.1k root 31 Dec 1969 libc-cflags
.r--r--r-- 69 root 31 Dec 1969 libc-ldflags
.r--r--r-- 0 root 31 Dec 1969 libc-ldflags-before
.r--r--r-- 64 root 31 Dec 1969 orig-bintools
.r--r--r-- 63 root 31 Dec 1969 orig-libc
.r--r--r-- 63 root 31 Dec 1969 orig-libc-dev
.r--r--r-- 127 root 31 Dec 1969 propagated-user-env-packages
.r--r--r-- 4.9k root 31 Dec 1969 setup-hook
.r--r--r-- 2.9k root 31 Dec 1969 utils.bash
And propogated-user-env-packages
and orig-binutils
both have paths to the original binutils
package. I just don’t know what the right way of using the nix-support directory is, and kinda feel like there is already infrastructure in nix-build
that will address those things, and I’m just missing it.
So, the question is, how can I modify my build script, or my derivation, to bring the executables from the original binutils
into my path, in addition to the wrapper binutils
, and maybe even the gcc
derivation?