Merge branch 'master' of http://cgit.cd/stockholm

This commit is contained in:
makefu 2015-07-24 13:28:35 +02:00
commit 2cecdcd6bb
15 changed files with 138 additions and 114 deletions

View File

@ -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 "/" ''

View File

@ -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 "~ ^/~(.+?)(/.*)?\$" ''

View File

@ -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";

View File

@ -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";

View File

@ -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 = [

View File

@ -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

View File

@ -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"

View File

@ -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;

7
4lib/krebs/default.nix Normal file
View File

@ -0,0 +1,7 @@
{ lib, ... }:
builtins // lib // {
types = import ./types.nix { inherit lib; };
}

81
4lib/krebs/types.nix Normal file
View File

@ -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;
}

View File

@ -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;
});
}

11
Zpkgs/krebs/default.nix Normal file
View File

@ -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 {};
}

View File

@ -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 {};