stockholm/krebs/3modules/default.nix

198 lines
5.5 KiB
Nix
Raw Normal View History

2015-07-24 20:48:00 +02:00
{ config, lib, ... }:
2016-10-20 20:54:38 +02:00
with import <stockholm/lib>;
2015-07-24 20:48:00 +02:00
let
cfg = config.krebs;
out = {
imports = [
./airdcpp.nix
2017-09-05 22:58:25 +02:00
./announce-activation.nix
./apt-cacher-ng.nix
2015-12-28 19:43:31 +01:00
./backup.nix
./bepasty-server.nix
2021-01-24 11:26:39 +01:00
./bindfs.nix
2020-12-30 09:47:57 +01:00
./brockman.nix
./build.nix
2018-11-21 00:03:49 +01:00
./cachecache.nix
2018-09-09 20:01:51 +02:00
./ci.nix
2015-10-25 14:15:21 +01:00
./current.nix
./dns.nix
2021-06-08 17:41:21 +02:00
./ergo.nix
2016-04-27 01:10:25 +02:00
./exim.nix
2015-08-13 11:46:09 +02:00
./exim-retiolum.nix
2015-08-14 15:48:17 +02:00
./exim-smarthost.nix
./fetchWallpaper.nix
2015-07-24 20:48:00 +02:00
./github-hosts-sync.nix
./github-known-hosts.nix
2015-07-24 20:48:00 +02:00
./git.nix
2015-11-13 01:16:15 +01:00
./go.nix
2017-04-15 18:04:19 +02:00
./hidden-ssh.nix
2019-01-21 11:04:37 +01:00
./hosts.nix
2017-03-16 20:56:28 +01:00
./htgen.nix
2017-09-21 20:59:38 +02:00
./iana-etc.nix
2015-10-01 22:10:21 +02:00
./iptables.nix
2017-02-07 17:21:25 +01:00
./kapacitor.nix
2018-08-25 16:54:13 +02:00
./konsens.nix
2017-02-13 14:31:26 +01:00
./monit.nix
./nixpkgs.nix
2016-03-15 15:58:45 +01:00
./on-failure.nix
2016-03-05 12:40:20 +01:00
./os-release.nix
./permown.nix
2015-11-06 21:37:58 +01:00
./per-user.nix
2016-07-26 21:36:47 +02:00
./power-action.nix
2019-01-22 19:35:03 +01:00
./reaktor2.nix
2015-10-05 14:49:36 +02:00
./realwallpaper.nix
./retiolum-bootstrap.nix
2016-08-24 17:51:22 +02:00
./rtorrent.nix
2016-02-21 05:27:37 +01:00
./secret.nix
2016-02-14 13:26:37 +01:00
./setuid.nix
2019-04-19 16:32:00 +02:00
./shadow.nix
2021-12-09 11:21:06 +01:00
./ssl.nix
2021-01-24 10:41:47 +01:00
./sync-containers.nix
./systemd.nix
2017-05-16 22:06:31 +02:00
./tinc.nix
./tinc_graphs.nix
2021-01-26 20:20:05 +01:00
./upstream
2015-07-24 20:48:00 +02:00
./urlwatch.nix
./repo-sync.nix
./xresources.nix
./zones.nix
2015-07-24 20:48:00 +02:00
];
options.krebs = api;
2016-02-14 16:43:44 +01:00
config = lib.mkIf cfg.enable imp;
2015-07-24 20:48:00 +02:00
};
api = {
enable = mkEnableOption "krebs";
users = mkOption {
type = with types; attrsOf user;
};
2017-08-01 11:27:03 +02:00
sitemap = mkOption {
default = {};
type = types.attrsOf types.sitemap.entry;
};
2015-08-16 23:58:02 +02: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 20:39:28 +01:00
'';
# TODO: configure the default somewhere else,
# maybe use krebs.dns.providers
2015-08-16 23:58:02 +02:00
default = {
# github.io -> 192.30.252.154
2015-08-16 23:58:02 +02: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-01-18 21:00:08 +01:00
IN A 185.199.108.153
IN A 185.199.109.153
IN A 185.199.110.153
IN A 185.199.111.153
2015-08-16 23:58:02 +02:00
'';
2021-11-21 20:39:28 +01:00
};
2015-08-16 23:58:02 +02:00
};
};
2016-02-14 16:43:44 +01:00
imp = lib.mkMerge [
{ krebs = import ./external { inherit config; }; }
{ krebs = import ./jeschli { inherit config; }; }
2017-07-14 00:17:58 +02:00
{ krebs = import ./krebs { inherit config; }; }
{ krebs = import ./lass { inherit config; }; }
2016-11-10 22:28:00 +01:00
{ krebs = import ./makefu { inherit config; }; }
2019-02-08 09:43:33 +01:00
{ krebs = import ./external/palo.nix { inherit config; }; }
2020-01-03 11:25:06 +01:00
{ krebs = import ./external/mic92.nix { inherit config; }; }
2022-01-18 18:50:27 +01:00
{ krebs = import ./external/kmein.nix { inherit config; }; }
2016-11-10 22:28:00 +01:00
{ krebs = import ./tv { inherit config; }; }
{
krebs.dns.providers = {
"krebsco.de" = "zones";
2015-11-17 22:15:07 +01:00
shack = "hosts";
2016-02-06 16:21:30 +01:00
i = "hosts";
r = "hosts";
2018-12-09 16:52:32 +01:00
w = "hosts";
};
krebs.dns.search-domain = mkDefault "r";
2016-02-21 07:39:24 +01:00
krebs.users = {
krebs = {
home = "/krebs";
mail = "spam@krebsco.de";
};
root = {
home = "/root";
pubkey = config.krebs.build.host.ssh.pubkey;
uid = 0;
};
};
services.openssh.hostKeys =
let inherit (config.krebs.build.host.ssh) privkey; in
2019-04-30 19:12:00 +02:00
mkIf (privkey != null) [privkey];
2016-02-07 15:58:49 +01:00
# TODO use imports for merging
services.openssh.knownHosts =
2016-02-07 15:58:49 +01:00
(let inherit (config.krebs.build.host.ssh) pubkey; in
optionalAttrs (pubkey != null) {
localhost = {
hostNames = ["localhost" "127.0.0.1" "::1"];
publicKey = pubkey;
};
})
//
mapAttrs
(name: host: {
hostNames =
concatLists
(mapAttrsToList
(net-name: net:
let
longs = net.aliases;
shorts =
optionals
(cfg.dns.search-domain != null)
(map (removeSuffix ".${cfg.dns.search-domain}")
(filter (hasSuffix ".${cfg.dns.search-domain}")
longs));
add-port = a:
if net.ssh.port != 22
then "[${a}]:${toString net.ssh.port}"
else a;
in
2016-02-07 06:43:26 +01:00
map add-port (shorts ++ longs ++ net.addrs))
host.nets);
publicKey = host.ssh.pubkey;
})
(filterAttrs (_: host: host.ssh.pubkey != null) cfg.hosts);
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 (cfg.dns.search-domain != null &&
hasAttr cfg.dns.search-domain host.nets) {
nets."" = host.nets.${cfg.dns.search-domain} // {
aliases = [host.name];
addrs = [];
};
}))
config.krebs.hosts)));
2015-08-16 23:58:02 +02:00
}
2015-07-24 21:38:41 +02:00
];
in out