summaryrefslogtreecommitdiffstats
path: root/4lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-07-23 00:37:21 +0200
committertv <tv@krebsco.de>2015-07-23 00:37:21 +0200
commit89ce2f5be474b3e72b53e450054f94fd4d13e381 (patch)
tree2b6a539ad2a9f3c4d4b2cf24034cea7e239acb51 /4lib
parent5c54cd99df9b6f426e70cd78be3411526b091864 (diff)
* tv identity: define type harder
Diffstat (limited to '4lib')
-rw-r--r--4lib/tv/default.nix64
1 files changed, 60 insertions, 4 deletions
diff --git a/4lib/tv/default.nix b/4lib/tv/default.nix
index 164a6a1..6985baa 100644
--- a/4lib/tv/default.nix
+++ b/4lib/tv/default.nix
@@ -1,12 +1,10 @@
{ lib, pkgs, ... }:
with builtins;
+with lib;
-let
- inherit (lib) mapAttrs stringAsChars;
-in
+builtins // lib // rec {
-rec {
git = import ./git.nix {
lib = lib // {
inherit addNames;
@@ -59,4 +57,62 @@ rec {
else if c == "\n" then "'\n'"
else "\\${c}");
+ types = lib.types // (with lib.types; rec {
+
+ host = submodule {
+ options = {
+ name = mkOption {
+ type = label;
+ };
+ dc = mkOption {
+ type = label;
+ };
+ cores = mkOption {
+ type = positive;
+ };
+ nets = mkOption {
+ type = attrsOf net;
+ apply = x: assert hasAttr "retiolum" x; x;
+ };
+ search = mkOption {
+ type = hostname;
+ };
+ };
+ };
+
+ net = submodule ({ config, ... }: {
+ options = {
+ addrs = mkOption {
+ type = listOf addr;
+ apply = _: config.addrs4 ++ config.addrs6;
+ };
+ addrs4 = mkOption {
+ type = listOf addr4;
+ default = [];
+ };
+ addrs6 = mkOption {
+ type = listOf addr6;
+ default = [];
+ };
+ aliases = mkOption {
+ # TODO nonEmptyListOf hostname
+ type = listOf hostname;
+ };
+ };
+ });
+
+ positive = mkOptionType {
+ name = "positive integer";
+ check = x: isInt x && x > 0;
+ merge = mergeOneOption;
+ };
+
+ # TODO
+ addr = str;
+ addr4 = str;
+ addr6 = str;
+ hostname = str;
+ label = str;
+ });
+
}