summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/5pkgs')
-rw-r--r--krebs/5pkgs/default.nix16
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"
'';
}