From 8827469a35852a0623d8353c22b481a15328254a Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 28 Aug 2015 21:43:16 +0200 Subject: krebs pkgs += execve --- krebs/5pkgs/default.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'krebs/5pkgs') diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix index c8fb1d2d7..406bd15eb 100644 --- a/krebs/5pkgs/default.nix +++ b/krebs/5pkgs/default.nix @@ -1,11 +1,13 @@ { lib, pkgs, ... }: +with import ../4lib { inherit lib; }; + let inherit (pkgs) callPackage; in pkgs // -{ +rec { cac = callPackage ./cac.nix {}; dic = callPackage ./dic.nix {}; genid = callPackage ./genid.nix {}; @@ -15,6 +17,20 @@ pkgs // nq = callPackage ./nq.nix {}; posix-array = callPackage ./posix-array.nix {}; + execve = name: { filename, argv, envp }: + writeC name {} '' + #include + int main () { + const char *filename = ${toC filename}; + char *const argv[] = ${toC (argv ++ [null])}; + char *const envp[] = ${toC ( + mapAttrsToList (k: v: "${k}=${v}") envp ++ [null] + )}; + execve(filename, argv, envp); + return -1; + } + ''; + writeC = name: {}: src: pkgs.runCommand name {} '' PATH=${lib.makeSearchPath "bin" (with pkgs; [ binutils -- cgit v1.2.3