add smaller-than-gnu "hello world" package

module-based-network
Daniel Barlow 2023-04-23 11:38:22 +01:00
parent 2c4f8b823e
commit 28264febdb
3 changed files with 29 additions and 1 deletions

View File

@ -49,7 +49,6 @@ extraPkgs // {
# openssl is reqired by ntp
rsyncSmall = prev.rsync.overrideAttrs(o: {
configureFlags = o.configureFlags ++ [
"--disable-openssl"

View File

@ -44,4 +44,6 @@
swconfig = callPackage ./swconfig {};
openwrt = callPackage ./openwrt {};
hi = callPackage ./hi {};
}

27
pkgs/hi/default.nix Normal file
View File

@ -0,0 +1,27 @@
# A "hello world" program that's smaller than the GNU
# one. Used for testing the toolchain/linker behaviour.
{
runCommandCC
}:
let code = ''
#include <stdio.h>
int main()
{
printf("hello world\n");
return 0;
}
'';
in runCommandCC "hello" {
name = "hi";
inherit code;
executable = true;
# hardeningDisable = ["all"];
passAsFile = ["code"];
preferLocalBuild = true;
allowSubstitutes = false;
} ''
n=$out/bin/$name
mkdir -p "$(dirname "$n")"
mv "$codePath" code.c
$CC -x c code.c -o "$n"
''