krebs += pkgs.writeC lib.toC

This commit is contained in:
tv 2015-08-28 21:31:59 +02:00
parent f6997378c9
commit c1aaaca7f7
5 changed files with 23 additions and 6 deletions

View File

@ -16,4 +16,10 @@ builtins // lib // rec {
listset = import ./listset.nix { inherit lib; };
shell = import ./shell.nix { inherit lib; };
tree = import ./tree.nix { inherit lib; };
toC = x: {
list = "{ ${concatStringsSep ", " (map toC x)} }";
null = "NULL";
string = toJSON x; # close enough
}.${typeOf x};
}

View File

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
let
inherit (pkgs) callPackage;
@ -14,4 +14,15 @@ pkgs //
hashPassword = callPackage ./hashPassword.nix {};
nq = callPackage ./nq.nix {};
posix-array = callPackage ./posix-array.nix {};
writeC = name: {}: 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
'';
}

View File

@ -3,7 +3,7 @@
with lib;
let
tvpkgs = import ../5pkgs { inherit pkgs; };
tvpkgs = import ../5pkgs { inherit lib pkgs; };
in
{

View File

@ -1,6 +1,6 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
with import ../5pkgs { inherit pkgs; };
with import ../5pkgs { inherit lib pkgs; };
{
environment.systemPackages = [

View File

@ -1,8 +1,8 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
let
inherit (pkgs) callPackage;
kpkgs = import ../../krebs/5pkgs { inherit pkgs; };
kpkgs = import ../../krebs/5pkgs { inherit lib pkgs; };
in
kpkgs // {