I’m following NixOS - Nix Pills to build a derivation for a simple C program.
Derivation definition:
simple = derivation { name = “simple”; builder = “${bash}/bin/bash”; args = [./simple_builder.sh]; gcc = gcc; coreutils = coreutils; src = ./simple.c; system = builtins.currentSystem; }
simple_builder.sh:
export PATH="$coreutils/bin:$gcc/bin"
mkdir $out
gcc --version
gcc -o $output/simple $src
When building the derivation, I’m getting this error. Can someone help? Does “gcc” not work on Mac? I tried to print out the version of gcc in the builder script but I didn’t see it in the output. Where can I see it? Thanks!
nix-store -r /nix/store/mcj1dsyfhrcspbh5nq11za20lc87z5if-simple.drv
these derivations will be built:
/nix/store/mcj1dsyfhrcspbh5nq11za20lc87z5if-simple.drv
building '/nix/store/mcj1dsyfhrcspbh5nq11za20lc87z5if-simple.drv'...
/nix/store/h2ig4svfh8xlc2z0p3hjrzll0fq7yfb5-simple.c: In function 'main':
/nix/store/h2ig4svfh8xlc2z0p3hjrzll0fq7yfb5-simple.c:2:5: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
2 | puts("Simple!");
| ^~~~
ld: can't open output file for writing '/simple.ld_o9FBa5', errno=30 for architecture x86_64
collect2: error: ld returned 1 exit status
builder for '/nix/store/mcj1dsyfhrcspbh5nq11za20lc87z5if-simple.drv' failed with exit code 1
error: build of '/nix/store/mcj1dsyfhrcspbh5nq11za20lc87z5if-simple.drv' failed