From 734ec4ae00c93d48297b7c3ee226ef890187bfa3 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 24 Jul 2015 11:50:23 +0200 Subject: [PATCH 1/5] 3 {tv -> krebs}.nginx --- 1systems/tv/cd.nix | 10 +++++----- 1systems/tv/nomic.nix | 4 ++-- 1systems/tv/wu.nix | 4 ++-- 3modules/{tv => krebs}/nginx.nix | 7 ++++--- 3modules/tv/git.nix | 5 +++-- 5 files changed, 16 insertions(+), 14 deletions(-) rename 3modules/{tv => krebs}/nginx.nix (91%) diff --git a/1systems/tv/cd.nix b/1systems/tv/cd.nix index d3cae6f4a..407fc25cf 100644 --- a/1systems/tv/cd.nix +++ b/1systems/tv/cd.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..7a12bc571 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 "~ ^/~(.+?)(/.*)?\$" '' 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/git.nix b/3modules/tv/git.nix index 8c73d0354..ea014e2a7 100644 --- a/3modules/tv/git.nix +++ b/3modules/tv/git.nix @@ -12,8 +12,9 @@ let cfg = config.tv.git; out = { + # TODO don't import krebs.nginx here imports = [ - ../../3modules/tv/nginx.nix + ../../3modules/krebs/nginx.nix ]; options.tv.git = api; config = mkIf cfg.enable (mkMerge [ @@ -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 = [ From 5f63c4071c7b1680e75671c0acede8a9bce4b14c Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 24 Jul 2015 11:44:49 +0200 Subject: [PATCH 2/5] 3: {tv -> krebs}.git --- 2configs/tv/git-public.nix | 4 ++-- 3modules/{tv => krebs}/git.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename 3modules/{tv => krebs}/git.nix (99%) 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 99% rename from 3modules/tv/git.nix rename to 3modules/krebs/git.nix index ea014e2a7..3c3e93426 100644 --- a/3modules/tv/git.nix +++ b/3modules/krebs/git.nix @@ -9,14 +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/krebs/nginx.nix ]; - options.tv.git = api; + options.krebs.git = api; config = mkIf cfg.enable (mkMerge [ (mkIf cfg.cgit cgit-imp) git-imp @@ -24,7 +24,7 @@ let }; api = { - enable = mkEnableOption "tv.git"; + enable = mkEnableOption "krebs.git"; cgit = mkOption { type = types.bool; From b6987329fe6dca5aca96fc651f06867c26dbf236 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 24 Jul 2015 11:55:16 +0200 Subject: [PATCH 3/5] 3: {tv -> krebs}.urlwatch --- 1systems/tv/wu.nix | 4 ++-- 3modules/{tv => krebs}/urlwatch.nix | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename 3modules/{tv => krebs}/urlwatch.nix (96%) diff --git a/1systems/tv/wu.nix b/1systems/tv/wu.nix index 7a12bc571..1d7bbe55b 100644 --- a/1systems/tv/wu.nix +++ b/1systems/tv/wu.nix @@ -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/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; From e3b72bb66e7c6bf410c8db81ff04e355a7b22116 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 24 Jul 2015 12:03:51 +0200 Subject: [PATCH 4/5] 3: {tv -> krebs}.github-hosts-sync --- 1systems/tv/cd.nix | 6 +++--- 3modules/{tv => krebs}/github-hosts-sync.nix | 8 ++++---- Zpkgs/krebs/default.nix | 11 +++++++++++ Zpkgs/{tv => krebs}/github-hosts-sync.nix | 0 Zpkgs/{tv => krebs}/github-known_hosts.nix | 0 Zpkgs/tv/default.nix | 2 -- 6 files changed, 18 insertions(+), 9 deletions(-) rename 3modules/{tv => krebs}/github-hosts-sync.nix (91%) create mode 100644 Zpkgs/krebs/default.nix rename Zpkgs/{tv => krebs}/github-hosts-sync.nix (100%) rename Zpkgs/{tv => krebs}/github-known_hosts.nix (100%) diff --git a/1systems/tv/cd.nix b/1systems/tv/cd.nix index 407fc25cf..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 ]; 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/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 {}; From ee52522cc139670c3eeaeeb462dff98ea870d2e4 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 24 Jul 2015 12:23:52 +0200 Subject: [PATCH 5/5] 4: {tv -> krebs}.types --- 4lib/krebs/default.nix | 7 ++++ 4lib/krebs/types.nix | 81 +++++++++++++++++++++++++++++++++++++++ 4lib/tv/default.nix | 87 +++--------------------------------------- 3 files changed, 94 insertions(+), 81 deletions(-) create mode 100644 4lib/krebs/default.nix create mode 100644 4lib/krebs/types.nix 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; - }); - }