2015-07-24 18:48:00 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
|
2016-10-20 18:54:38 +00:00
|
|
|
with import <stockholm/lib>;
|
2015-07-24 18:48:00 +00:00
|
|
|
let
|
|
|
|
cfg = config.krebs;
|
|
|
|
|
|
|
|
out = {
|
|
|
|
imports = [
|
2018-09-24 21:32:28 +00:00
|
|
|
./airdcpp.nix
|
2017-09-05 20:58:25 +00:00
|
|
|
./announce-activation.nix
|
2015-11-17 12:49:29 +00:00
|
|
|
./apt-cacher-ng.nix
|
2015-12-28 18:43:31 +00:00
|
|
|
./backup.nix
|
2015-10-22 13:26:54 +00:00
|
|
|
./bepasty-server.nix
|
2015-12-22 18:36:19 +00:00
|
|
|
./buildbot/master.nix
|
|
|
|
./buildbot/slave.nix
|
2016-02-15 15:29:01 +00:00
|
|
|
./build.nix
|
2018-11-20 23:03:49 +00:00
|
|
|
./cachecache.nix
|
2018-10-07 13:09:15 +00:00
|
|
|
./charybdis.nix
|
2018-09-09 18:01:51 +00:00
|
|
|
./ci.nix
|
2015-10-25 13:15:21 +00:00
|
|
|
./current.nix
|
2016-04-26 23:10:25 +00:00
|
|
|
./exim.nix
|
2015-08-13 09:46:09 +00:00
|
|
|
./exim-retiolum.nix
|
2015-08-14 13:48:17 +00:00
|
|
|
./exim-smarthost.nix
|
2015-12-12 18:37:13 +00:00
|
|
|
./fetchWallpaper.nix
|
2015-07-24 18:48:00 +00:00
|
|
|
./github-hosts-sync.nix
|
|
|
|
./git.nix
|
2015-11-13 00:16:15 +00:00
|
|
|
./go.nix
|
2017-04-15 16:04:19 +00:00
|
|
|
./hidden-ssh.nix
|
2017-03-16 19:56:28 +00:00
|
|
|
./htgen.nix
|
2017-09-21 18:59:38 +00:00
|
|
|
./iana-etc.nix
|
2015-10-01 20:10:21 +00:00
|
|
|
./iptables.nix
|
2017-02-07 16:21:25 +00:00
|
|
|
./kapacitor.nix
|
2018-08-25 14:54:13 +00:00
|
|
|
./konsens.nix
|
2017-02-13 13:31:26 +00:00
|
|
|
./monit.nix
|
2016-03-15 13:37:46 +00:00
|
|
|
./newsbot-js.nix
|
2016-02-10 18:06:32 +00:00
|
|
|
./nixpkgs.nix
|
2016-03-15 14:58:45 +00:00
|
|
|
./on-failure.nix
|
2016-03-05 11:40:20 +00:00
|
|
|
./os-release.nix
|
2015-11-06 20:37:58 +00:00
|
|
|
./per-user.nix
|
2016-07-26 19:36:47 +00:00
|
|
|
./power-action.nix
|
2015-08-31 12:22:21 +00:00
|
|
|
./Reaktor.nix
|
2015-10-05 12:49:36 +00:00
|
|
|
./realwallpaper.nix
|
2016-02-15 15:29:01 +00:00
|
|
|
./retiolum-bootstrap.nix
|
2016-08-24 15:51:22 +00:00
|
|
|
./rtorrent.nix
|
2016-02-21 04:27:37 +00:00
|
|
|
./secret.nix
|
2016-02-14 12:26:37 +00:00
|
|
|
./setuid.nix
|
2017-05-16 20:06:31 +00:00
|
|
|
./tinc.nix
|
2015-10-22 13:33:05 +00:00
|
|
|
./tinc_graphs.nix
|
2015-07-24 18:48:00 +00:00
|
|
|
./urlwatch.nix
|
2016-02-15 13:01:20 +00:00
|
|
|
./repo-sync.nix
|
2017-12-15 18:55:02 +00:00
|
|
|
./xresources.nix
|
2017-11-30 21:35:04 +00:00
|
|
|
./zones.nix
|
2015-07-24 18:48:00 +00:00
|
|
|
];
|
|
|
|
options.krebs = api;
|
2016-02-14 15:43:44 +00:00
|
|
|
config = lib.mkIf cfg.enable imp;
|
2015-07-24 18:48:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
api = {
|
2015-07-24 19:27:19 +00:00
|
|
|
enable = mkEnableOption "krebs";
|
|
|
|
|
2015-07-26 19:04:13 +00:00
|
|
|
dns = {
|
|
|
|
providers = mkOption {
|
2016-02-21 19:04:45 +00:00
|
|
|
type = with types; attrsOf str;
|
2015-07-26 19:04:13 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-07-24 19:15:18 +00:00
|
|
|
hosts = mkOption {
|
|
|
|
type = with types; attrsOf host;
|
2017-12-05 22:37:19 +00:00
|
|
|
default = {};
|
2015-07-24 19:27:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
users = mkOption {
|
|
|
|
type = with types; attrsOf user;
|
|
|
|
};
|
2015-07-24 22:04:04 +00:00
|
|
|
|
|
|
|
# XXX is there a better place to define search-domain?
|
|
|
|
# TODO search-domains :: listOf hostname
|
|
|
|
search-domain = mkOption {
|
|
|
|
type = types.hostname;
|
2017-04-13 00:57:11 +00:00
|
|
|
default = "r";
|
2015-07-24 22:04:04 +00:00
|
|
|
};
|
2017-08-01 09:27:03 +00:00
|
|
|
|
|
|
|
sitemap = mkOption {
|
|
|
|
default = {};
|
|
|
|
type = types.attrsOf types.sitemap.entry;
|
|
|
|
};
|
|
|
|
|
2015-08-16 21:58:02 +00:00
|
|
|
zone-head-config = mkOption {
|
|
|
|
type = with types; attrsOf str;
|
|
|
|
description = ''
|
|
|
|
The zone configuration head which is being used to create the
|
|
|
|
zone files. The string for each key is pre-pended to the zone file.
|
|
|
|
'';
|
|
|
|
# TODO: configure the default somewhere else,
|
|
|
|
# maybe use krebs.dns.providers
|
|
|
|
default = {
|
2015-08-16 22:43:44 +00:00
|
|
|
|
|
|
|
# github.io -> 192.30.252.154
|
2015-08-16 21:58:02 +00:00
|
|
|
"krebsco.de" = ''
|
|
|
|
$TTL 86400
|
|
|
|
@ IN SOA dns19.ovh.net. tech.ovh.net. (2015052000 86400 3600 3600000 86400)
|
|
|
|
IN NS ns19.ovh.net.
|
|
|
|
IN NS dns19.ovh.net.
|
|
|
|
IN A 192.30.252.154
|
|
|
|
IN A 192.30.252.153
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2015-07-24 19:27:19 +00:00
|
|
|
};
|
|
|
|
|
2016-02-14 15:43:44 +00:00
|
|
|
imp = lib.mkMerge [
|
2018-12-05 15:06:32 +00:00
|
|
|
{ krebs = import ./external { inherit config; }; }
|
2017-12-15 12:32:32 +00:00
|
|
|
{ krebs = import ./jeschli { inherit config; }; }
|
2017-07-13 22:17:58 +00:00
|
|
|
{ krebs = import ./krebs { inherit config; }; }
|
2017-12-15 12:32:32 +00:00
|
|
|
{ krebs = import ./lass { inherit config; }; }
|
2016-11-10 21:28:00 +00:00
|
|
|
{ krebs = import ./makefu { inherit config; }; }
|
|
|
|
{ krebs = import ./tv { inherit config; }; }
|
2015-07-24 22:04:04 +00:00
|
|
|
{
|
2015-07-26 19:04:13 +00:00
|
|
|
krebs.dns.providers = {
|
2016-02-21 19:04:45 +00:00
|
|
|
"krebsco.de" = "zones";
|
2015-10-18 14:12:14 +00:00
|
|
|
gg23 = "hosts";
|
2015-11-17 21:15:07 +00:00
|
|
|
shack = "hosts";
|
2016-02-06 15:21:30 +00:00
|
|
|
i = "hosts";
|
|
|
|
r = "hosts";
|
2018-12-09 15:52:32 +00:00
|
|
|
w = "hosts";
|
2015-07-26 19:04:13 +00:00
|
|
|
};
|
2015-07-24 22:04:04 +00:00
|
|
|
|
2016-02-21 06:39:24 +00:00
|
|
|
krebs.users = {
|
|
|
|
krebs = {
|
|
|
|
home = "/krebs";
|
|
|
|
mail = "spam@krebsco.de";
|
|
|
|
};
|
|
|
|
root = {
|
|
|
|
home = "/root";
|
|
|
|
pubkey = config.krebs.build.host.ssh.pubkey;
|
|
|
|
uid = 0;
|
|
|
|
};
|
2016-02-21 06:18:13 +00:00
|
|
|
};
|
|
|
|
|
2016-02-21 19:04:45 +00:00
|
|
|
networking.extraHosts = let
|
|
|
|
domains = attrNames (filterAttrs (_: eq "hosts") cfg.dns.providers);
|
|
|
|
check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
|
|
|
|
in concatStringsSep "\n" (flatten (
|
2015-07-26 19:04:13 +00:00
|
|
|
mapAttrsToList (hostname: host:
|
|
|
|
mapAttrsToList (netname: net:
|
|
|
|
let
|
2015-09-27 13:19:59 +00:00
|
|
|
aliases = longs ++ shorts;
|
2016-02-21 19:04:45 +00:00
|
|
|
longs = filter check net.aliases;
|
2016-02-06 14:57:43 +00:00
|
|
|
shorts = let s = ".${cfg.search-domain}"; in
|
|
|
|
map (removeSuffix s) (filter (hasSuffix s) longs);
|
2015-07-26 19:04:13 +00:00
|
|
|
in
|
2016-11-11 00:50:59 +00:00
|
|
|
optionals
|
|
|
|
(aliases != [])
|
|
|
|
(map (addr: "${addr} ${toString aliases}") net.addrs)
|
2015-09-27 13:19:59 +00:00
|
|
|
) (filterAttrs (name: host: host.aliases != []) host.nets)
|
2015-07-26 19:04:13 +00:00
|
|
|
) cfg.hosts
|
|
|
|
));
|
2015-08-13 20:28:21 +00:00
|
|
|
|
2017-05-09 21:42:18 +00:00
|
|
|
# TODO dedup with networking.extraHosts
|
|
|
|
nixpkgs.config.packageOverrides = oldpkgs:
|
|
|
|
let
|
|
|
|
domains = attrNames (filterAttrs (_: eq "hosts") cfg.dns.providers);
|
|
|
|
check = hostname: any (domain: hasSuffix ".${domain}" hostname) domains;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
retiolum-hosts = oldpkgs.writeText "retiolum-hosts" ''
|
|
|
|
${concatStringsSep "\n" (flatten (
|
|
|
|
map (host:
|
|
|
|
let
|
|
|
|
net = host.nets.retiolum;
|
|
|
|
aliases = longs;
|
|
|
|
longs = filter check net.aliases;
|
|
|
|
in
|
|
|
|
optionals
|
|
|
|
(aliases != [])
|
|
|
|
(map (addr: "${addr} ${toString aliases}") net.addrs)
|
|
|
|
) (filter (host: hasAttr "retiolum" host.nets)
|
|
|
|
(attrValues cfg.hosts))))}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-10-05 01:01:21 +00:00
|
|
|
krebs.exim-smarthost.internet-aliases = let
|
2016-02-21 20:51:11 +00:00
|
|
|
format = from: to: {
|
|
|
|
inherit from;
|
2015-10-05 01:01:21 +00:00
|
|
|
# TODO assert is-retiolum-mail-address to;
|
2016-02-21 20:51:11 +00:00
|
|
|
to = concatMapStringsSep "," (getAttr "mail") (toList to);
|
|
|
|
};
|
2015-10-05 01:01:21 +00:00
|
|
|
in mapAttrsToList format (with config.krebs.users; let
|
2018-09-18 20:15:54 +00:00
|
|
|
brain-ml = [
|
|
|
|
lass
|
|
|
|
makefu
|
|
|
|
tv
|
|
|
|
];
|
2016-12-01 15:57:29 +00:00
|
|
|
eloop-ml = spam-ml ++ [ ciko ];
|
2015-10-05 01:01:21 +00:00
|
|
|
spam-ml = [
|
|
|
|
lass
|
|
|
|
makefu
|
|
|
|
tv
|
|
|
|
];
|
2017-06-18 16:55:07 +00:00
|
|
|
ciko.mail = "ciko@slash16.net";
|
2015-10-05 01:01:21 +00:00
|
|
|
in {
|
2016-11-12 13:37:07 +00:00
|
|
|
"anmeldung@eloop.org" = eloop-ml;
|
2018-09-18 20:15:54 +00:00
|
|
|
"brain@krebsco.de" = brain-ml;
|
2016-08-09 18:00:02 +00:00
|
|
|
"cfp@eloop.org" = eloop-ml;
|
|
|
|
"kontakt@eloop.org" = eloop-ml;
|
|
|
|
"root@eloop.org" = eloop-ml;
|
2018-11-10 19:06:31 +00:00
|
|
|
"youtube@eloop.org" = eloop-ml;
|
2016-08-09 18:00:02 +00:00
|
|
|
"eloop2016@krebsco.de" = eloop-ml;
|
2017-10-16 20:55:38 +00:00
|
|
|
"eloop2017@krebsco.de" = eloop-ml;
|
2015-10-05 01:03:51 +00:00
|
|
|
"postmaster@krebsco.de" = spam-ml; # RFC 822
|
2015-10-05 01:29:04 +00:00
|
|
|
"lass@krebsco.de" = lass;
|
|
|
|
"makefu@krebsco.de" = makefu;
|
2015-10-05 01:01:21 +00:00
|
|
|
"spam@krebsco.de" = spam-ml;
|
2015-10-05 01:29:04 +00:00
|
|
|
"tv@krebsco.de" = tv;
|
2015-10-05 01:06:04 +00:00
|
|
|
# XXX These are no internet aliases
|
|
|
|
# XXX exim-retiolum hosts should be able to relay to retiolum addresses
|
|
|
|
"lass@retiolum" = lass;
|
|
|
|
"makefu@retiolum" = makefu;
|
|
|
|
"spam@retiolum" = spam-ml;
|
|
|
|
"tv@retiolum" = tv;
|
2016-02-21 20:51:11 +00:00
|
|
|
"lass@r" = lass;
|
|
|
|
"makefu@r" = makefu;
|
|
|
|
"spam@r" = spam-ml;
|
|
|
|
"tv@r" = tv;
|
2015-10-05 01:01:21 +00:00
|
|
|
});
|
|
|
|
|
2015-09-27 14:15:53 +00:00
|
|
|
services.openssh.hostKeys =
|
|
|
|
let inherit (config.krebs.build.host.ssh) privkey; in
|
|
|
|
mkIf (privkey != null) (mkForce [privkey]);
|
|
|
|
|
2016-02-07 14:58:49 +00:00
|
|
|
# TODO use imports for merging
|
2015-09-27 14:15:53 +00:00
|
|
|
services.openssh.knownHosts =
|
2016-02-07 14:58:49 +00:00
|
|
|
(let inherit (config.krebs.build.host.ssh) pubkey; in
|
|
|
|
optionalAttrs (pubkey != null) {
|
|
|
|
localhost = {
|
|
|
|
hostNames = ["localhost" "127.0.0.1" "::1"];
|
|
|
|
publicKey = pubkey;
|
|
|
|
};
|
|
|
|
})
|
|
|
|
//
|
2017-12-12 20:08:50 +00:00
|
|
|
{
|
|
|
|
github = {
|
|
|
|
hostNames = [
|
|
|
|
"github.com"
|
|
|
|
# List generated with
|
|
|
|
# curl -sS https://api.github.com/meta | jq -r .git[] | cidr2glob
|
2018-02-19 12:42:00 +00:00
|
|
|
"192.30.252.*"
|
2017-12-12 20:08:50 +00:00
|
|
|
"192.30.253.*"
|
|
|
|
"192.30.254.*"
|
|
|
|
"192.30.255.*"
|
|
|
|
"185.199.108.*"
|
|
|
|
"185.199.109.*"
|
|
|
|
"185.199.110.*"
|
|
|
|
"185.199.111.*"
|
2018-02-19 12:42:00 +00:00
|
|
|
"13.229.188.59"
|
|
|
|
"13.250.177.223"
|
2017-12-12 20:08:50 +00:00
|
|
|
"18.194.104.89"
|
2018-02-19 12:42:00 +00:00
|
|
|
"18.195.85.27"
|
2017-12-12 20:08:50 +00:00
|
|
|
"35.159.8.160"
|
2018-02-19 12:42:00 +00:00
|
|
|
"52.74.223.119"
|
2017-12-12 20:08:50 +00:00
|
|
|
];
|
|
|
|
publicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
|
|
|
|
};
|
|
|
|
}
|
2015-10-09 11:18:21 +00:00
|
|
|
//
|
2015-09-27 13:24:41 +00:00
|
|
|
mapAttrs
|
|
|
|
(name: host: {
|
|
|
|
hostNames =
|
|
|
|
concatLists
|
|
|
|
(mapAttrsToList
|
|
|
|
(net-name: net:
|
|
|
|
let
|
|
|
|
longs = net.aliases;
|
|
|
|
shorts =
|
|
|
|
map (removeSuffix ".${cfg.search-domain}")
|
|
|
|
(filter (hasSuffix ".${cfg.search-domain}")
|
|
|
|
longs);
|
|
|
|
add-port = a:
|
2016-04-17 02:13:32 +00:00
|
|
|
if net.ssh.port != 22
|
2015-09-27 13:24:41 +00:00
|
|
|
then "[${a}]:${toString net.ssh.port}"
|
|
|
|
else a;
|
|
|
|
in
|
2016-02-07 05:43:26 +00:00
|
|
|
map add-port (shorts ++ longs ++ net.addrs))
|
2015-09-27 13:24:41 +00:00
|
|
|
host.nets);
|
|
|
|
|
|
|
|
publicKey = host.ssh.pubkey;
|
|
|
|
})
|
|
|
|
(filterAttrs (_: host: host.ssh.pubkey != null) cfg.hosts);
|
2016-04-17 08:23:01 +00:00
|
|
|
|
|
|
|
programs.ssh.extraConfig = concatMapStrings
|
|
|
|
(net: ''
|
|
|
|
Host ${toString (net.aliases ++ net.addrs)}
|
|
|
|
Port ${toString net.ssh.port}
|
|
|
|
'')
|
|
|
|
(filter
|
|
|
|
(net: net.ssh.port != 22)
|
|
|
|
(concatMap (host: attrValues host.nets)
|
|
|
|
(mapAttrsToList
|
|
|
|
(_: host: recursiveUpdate host
|
|
|
|
(optionalAttrs (hasAttr config.krebs.search-domain host.nets) {
|
|
|
|
nets."" = host.nets.${config.krebs.search-domain} // {
|
|
|
|
aliases = [host.name];
|
|
|
|
addrs = [];
|
|
|
|
};
|
|
|
|
}))
|
|
|
|
config.krebs.hosts)));
|
2015-08-16 21:58:02 +00:00
|
|
|
}
|
2015-07-24 19:38:41 +00:00
|
|
|
];
|
|
|
|
|
2016-04-17 08:23:01 +00:00
|
|
|
in out
|