1
0
Fork 0

Compare commits

..

No commits in common. "e49d13d8e82d6d19a765a2a3107e1c5a169c5e1d" and "fe3fa8fb064ad307dbb1e78d63be183f1765db57" have entirely different histories.

7 changed files with 49 additions and 116 deletions

View file

@ -234,11 +234,11 @@
"nix-secrets": {
"flake": false,
"locked": {
"lastModified": 1724432746,
"narHash": "sha256-s7XsY4ZsS9jyzZWpXOJNVzc03SNQbALM+S28QKXc8co=",
"lastModified": 1723838364,
"narHash": "sha256-L1KajQACN1256oVG//QPXWuVbuzxlSAlOjXT67i6c0Q=",
"ref": "refs/heads/main",
"rev": "56ccf5bf3f4d8687dc22c390cdafe20c08a7e549",
"revCount": 60,
"rev": "d57c296dab0ec1e7c6f28c7741d9a591b35117da",
"revCount": 59,
"type": "git",
"url": "file:./nix-secrets"
},

View file

@ -87,11 +87,19 @@
in
{
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
nixosConfigurations = {
Dimaga = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
# Add unstable repo
specialArgs = {
pkgs-unstable = import nixpkgs-unstable {
system = "x86_64-linux";
config.allowUnfree = true;
};
};
modules = defaultModules ++ [
nixos-hardware.nixosModules.common-cpu-intel
./hosts/Dimaga

View file

@ -173,12 +173,10 @@ in
netdata = {
enable = true;
domain = config.secrets.networking.primaryDomain;
type = "parent";
url = config.secrets.services.netdata.url;
auth = {
user = config.users.users.aires.name;
password = config.secrets.services.netdata.password;
apiKey = config.secrets.services.netdata.apiKey;
};
};
nginx = {

View file

@ -66,12 +66,6 @@ in
onCalendar = "daily";
user = config.users.users.aires.name;
};
netdata = {
enable = true;
type = "child";
url = config.secrets.services.netdata.url;
auth.apiKey = config.secrets.services.netdata.apiKey;
};
# Install virtual machine management tools
virtualization = {
enable = true;

View file

@ -1,10 +1,5 @@
# Modules common to all systems
{
pkgs,
config,
inputs,
...
}:
{ pkgs, config, ... }:
{
config = {
@ -19,16 +14,6 @@
];
};
# Allow packages from the unstable repo by using 'pkgs.unstable'
nixpkgs.overlays = [
(final: _prev: {
unstable = import inputs.nixpkgs-unstable {
system = final.system;
config.allowUnfree = true;
};
})
];
programs = {
# Enable NH, an alternative nixos-rebuild frontend.
nh = {

View file

@ -1,5 +1,6 @@
{
pkgs,
pkgs-unstable,
config,
lib,
...
@ -22,11 +23,6 @@ in
type = lib.types.str;
description = "Password for basic auth.";
};
apiKey = lib.mkOption {
default = "";
type = lib.types.str;
description = "API key for streaming data from a child to a parent.";
};
};
domain = lib.mkOption {
default = "";
@ -34,15 +30,6 @@ in
description = "The root domain that Netdata will be hosted on.";
example = "example.com";
};
type = lib.mkOption {
default = "parent";
type = lib.types.enum [
"parent"
"child"
];
description = "Whether this is a parent (default: includes web UI) or child (no web UI - streaming only).";
example = "child";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
@ -52,15 +39,8 @@ in
};
};
config = lib.mkMerge [
(lib.mkIf cfg.enable {
services.netdata = {
enable = true;
package = pkgs.unstable.netdataCloud;
enableAnalyticsReporting = false;
};
})
(lib.mkIf (cfg.type == "parent") {
config = lib.mkIf cfg.enable {
services = {
nginx.virtualHosts."${cfg.url}" = {
useACMEHost = cfg.domain;
@ -83,50 +63,18 @@ in
};
netdata = {
enable = true;
package = pkgs-unstable.netdataCloud;
enableAnalyticsReporting = false;
configDir = {
# Enable nvidia-smi: https://nixos.wiki/wiki/Netdata#nvidia-smi
"python.d.conf" = pkgs.writeText "python.d.conf" ''
nvidia_smi: yes
'';
# Allow incoming streams
"stream.conf" = pkgs.writeText "stream.conf" ''
[${config.secrets.services.netdata.apiKey}]
enabled = yes
default history = 3600
default memory mode = dbengine
health enabled by default = auto
allow streaming from = *
'';
};
};
};
systemd.services.nginx.wants = [ config.systemd.services.netdata.name ];
})
(lib.mkIf (cfg.type == "child") {
services.netdata = {
# Disable web UI
config = {
global = {
"memory mode" = "none";
};
web = {
mode = "none";
"accept a streaming request every seconds" = 0;
};
};
# Set up streaming
configDir = {
"stream.conf" = pkgs.writeText "stream.conf" ''
[stream]
enabled = yes
destination = ${cfg.url}:SSL
api key = ${cfg.auth.apiKey}
[${cfg.auth.apiKey}]
enabled = yes
'';
};
};
})
];
}

@ -1 +1 @@
Subproject commit 56ccf5bf3f4d8687dc22c390cdafe20c08a7e549
Subproject commit d57c296dab0ec1e7c6f28c7741d9a591b35117da