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 = [
|
2022-11-22 19:15:44 +00:00
|
|
|
../../kartei
|
2022-12-27 17:55:23 +00:00
|
|
|
../../submodules/disko/module.nix
|
2022-01-30 09:47:23 +00:00
|
|
|
./acl.nix
|
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
|
2021-01-24 10:26:39 +00:00
|
|
|
./bindfs.nix
|
2020-12-30 08:47:57 +00:00
|
|
|
./brockman.nix
|
2016-02-15 15:29:01 +00:00
|
|
|
./build.nix
|
2018-11-20 23:03:49 +00:00
|
|
|
./cachecache.nix
|
2022-10-23 16:30:56 +00:00
|
|
|
./ci
|
2015-10-25 13:15:21 +00:00
|
|
|
./current.nix
|
2019-01-21 09:32:15 +00:00
|
|
|
./dns.nix
|
2015-08-13 09:46:09 +00:00
|
|
|
./exim-retiolum.nix
|
2015-08-14 13:48:17 +00:00
|
|
|
./exim-smarthost.nix
|
2022-01-27 11:19:47 +00:00
|
|
|
./exim.nix
|
2015-12-12 18:37:13 +00:00
|
|
|
./fetchWallpaper.nix
|
2022-01-27 11:19:47 +00:00
|
|
|
./git.nix
|
2022-09-20 09:17:19 +00:00
|
|
|
./github
|
2015-11-13 00:16:15 +00:00
|
|
|
./go.nix
|
2017-04-15 16:04:19 +00:00
|
|
|
./hidden-ssh.nix
|
2019-01-21 10:04:37 +00:00
|
|
|
./hosts.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
|
2022-12-09 14:50:25 +00:00
|
|
|
./krebs-pages.nix
|
2017-02-13 13:31:26 +00:00
|
|
|
./monit.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
|
2022-01-27 11:19:47 +00:00
|
|
|
./permown.nix
|
2016-07-26 19:36:47 +00:00
|
|
|
./power-action.nix
|
2019-01-22 18:35:03 +00:00
|
|
|
./reaktor2.nix
|
2015-10-05 12:49:36 +00:00
|
|
|
./realwallpaper.nix
|
2022-01-27 11:19:47 +00:00
|
|
|
./repo-sync.nix
|
2016-02-15 15:29:01 +00:00
|
|
|
./retiolum-bootstrap.nix
|
2016-02-21 04:27:37 +00:00
|
|
|
./secret.nix
|
2016-02-14 12:26:37 +00:00
|
|
|
./setuid.nix
|
2019-04-19 14:32:00 +00:00
|
|
|
./shadow.nix
|
2022-11-23 15:43:02 +00:00
|
|
|
./sitemap.nix
|
2021-12-09 10:21:06 +00:00
|
|
|
./ssl.nix
|
2021-01-24 09:41:47 +00:00
|
|
|
./sync-containers.nix
|
2021-12-23 00:10:22 +00:00
|
|
|
./systemd.nix
|
2017-05-16 20:06:31 +00:00
|
|
|
./tinc.nix
|
2015-10-22 13:33:05 +00:00
|
|
|
./tinc_graphs.nix
|
2021-01-26 19:20:05 +00:00
|
|
|
./upstream
|
2015-07-24 18:48:00 +00:00
|
|
|
./urlwatch.nix
|
2022-11-23 15:37:32 +00:00
|
|
|
./users.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-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.
|
2021-11-21 19:39:28 +00:00
|
|
|
'';
|
|
|
|
# TODO: configure the default somewhere else,
|
|
|
|
# maybe use krebs.dns.providers
|
2015-08-16 21:58:02 +00:00
|
|
|
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.
|
|
|
|
'';
|
2021-11-21 19:39:28 +00:00
|
|
|
};
|
2015-08-16 21:58:02 +00:00
|
|
|
};
|
2015-07-24 19:27:19 +00:00
|
|
|
};
|
|
|
|
|
2016-02-14 15:43:44 +00:00
|
|
|
imp = lib.mkMerge [
|
2015-07-24 22:04:04 +00:00
|
|
|
{
|
2015-09-27 14:15:53 +00:00
|
|
|
services.openssh.hostKeys =
|
|
|
|
let inherit (config.krebs.build.host.ssh) privkey; in
|
2019-04-30 17:12:00 +00:00
|
|
|
mkIf (privkey != null) [privkey];
|
2015-09-27 14:15:53 +00:00
|
|
|
|
|
|
|
services.openssh.knownHosts =
|
2022-07-15 08:27:30 +00:00
|
|
|
filterAttrs
|
|
|
|
(knownHostName: knownHost:
|
|
|
|
knownHost.publicKey != null &&
|
|
|
|
knownHost.hostNames != []
|
|
|
|
)
|
|
|
|
(mapAttrs
|
|
|
|
(hostName: host: {
|
|
|
|
hostNames =
|
|
|
|
concatLists
|
|
|
|
(mapAttrsToList
|
|
|
|
(netName: net:
|
|
|
|
let
|
|
|
|
aliases =
|
|
|
|
concatLists [
|
|
|
|
shortAliases
|
|
|
|
net.aliases
|
|
|
|
net.addrs
|
|
|
|
];
|
|
|
|
shortAliases =
|
|
|
|
optionals
|
|
|
|
(cfg.dns.search-domain != null)
|
|
|
|
(map (removeSuffix ".${cfg.dns.search-domain}")
|
|
|
|
(filter (hasSuffix ".${cfg.dns.search-domain}")
|
|
|
|
net.aliases));
|
|
|
|
addPort = alias:
|
|
|
|
if net.ssh.port != 22
|
|
|
|
then "[${alias}]:${toString net.ssh.port}"
|
|
|
|
else alias;
|
|
|
|
in
|
|
|
|
map addPort aliases
|
|
|
|
)
|
|
|
|
host.nets);
|
|
|
|
publicKey = host.ssh.pubkey;
|
|
|
|
})
|
|
|
|
(foldl' mergeAttrs {} [
|
|
|
|
cfg.hosts
|
|
|
|
{
|
|
|
|
localhost = {
|
|
|
|
nets.local = {
|
|
|
|
addrs = [ "127.0.0.1" "::1" ];
|
|
|
|
aliases = [ "localhost" ];
|
|
|
|
ssh.port = 22;
|
|
|
|
};
|
|
|
|
ssh.pubkey = config.krebs.build.host.ssh.pubkey;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
]));
|
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
|
2020-08-16 09:28:27 +00:00
|
|
|
(optionalAttrs (cfg.dns.search-domain != null &&
|
|
|
|
hasAttr cfg.dns.search-domain host.nets) {
|
2019-01-21 09:32:15 +00:00
|
|
|
nets."" = host.nets.${cfg.dns.search-domain} // {
|
2016-04-17 08:23:01 +00:00
|
|
|
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
|