]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/system/monitoring-1.nix
Remove netdata stream key from the store
[perso/Immae/Config/Nix.git] / modules / private / system / monitoring-1.nix
CommitLineData
e820134d
IB
1{ privateFiles }:
2{ config, pkgs, resources, ... }:
3{
34abd6af
IB
4 deployment = {
5 targetUser = "root";
6 targetHost = config.hostEnv.ips.main.ip4;
7 substituteOnDestination = true;
8 };
e820134d
IB
9 boot.kernelPackages = pkgs.linuxPackages_latest;
10 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
e820134d 11
34abd6af 12 imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ] ++ builtins.attrValues (import ../..);
e820134d
IB
13
14 myServices.monitoring.enable = true;
15 myServices.monitoring.master = true;
16 myServices.status.enable = true;
17 networking = {
18 firewall.enable = true;
19 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
20 (n: ips: { address = ips.ip4; prefixLength = 32; })
619e4f46 21 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
e820134d
IB
22 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
23 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
619e4f46 24 config.hostEnv.ips);
e820134d
IB
25 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
26 };
34abd6af
IB
27 boot.loader.grub.device = "nodev";
28 fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
e820134d
IB
29 myServices.mailRelay.enable = true;
30
171d8e1a
IB
31 security.pki.certificateFiles = [
32 (pkgs.fetchurl {
33 url = "http://downloads.e.eriomem.net/eriomemca.pem";
34 sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
35 })
36 ];
37
e43fdf34
IB
38 services.netdata.enable = true;
39 services.netdata.config.web."allow dashboard from" = "localhost";
40 services.netdata.config.web."allow badges from" = "*";
41 services.netdata.config.web."allow streaming from" = "*";
42 services.netdata.config.web."allow netdata.conf from" = "fd*";
43 services.netdata.config.web."allow management from" = "fd*";
44 networking.firewall.allowedTCPPorts = [ 19999 ];
0e374709
IB
45 environment.etc."netdata/stream.conf".source = "/var/secrets/netdata-stream.conf";
46
47 secrets.keys = [
48 {
49 dest = "netdata-stream.conf";
50 user = config.services.netdata.user;
51 group = config.services.netdata.group;
52 permissions = "0400";
53 text = builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (_: key: ''
54 [${key}]
55 enabled = yes
56 default history = 3600
57 default memory = ram
58 health enabled by default = auto
59 '') config.myEnv.monitoring.netdata_keys);
60 }
61 ];
62 users.users."${config.services.netdata.user}".extraGroups = [ "keys" ];
e820134d
IB
63 # This value determines the NixOS release with which your system is
64 # to be compatible, in order to avoid breaking some software such as
65 # database servers. You should change this only after NixOS release
66 # notes say you should.
67 # https://nixos.org/nixos/manual/release-notes.html
d43e0c61 68 system.stateVersion = "20.03"; # Did you read the comment?
e820134d 69}