-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.nix
63 lines (59 loc) · 1.58 KB
/
server.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{
host,
inputs,
...
}: let
# allows value to overwrite enabled when specified explicitly
defaultEnabled = builtins.mapAttrs (_: lib.mergeAttrs {enable = true;});
inherit (inputs.nixpkgs) lib;
in {
mkServer = services:
host.mkBase [
({lib, ...}: {
options.stylix = lib.mkOption {
description = "placeholder module";
type = lib.types.anything;
default = null;
};
})
({lib, ...}: {
config = {
documentation.enable = false;
zramSwap = {
enable = true;
algorithm = "zstd";
};
boot.kernel.sysctl = {
"vm.swappiness" = 180;
"vm.page-cluster" = 0;
};
phil = {
# enable networking by default
# TODO replace with headscale
# nebula.enable = lib.mkDefault true;
# no need for these on a server
sound.enable = false;
video.enable = false;
yubikey.enable = false;
server = let
defaults = [
"openssh"
"fail2ban"
#"telegraf"
#"vector"
"iperf"
];
in {
enable = true;
services = builtins.foldl' lib.mergeAttrs {} (map
(service:
if builtins.isAttrs service
then defaultEnabled service
else {"${service}".enable = true;})
(defaults ++ services));
};
};
};
})
];
}