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 ]; imports = [ ../../3modules/krebs/github-hosts-sync.nix ];
tv.github-hosts-sync.enable = true; krebs.github-hosts-sync.enable = true;
tv.iptables.input-internet-accept-new-tcp = 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 ]; imports = [ ../../2configs/tv/identity.nix ];
@ -57,19 +57,19 @@ in
{ {
imports = [ imports = [
../../3modules/tv/iptables.nix ../../3modules/tv/iptables.nix
../../3modules/tv/nginx.nix ../../3modules/krebs/nginx.nix
]; ];
tv.iptables.input-internet-accept-new-tcp = singleton "http"; 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) # TODO make public_html also available to cd, cd.retiolum (AKA default)
imports = [ imports = [
../../3modules/tv/iptables.nix ../../3modules/tv/iptables.nix
../../3modules/tv/nginx.nix ../../3modules/krebs/nginx.nix
]; ];
tv.iptables.input-internet-accept-new-tcp = singleton "http"; 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"; server-names = singleton "cd.viljetic.de";
locations = singleton (nameValuePair "~ ^/~(.+?)(/.*)?\$" '' locations = singleton (nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
alias /home/$1/public_html$2; alias /home/$1/public_html$2;
@ -77,7 +77,7 @@ in
}; };
} }
{ {
tv.nginx.servers.viljetic = { krebs.nginx.servers.viljetic = {
server-names = singleton "viljetic.de"; server-names = singleton "viljetic.de";
# TODO directly set root (instead via location) # TODO directly set root (instead via location)
locations = singleton (nameValuePair "/" '' locations = singleton (nameValuePair "/" ''

View File

@ -26,8 +26,8 @@ with lib;
}; };
} }
{ {
imports = [ ../../3modules/tv/nginx.nix ]; imports = [ ../../3modules/krebs/nginx.nix ];
tv.nginx = { krebs.nginx = {
enable = true; enable = true;
servers.default.locations = [ servers.default.locations = [
(nameValuePair "~ ^/~(.+?)(/.*)?\$" '' (nameValuePair "~ ^/~(.+?)(/.*)?\$" ''

View File

@ -134,8 +134,8 @@ in
}; };
} }
{ {
imports = [ ../../3modules/tv/nginx.nix ]; imports = [ ../../3modules/krebs/nginx.nix ];
tv.nginx = { krebs.nginx = {
enable = true; enable = true;
servers.default.locations = [ servers.default.locations = [
(nameValuePair "~ ^/~(.+?)(/.*)?\$" '' (nameValuePair "~ ^/~(.+?)(/.*)?\$" ''
@ -156,8 +156,8 @@ in
}; };
} }
{ {
imports = [ ../../3modules/tv/urlwatch.nix ]; imports = [ ../../3modules/krebs/urlwatch.nix ];
tv.urlwatch = { krebs.urlwatch = {
enable = true; enable = true;
mailto = "tv@wu.retiolum"; # TODO mailto = "tv@wu.retiolum"; # TODO
onCalendar = "*-*-* 05:00:00"; onCalendar = "*-*-* 05:00:00";

View File

@ -3,8 +3,8 @@ with import ../../4lib/tv { inherit lib pkgs; };
let let
out = { out = {
imports = [ ../../3modules/tv/git.nix ]; imports = [ ../../3modules/krebs/git.nix ];
tv.git = { krebs.git = {
enable = true; enable = true;
root-title = "public repositories at ${config.tv.identity.self.name}"; root-title = "public repositories at ${config.tv.identity.self.name}";
root-desc = "keep calm and engage"; root-desc = "keep calm and engage";

View File

@ -9,13 +9,14 @@
with builtins; with builtins;
with lib; with lib;
let let
cfg = config.tv.git; cfg = config.krebs.git;
out = { out = {
# TODO don't import krebs.nginx here
imports = [ imports = [
../../3modules/tv/nginx.nix ../../3modules/krebs/nginx.nix
]; ];
options.tv.git = api; options.krebs.git = api;
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.cgit cgit-imp) (mkIf cfg.cgit cgit-imp)
git-imp git-imp
@ -23,7 +24,7 @@ let
}; };
api = { api = {
enable = mkEnableOption "tv.git"; enable = mkEnableOption "krebs.git";
cgit = mkOption { cgit = mkOption {
type = types.bool; type = types.bool;
@ -210,7 +211,7 @@ let
chown ${toString fcgitwrap-user.uid}:${toString fcgitwrap-group.gid} /tmp/cgit chown ${toString fcgitwrap-user.uid}:${toString fcgitwrap-group.gid} /tmp/cgit
''; '';
tv.nginx = { krebs.nginx = {
enable = true; enable = true;
servers.cgit = { servers.cgit = {
server-names = [ server-names = [

View File

@ -3,15 +3,15 @@
with builtins; with builtins;
with lib; with lib;
let let
cfg = config.tv.github-hosts-sync; cfg = config.krebs.github-hosts-sync;
out = { out = {
options.tv.github-hosts-sync = api; options.krebs.github-hosts-sync = api;
config = mkIf cfg.enable imp; config = mkIf cfg.enable imp;
}; };
api = { api = {
enable = mkEnableOption "tv.github-hosts-sync"; enable = mkEnableOption "krebs.github-hosts-sync";
port = mkOption { port = mkOption {
type = types.int; # TODO port type type = types.int; # TODO port type
default = 1028; default = 1028;
@ -78,6 +78,6 @@ let
uid = 3220554646; # genid github-hosts-sync uid = 3220554646; # genid github-hosts-sync
}; };
Zpkgs = import ../../Zpkgs/tv { inherit pkgs; }; Zpkgs = import ../../Zpkgs/krebs { inherit pkgs; };
in in
out out

View File

@ -3,21 +3,22 @@
with builtins; with builtins;
with lib; with lib;
let let
cfg = config.tv.nginx; cfg = config.krebs.nginx;
out = { out = {
options.tv.nginx = api; options.krebs.nginx = api;
config = mkIf cfg.enable imp; config = mkIf cfg.enable imp;
}; };
api = { api = {
enable = mkEnableOption "tv.nginx"; enable = mkEnableOption "krebs.nginx";
servers = mkOption { servers = mkOption {
type = with types; attrsOf optionSet; type = with types; attrsOf optionSet;
options = singleton { options = singleton {
server-names = mkOption { server-names = mkOption {
type = with types; listOf str; type = with types; listOf str;
# TODO use identity
default = [ default = [
"${config.networking.hostName}" "${config.networking.hostName}"
"${config.networking.hostName}.retiolum" "${config.networking.hostName}.retiolum"

View File

@ -8,16 +8,16 @@
with builtins; with builtins;
with lib; with lib;
let let
cfg = config.tv.urlwatch; cfg = config.krebs.urlwatch;
# TODO assert sendmail's existence # TODO assert sendmail's existence
out = { out = {
options.tv.urlwatch = api; options.krebs.urlwatch = api;
config = mkIf cfg.enable imp; config = mkIf cfg.enable imp;
}; };
api = { api = {
enable = mkEnableOption "tv.urlwatch"; enable = mkEnableOption "krebs.urlwatch";
dataDir = mkOption { dataDir = mkOption {
type = types.str; 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, ... }: { lib, pkgs, ... }:
with builtins; let
with lib; krebs = import ../../4lib/krebs { inherit lib; };
in
builtins // lib // rec { with krebs;
krebs // rec {
git = import ./git.nix { git = import ./git.nix {
lib = lib // { lib = lib // {
@ -53,82 +56,4 @@ builtins // lib // rec {
if isSafeChar c then c if isSafeChar c then c
else if c == "\n" then "'\n'" else if c == "\n" then "'\n'"
else "\\${c}"); 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 {}; charybdis = callPackage ./charybdis {};
dic = callPackage ./dic.nix {}; dic = callPackage ./dic.nix {};
genid = callPackage ./genid.nix {}; genid = callPackage ./genid.nix {};
github-hosts-sync = callPackage ./github-hosts-sync.nix {};
github-known_hosts = callPackage ./github-known_hosts.nix {};
lentil = callPackage ./lentil {}; lentil = callPackage ./lentil {};
much = callPackage ./much.nix {}; much = callPackage ./much.nix {};
viljetic-pages = callPackage ./viljetic-pages {}; viljetic-pages = callPackage ./viljetic-pages {};