diff --git a/1systems/tv/cd.nix b/1systems/tv/cd.nix index d3cae6f4a..463d643a6 100644 --- a/1systems/tv/cd.nix +++ b/1systems/tv/cd.nix @@ -29,10 +29,10 @@ in }; } { - imports = [ ../../3modules/tv/github-hosts-sync.nix ]; - tv.github-hosts-sync.enable = true; + imports = [ ../../3modules/krebs/github-hosts-sync.nix ]; + krebs.github-hosts-sync.enable = true; tv.iptables.input-internet-accept-new-tcp = - singleton config.tv.github-hosts-sync.port; + singleton config.krebs.github-hosts-sync.port; } { imports = [ ../../2configs/tv/identity.nix ]; @@ -57,19 +57,19 @@ in { imports = [ ../../3modules/tv/iptables.nix - ../../3modules/tv/nginx.nix + ../../3modules/krebs/nginx.nix ]; tv.iptables.input-internet-accept-new-tcp = singleton "http"; - tv.nginx.servers.cgit.server-names = singleton "cgit.cd.viljetic.de"; + krebs.nginx.servers.cgit.server-names = singleton "cgit.cd.viljetic.de"; } { # TODO make public_html also available to cd, cd.retiolum (AKA default) imports = [ ../../3modules/tv/iptables.nix - ../../3modules/tv/nginx.nix + ../../3modules/krebs/nginx.nix ]; tv.iptables.input-internet-accept-new-tcp = singleton "http"; - tv.nginx.servers.public_html = { + krebs.nginx.servers.public_html = { server-names = singleton "cd.viljetic.de"; locations = singleton (nameValuePair "~ ^/~(.+?)(/.*)?\$" '' alias /home/$1/public_html$2; @@ -77,7 +77,7 @@ in }; } { - tv.nginx.servers.viljetic = { + krebs.nginx.servers.viljetic = { server-names = singleton "viljetic.de"; # TODO directly set root (instead via location) locations = singleton (nameValuePair "/" '' diff --git a/1systems/tv/nomic.nix b/1systems/tv/nomic.nix index 6f984c44d..8e6812e43 100644 --- a/1systems/tv/nomic.nix +++ b/1systems/tv/nomic.nix @@ -26,8 +26,8 @@ with lib; }; } { - imports = [ ../../3modules/tv/nginx.nix ]; - tv.nginx = { + imports = [ ../../3modules/krebs/nginx.nix ]; + krebs.nginx = { enable = true; servers.default.locations = [ (nameValuePair "~ ^/~(.+?)(/.*)?\$" '' diff --git a/1systems/tv/wu.nix b/1systems/tv/wu.nix index 76bb43eca..1d7bbe55b 100644 --- a/1systems/tv/wu.nix +++ b/1systems/tv/wu.nix @@ -134,8 +134,8 @@ in }; } { - imports = [ ../../3modules/tv/nginx.nix ]; - tv.nginx = { + imports = [ ../../3modules/krebs/nginx.nix ]; + krebs.nginx = { enable = true; servers.default.locations = [ (nameValuePair "~ ^/~(.+?)(/.*)?\$" '' @@ -156,8 +156,8 @@ in }; } { - imports = [ ../../3modules/tv/urlwatch.nix ]; - tv.urlwatch = { + imports = [ ../../3modules/krebs/urlwatch.nix ]; + krebs.urlwatch = { enable = true; mailto = "tv@wu.retiolum"; # TODO onCalendar = "*-*-* 05:00:00"; diff --git a/2configs/tv/git-public.nix b/2configs/tv/git-public.nix index 7222f99eb..7f2b51308 100644 --- a/2configs/tv/git-public.nix +++ b/2configs/tv/git-public.nix @@ -3,8 +3,8 @@ with import ../../4lib/tv { inherit lib pkgs; }; let out = { - imports = [ ../../3modules/tv/git.nix ]; - tv.git = { + imports = [ ../../3modules/krebs/git.nix ]; + krebs.git = { enable = true; root-title = "public repositories at ${config.tv.identity.self.name}"; root-desc = "keep calm and engage"; diff --git a/3modules/tv/git.nix b/3modules/krebs/git.nix similarity index 98% rename from 3modules/tv/git.nix rename to 3modules/krebs/git.nix index 8c73d0354..3c3e93426 100644 --- a/3modules/tv/git.nix +++ b/3modules/krebs/git.nix @@ -9,13 +9,14 @@ with builtins; with lib; let - cfg = config.tv.git; + cfg = config.krebs.git; out = { + # TODO don't import krebs.nginx here imports = [ - ../../3modules/tv/nginx.nix + ../../3modules/krebs/nginx.nix ]; - options.tv.git = api; + options.krebs.git = api; config = mkIf cfg.enable (mkMerge [ (mkIf cfg.cgit cgit-imp) git-imp @@ -23,7 +24,7 @@ let }; api = { - enable = mkEnableOption "tv.git"; + enable = mkEnableOption "krebs.git"; cgit = mkOption { type = types.bool; @@ -210,7 +211,7 @@ let chown ${toString fcgitwrap-user.uid}:${toString fcgitwrap-group.gid} /tmp/cgit ''; - tv.nginx = { + krebs.nginx = { enable = true; servers.cgit = { server-names = [ diff --git a/3modules/tv/github-hosts-sync.nix b/3modules/krebs/github-hosts-sync.nix similarity index 91% rename from 3modules/tv/github-hosts-sync.nix rename to 3modules/krebs/github-hosts-sync.nix index f50bf2b1b..c3b56ef94 100644 --- a/3modules/tv/github-hosts-sync.nix +++ b/3modules/krebs/github-hosts-sync.nix @@ -3,15 +3,15 @@ with builtins; with lib; let - cfg = config.tv.github-hosts-sync; + cfg = config.krebs.github-hosts-sync; out = { - options.tv.github-hosts-sync = api; + options.krebs.github-hosts-sync = api; config = mkIf cfg.enable imp; }; api = { - enable = mkEnableOption "tv.github-hosts-sync"; + enable = mkEnableOption "krebs.github-hosts-sync"; port = mkOption { type = types.int; # TODO port type default = 1028; @@ -78,6 +78,6 @@ let uid = 3220554646; # genid github-hosts-sync }; - Zpkgs = import ../../Zpkgs/tv { inherit pkgs; }; + Zpkgs = import ../../Zpkgs/krebs { inherit pkgs; }; in out diff --git a/3modules/tv/nginx.nix b/3modules/krebs/nginx.nix similarity index 91% rename from 3modules/tv/nginx.nix rename to 3modules/krebs/nginx.nix index a58c49520..702e8a7f6 100644 --- a/3modules/tv/nginx.nix +++ b/3modules/krebs/nginx.nix @@ -3,21 +3,22 @@ with builtins; with lib; let - cfg = config.tv.nginx; + cfg = config.krebs.nginx; out = { - options.tv.nginx = api; + options.krebs.nginx = api; config = mkIf cfg.enable imp; }; api = { - enable = mkEnableOption "tv.nginx"; + enable = mkEnableOption "krebs.nginx"; servers = mkOption { type = with types; attrsOf optionSet; options = singleton { server-names = mkOption { type = with types; listOf str; + # TODO use identity default = [ "${config.networking.hostName}" "${config.networking.hostName}.retiolum" diff --git a/3modules/tv/urlwatch.nix b/3modules/krebs/urlwatch.nix similarity index 96% rename from 3modules/tv/urlwatch.nix rename to 3modules/krebs/urlwatch.nix index a659fc74f..58de72fc6 100644 --- a/3modules/tv/urlwatch.nix +++ b/3modules/krebs/urlwatch.nix @@ -8,16 +8,16 @@ with builtins; with lib; let - cfg = config.tv.urlwatch; + cfg = config.krebs.urlwatch; # TODO assert sendmail's existence out = { - options.tv.urlwatch = api; + options.krebs.urlwatch = api; config = mkIf cfg.enable imp; }; api = { - enable = mkEnableOption "tv.urlwatch"; + enable = mkEnableOption "krebs.urlwatch"; dataDir = mkOption { type = types.str; diff --git a/4lib/krebs/default.nix b/4lib/krebs/default.nix new file mode 100644 index 000000000..38c2a97d6 --- /dev/null +++ b/4lib/krebs/default.nix @@ -0,0 +1,7 @@ +{ lib, ... }: + +builtins // lib // { + + types = import ./types.nix { inherit lib; }; + +} diff --git a/4lib/krebs/types.nix b/4lib/krebs/types.nix new file mode 100644 index 000000000..38ed8a916 --- /dev/null +++ b/4lib/krebs/types.nix @@ -0,0 +1,81 @@ +{ lib, ... }: + +with lib; +with types; + +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; + }; + }; + }; + + net = submodule ({ config, ... }: { + options = { + via = mkOption { + type = nullOr net; + default = null; + }; + 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; + }; + tinc = mkOption { + type = let net-config = config; in submodule ({ config, ... }: { + options = { + config = mkOption { + type = str; + apply = _: '' + ${optionalString (net-config.via != null) + (concatMapStringsSep "\n" (a: "Address = ${a}") net-config.via.addrs)} + ${concatMapStringsSep "\n" (a: "Subnet = ${a}") net-config.addrs} + ${config.pubkey} + ''; + }; + pubkey = mkOption { + type = str; + }; + }; + }); + }; + }; + }); + + positive = mkOptionType { + name = "positive integer"; + check = x: isInt x && x > 0; + merge = mergeOneOption; + }; + + # TODO + addr = str; + addr4 = str; + addr6 = str; + hostname = str; + label = str; +} diff --git a/4lib/tv/default.nix b/4lib/tv/default.nix index 092a9626c..267a858d2 100644 --- a/4lib/tv/default.nix +++ b/4lib/tv/default.nix @@ -1,9 +1,12 @@ { lib, pkgs, ... }: -with builtins; -with lib; +let + krebs = import ../../4lib/krebs { inherit lib; }; +in -builtins // lib // rec { +with krebs; + +krebs // rec { git = import ./git.nix { lib = lib // { @@ -53,82 +56,4 @@ builtins // lib // rec { if isSafeChar c then c 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; - }; - }; - }; - - net = submodule ({ config, ... }: { - options = { - via = mkOption { - type = nullOr net; - default = null; - }; - 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; - }; - tinc = mkOption { - type = let net-config = config; in submodule ({ config, ... }: { - options = { - config = mkOption { - type = str; - apply = _: '' - ${optionalString (net-config.via != null) - (concatMapStringsSep "\n" (a: "Address = ${a}") net-config.via.addrs)} - ${concatMapStringsSep "\n" (a: "Subnet = ${a}") net-config.addrs} - ${config.pubkey} - ''; - }; - pubkey = mkOption { - type = str; - }; - }; - }); - }; - }; - }); - - positive = mkOptionType { - name = "positive integer"; - check = x: isInt x && x > 0; - merge = mergeOneOption; - }; - - # TODO - addr = str; - addr4 = str; - addr6 = str; - hostname = str; - label = str; - }); - } diff --git a/Zpkgs/krebs/default.nix b/Zpkgs/krebs/default.nix new file mode 100644 index 000000000..be8f72011 --- /dev/null +++ b/Zpkgs/krebs/default.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: + +let + inherit (pkgs) callPackage; +in + +pkgs // +{ + github-hosts-sync = callPackage ./github-hosts-sync.nix {}; + github-known_hosts = callPackage ./github-known_hosts.nix {}; +} diff --git a/Zpkgs/tv/github-hosts-sync.nix b/Zpkgs/krebs/github-hosts-sync.nix similarity index 100% rename from Zpkgs/tv/github-hosts-sync.nix rename to Zpkgs/krebs/github-hosts-sync.nix diff --git a/Zpkgs/tv/github-known_hosts.nix b/Zpkgs/krebs/github-known_hosts.nix similarity index 100% rename from Zpkgs/tv/github-known_hosts.nix rename to Zpkgs/krebs/github-known_hosts.nix diff --git a/Zpkgs/tv/default.nix b/Zpkgs/tv/default.nix index fa9fff84c..e3e12bd18 100644 --- a/Zpkgs/tv/default.nix +++ b/Zpkgs/tv/default.nix @@ -9,8 +9,6 @@ pkgs // charybdis = callPackage ./charybdis {}; dic = callPackage ./dic.nix {}; genid = callPackage ./genid.nix {}; - github-hosts-sync = callPackage ./github-hosts-sync.nix {}; - github-known_hosts = callPackage ./github-known_hosts.nix {}; lentil = callPackage ./lentil {}; much = callPackage ./much.nix {}; viljetic-pages = callPackage ./viljetic-pages {};