liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

default.nix (529B)


      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 code = ''
      7   #include <stdio.h>
      8   int main()
      9   {
     10     printf("hello world\n");
     11     return 0;
     12   }
     13 '';
     14 in runCommandCC "hello" {
     15   name = "hi";
     16   inherit code;
     17   executable = true;
     18   # hardeningDisable = ["all"];
     19   passAsFile = ["code"];
     20   preferLocalBuild = true;
     21   allowSubstitutes = false;
     22 } ''
     23   n=$out/bin/$name
     24   mkdir -p "$(dirname "$n")"
     25   mv "$codePath" code.c
     26   $CC -x c code.c -o "$n"
     27 ''