From 28264febdb8345a3f3cd6bdf86dad919f480fca2 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 23 Apr 2023 11:38:22 +0100 Subject: [PATCH] add smaller-than-gnu "hello world" package --- overlay.nix | 1 - pkgs/default.nix | 2 ++ pkgs/hi/default.nix | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 pkgs/hi/default.nix diff --git a/overlay.nix b/overlay.nix index 72fffff..ce7b205 100644 --- a/overlay.nix +++ b/overlay.nix @@ -49,7 +49,6 @@ extraPkgs // { # openssl is reqired by ntp - rsyncSmall = prev.rsync.overrideAttrs(o: { configureFlags = o.configureFlags ++ [ "--disable-openssl" diff --git a/pkgs/default.nix b/pkgs/default.nix index 0389663..8a569c6 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -44,4 +44,6 @@ swconfig = callPackage ./swconfig {}; openwrt = callPackage ./openwrt {}; + + hi = callPackage ./hi {}; } diff --git a/pkgs/hi/default.nix b/pkgs/hi/default.nix new file mode 100644 index 0000000..3dd65e4 --- /dev/null +++ b/pkgs/hi/default.nix @@ -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 + 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" +''