krebs pkgs += execve
This commit is contained in:
parent
c1aaaca7f7
commit
8827469a35
@ -1,11 +1,13 @@
|
|||||||
{ lib, pkgs, ... }:
|
{ lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with import ../4lib { inherit lib; };
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (pkgs) callPackage;
|
inherit (pkgs) callPackage;
|
||||||
in
|
in
|
||||||
|
|
||||||
pkgs //
|
pkgs //
|
||||||
{
|
rec {
|
||||||
cac = callPackage ./cac.nix {};
|
cac = callPackage ./cac.nix {};
|
||||||
dic = callPackage ./dic.nix {};
|
dic = callPackage ./dic.nix {};
|
||||||
genid = callPackage ./genid.nix {};
|
genid = callPackage ./genid.nix {};
|
||||||
@ -15,6 +17,20 @@ pkgs //
|
|||||||
nq = callPackage ./nq.nix {};
|
nq = callPackage ./nq.nix {};
|
||||||
posix-array = callPackage ./posix-array.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 {} ''
|
writeC = name: {}: src: pkgs.runCommand name {} ''
|
||||||
PATH=${lib.makeSearchPath "bin" (with pkgs; [
|
PATH=${lib.makeSearchPath "bin" (with pkgs; [
|
||||||
binutils
|
binutils
|
||||||
|
Loading…
Reference in New Issue
Block a user