summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-08-28 21:31:59 +0200
committertv <tv@shackspace.de>2015-08-28 21:31:59 +0200
commitc1aaaca7f7febe0c587342ae74e7045bb9a67c5a (patch)
treecadfdb8d3968e7e3dea817bfba255d78a3c9de9c
parentf6997378c91be84432703183397f8675143030e9 (diff)
krebs += pkgs.writeC lib.toC
-rw-r--r--krebs/4lib/default.nix6
-rw-r--r--krebs/5pkgs/default.nix13
-rw-r--r--tv/1systems/wu.nix2
-rw-r--r--tv/2configs/mail-client.nix4
-rw-r--r--tv/5pkgs/default.nix4
5 files changed, 23 insertions, 6 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix
index 8b587dfb..ca7219c7 100644
--- a/krebs/4lib/default.nix
+++ b/krebs/4lib/default.nix
@@ -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};
}
diff --git a/krebs/5pkgs/default.nix b/krebs/5pkgs/default.nix
index 2149b6f1..c8fb1d2d 100644
--- a/krebs/5pkgs/default.nix
+++ b/krebs/5pkgs/default.nix
@@ -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
+ '';
}
diff --git a/tv/1systems/wu.nix b/tv/1systems/wu.nix
index e48da90a..6131897a 100644
--- a/tv/1systems/wu.nix
+++ b/tv/1systems/wu.nix
@@ -3,7 +3,7 @@
with lib;
let
- tvpkgs = import ../5pkgs { inherit pkgs; };
+ tvpkgs = import ../5pkgs { inherit lib pkgs; };
in
{
diff --git a/tv/2configs/mail-client.nix b/tv/2configs/mail-client.nix
index a632cf7c..1daacdb4 100644
--- a/tv/2configs/mail-client.nix
+++ b/tv/2configs/mail-client.nix
@@ -1,6 +1,6 @@
-{ pkgs, ... }:
+{ lib, pkgs, ... }:
-with import ../5pkgs { inherit pkgs; };
+with import ../5pkgs { inherit lib pkgs; };
{
environment.systemPackages = [
diff --git a/tv/5pkgs/default.nix b/tv/5pkgs/default.nix
index 7b5d10a6..a0a22df9 100644
--- a/tv/5pkgs/default.nix
+++ b/tv/5pkgs/default.nix
@@ -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 // {