From 74cf3e0711db0bea8d02a98da37c5afd780c0aa4 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 26 Apr 2024 16:43:09 +0100 Subject: [PATCH] add anoia.net.constants for SOCK_{STREAM,DGRAM} etc we use an ugly bit of C preprocessor to get the values from header files, because certain constants are different on MIPS than on other architectures --- pkgs/anoia/Makefile | 6 +++++- pkgs/anoia/default.nix | 5 +++-- pkgs/anoia/net/constants.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 pkgs/anoia/net/constants.c diff --git a/pkgs/anoia/Makefile b/pkgs/anoia/Makefile index 9fdf7f8..f68e596 100644 --- a/pkgs/anoia/Makefile +++ b/pkgs/anoia/Makefile @@ -1,10 +1,14 @@ -default: fs.lua init.lua nl.lua svc.lua +default: fs.lua init.lua nl.lua svc.lua net/constants.lua test: ln -s . anoia fennel test.fnl fennel test-svc.fnl +net/constants.lua: net/constants.c + $(CC) -imacros sys/socket.h -imacros linux/netlink.h -E -P - < net/constants.c | sed 's/ *$$//g' | cat -s > net/constants.lua + + %.lua: %.fnl fennel --compile $< > $@ diff --git a/pkgs/anoia/default.nix b/pkgs/anoia/default.nix index 7876303..b981f48 100644 --- a/pkgs/anoia/default.nix +++ b/pkgs/anoia/default.nix @@ -4,13 +4,14 @@ , linotify , lua , lualinux +, cpio }: let pname = "anoia"; in stdenv.mkDerivation { inherit pname; version = "0.1"; src = ./.; - nativeBuildInputs = [ fennel ]; + nativeBuildInputs = [ fennel cpio ]; buildInputs = with lua.pkgs; [ linotify lualinux ]; outputs = [ "out" "dev" ]; @@ -18,7 +19,7 @@ in stdenv.mkDerivation { installPhase = '' mkdir -p "$out/share/lua/${lua.luaversion}/${pname}" - cp *.lua "$out/share/lua/${lua.luaversion}/${pname}" + find . -name \*.lua | cpio -p -d "$out/share/lua/${lua.luaversion}/${pname}" mkdir -p "$dev/share/lua/${lua.luaversion}/${pname}" cp assert.fnl "$dev/share/lua/${lua.luaversion}/${pname}" diff --git a/pkgs/anoia/net/constants.c b/pkgs/anoia/net/constants.c new file mode 100644 index 0000000..3c01e70 --- /dev/null +++ b/pkgs/anoia/net/constants.c @@ -0,0 +1,11 @@ + +#define MACRO(c) [#c] = c, + +return { + MACRO(SOCK_STREAM) + MACRO(SOCK_DGRAM) + MACRO(SOCK_RAW) + MACRO(AF_LOCAL) + MACRO(AF_NETLINK) + MACRO(NETLINK_KOBJECT_UEVENT) +}