From 050b449242410ae046cae86468b447ed03243093 Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Sun, 22 Sep 2024 15:49:14 +1000 Subject: [PATCH] modules/nixos: add cgroups and exporter --- flake.nix | 1 + hosts/build03/default.nix | 1 + hosts/build04/default.nix | 1 + modules/nixos/cgroups.nix | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 modules/nixos/cgroups.nix diff --git a/flake.nix b/flake.nix index 3777ffb44..86a1c7758 100644 --- a/flake.nix +++ b/flake.nix @@ -160,6 +160,7 @@ flake.nixosModules = { buildbot = ./modules/nixos/buildbot.nix; builder = ./modules/nixos/builder.nix; + cgroups = ./modules/nixos/cgroups.nix; community-builder = ./modules/nixos/community-builder; disko-zfs = ./modules/nixos/disko-zfs.nix; github-org-backup = ./modules/nixos/github-org-backup.nix; diff --git a/hosts/build03/default.nix b/hosts/build03/default.nix index 17e984bc1..84a5ec20d 100644 --- a/hosts/build03/default.nix +++ b/hosts/build03/default.nix @@ -6,6 +6,7 @@ inputs.self.nixosModules.disko-zfs inputs.self.nixosModules.buildbot inputs.self.nixosModules.builder + inputs.self.nixosModules.cgroups inputs.self.nixosModules.hercules-ci inputs.self.nixosModules.watch-store ./builders.nix diff --git a/hosts/build04/default.nix b/hosts/build04/default.nix index c270f6fb1..337c5d5c6 100644 --- a/hosts/build04/default.nix +++ b/hosts/build04/default.nix @@ -4,6 +4,7 @@ inputs.srvos.nixosModules.hardware-hetzner-online-arm inputs.self.nixosModules.disko-zfs inputs.self.nixosModules.builder + inputs.self.nixosModules.cgroups inputs.self.nixosModules.hercules-ci inputs.self.nixosModules.remote-builder ]; diff --git a/modules/nixos/cgroups.nix b/modules/nixos/cgroups.nix new file mode 100644 index 000000000..1e3bf99ca --- /dev/null +++ b/modules/nixos/cgroups.nix @@ -0,0 +1,33 @@ +{ + config, + inputs, + pkgs, + ... +}: +{ + imports = [ + inputs.cgroup-exporter.nixosModules.default + ]; + + services.prometheus.exporters.cgroup.enable = true; + + services.telegraf.extraConfig.inputs.prometheus.urls = [ + "http://localhost:${toString config.services.prometheus.exporters.cgroup.port}/metrics" + ]; + + nix = { + package = pkgs.nixVersions.nix_2_25; + + settings = { + experimental-features = [ + "auto-allocate-uids" + "cgroups" + ]; + + extra-system-features = [ "uid-range" ]; + + auto-allocate-uids = true; + use-cgroups = true; + }; + }; +}