diff options
author | tv <tv@shackspace.de> | 2015-08-28 22:13:17 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-08-28 22:13:17 +0200 |
commit | 642c761bd015f5766a75cf5688b50d42efdb96c3 (patch) | |
tree | e3dd1ff14e96c0febc95a9cb5efb20e7d61ccf60 /krebs | |
parent | f63b27240ec7b7de1834ddc36a325556498c4e6c (diff) |
krebs pkgs += execveBin
Diffstat (limited to 'krebs')
-rw-r--r-- | krebs/5pkgs/default.nix | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix index 3658c43e0..54604382f 100644 --- a/krebs/5pkgs/default.nix +++ b/krebs/5pkgs/default.nix @@ -18,8 +18,8 @@ rec { posix-array = callPackage ./posix-array.nix {}; youtube-tools = callPackage ./youtube-tools.nix {}; - execve = name: { filename, argv, envp }: - writeC name {} '' + execve = name: { filename, argv, envp ? {}, destination ? "" }: + writeC name { inherit destination; } '' #include <unistd.h> int main () { const char *filename = ${toC filename}; @@ -32,14 +32,18 @@ rec { } ''; - writeC = name: {}: src: pkgs.runCommand name {} '' + execveBin = name: cfg: execve name (cfg // { destination = "/bin/${name}"; }); + + writeC = name: { destination ? "" }: src: pkgs.runCommand name {} '' PATH=${lib.makeSearchPath "bin" (with pkgs; [ binutils coreutils gcc ])} - in=${pkgs.writeText "${name}.c" src} - gcc -O -Wall -o $out $in - strip --strip-unneeded $out + src=${pkgs.writeText "${name}.c" src} + exe=$out${destination} + mkdir -p "$(dirname "$exe")" + gcc -O -Wall -o "$exe" $src + strip --strip-unneeded "$exe" ''; } |