summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-08-28 21:43:16 +0200
committertv <tv@shackspace.de>2015-08-28 21:45:55 +0200
commit8827469a35852a0623d8353c22b481a15328254a (patch)
tree83caa3611edf07779b3e8c4858dc8cda8552af8b
parentc1aaaca7f7febe0c587342ae74e7045bb9a67c5a (diff)
krebs pkgs += execve
-rw-r--r--krebs/5pkgs/default.nix18
1 files changed, 17 insertions, 1 deletions
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 <unistd.h>
+ 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