default.nix (578B)
1 # A "hello world" program that's smaller than the GNU 2 # one. Used for testing the toolchain/linker behaviour. 3 { 4 runCommandCC, 5 }: 6 let 7 code = '' 8 #include <stdio.h> 9 int main() 10 { 11 printf("hello world\n"); 12 return 0; 13 } 14 ''; 15 in 16 runCommandCC "hello" 17 { 18 name = "hi"; 19 inherit code; 20 executable = true; 21 # hardeningDisable = ["all"]; 22 passAsFile = [ "code" ]; 23 preferLocalBuild = true; 24 allowSubstitutes = false; 25 } 26 '' 27 n=$out/bin/$name 28 mkdir -p "$(dirname "$n")" 29 mv "$codePath" code.c 30 $CC -x c code.c -o "$n" 31 ''