From a5deef685a63974d9e78329e5d8f129891ca60de Mon Sep 17 00:00:00 2001 From: yvt Date: Sat, 21 Sep 2019 02:33:50 +0900 Subject: [PATCH 1/9] maintainer: Add yvt --- maintainers/maintainer-list.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 3cb0cd3fa99d..bb27e1108445 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -7064,6 +7064,11 @@ githubId = 1866448; name = "Eric Bailey"; }; + yvt = { + email = "i@yvt.jp"; + github = "yvt"; + name = "yvt"; + }; z77z = { email = "maggesi@math.unifi.it"; github = "maggesi"; From 5ef5852b30aa775d6b17e5895c7df917de472477 Mon Sep 17 00:00:00 2001 From: yvt Date: Sat, 21 Sep 2019 03:00:41 +0900 Subject: [PATCH 2/9] do-agent: init at 3.5.6 --- pkgs/servers/monitoring/do-agent/default.nix | 31 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 pkgs/servers/monitoring/do-agent/default.nix diff --git a/pkgs/servers/monitoring/do-agent/default.nix b/pkgs/servers/monitoring/do-agent/default.nix new file mode 100644 index 000000000000..b1b3160bc5b2 --- /dev/null +++ b/pkgs/servers/monitoring/do-agent/default.nix @@ -0,0 +1,31 @@ +{ lib, buildGoModule, fetchFromGitHub }: + +buildGoModule rec { + name = "do-agent-${version}"; + version = "3.5.6"; + + src = fetchFromGitHub { + owner = "digitalocean"; + repo = "do-agent"; + rev = "${version}"; + sha256 = "1gl034cslqa30fqy2p9rymgx398s1rcgbmfvzk5zjlrw47327k8i"; + }; + + buildFlagsArray = '' + -ldflags= + -X main.version=${version} + ''; + + modSha256 = "0ydjwxdkcz0blpzwapiaq66vh7nrcg4j91z6h7v4ynnw2rgp7pmy"; + + meta = with lib; { + description = '' + Collects system metrics from a DigitalOcean Droplet (on which the program + runs) and sends them to DigitalOcean + ''; + homepage = https://github.com/digitalocean/do-agent; + license = licenses.asl20; + maintainers = with maintainers; [ yvt ]; + platforms = platforms.linux; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 30944855831d..51f4ad7a3f91 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14581,6 +14581,8 @@ in dkimproxy = callPackage ../servers/mail/dkimproxy { }; + do-agent = callPackage ../servers/monitoring/do-agent { }; + dovecot = callPackage ../servers/mail/dovecot { }; dovecot_pigeonhole = callPackage ../servers/mail/dovecot/plugins/pigeonhole { }; From 832ede6514d2242e93085c0eda0e065c66bdd262 Mon Sep 17 00:00:00 2001 From: yvt Date: Sat, 21 Sep 2019 03:00:48 +0900 Subject: [PATCH 3/9] nixos/do-agent: init --- nixos/modules/module-list.nix | 1 + .../modules/services/monitoring/do-agent.nix | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 nixos/modules/services/monitoring/do-agent.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index fb8453f1d537..d25836c2d8dc 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -502,6 +502,7 @@ ./services/monitoring/das_watchdog.nix ./services/monitoring/datadog-agent.nix ./services/monitoring/dd-agent/dd-agent.nix + ./services/monitoring/do-agent.nix ./services/monitoring/fusion-inventory.nix ./services/monitoring/grafana.nix ./services/monitoring/grafana-reporter.nix diff --git a/nixos/modules/services/monitoring/do-agent.nix b/nixos/modules/services/monitoring/do-agent.nix new file mode 100644 index 000000000000..a03c33303481 --- /dev/null +++ b/nixos/modules/services/monitoring/do-agent.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.do-agent; +in +{ + options.services.do-agent = { + enable = mkEnableOption "do-agent, the DigitalOcean droplet metrics agent"; + + user = mkOption { + type = types.str; + default = "do-agent"; + description = "User account under which do-agent runs."; + }; + + group = mkOption { + type = types.str; + default = "do-agent"; + description = "Group account under which do-agent runs."; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.do-agent ]; + + systemd.services.do-agent = { + description = "DigitalOcean Droplet Metrics Agent"; + wantedBy = [ "multi-user.target" ]; + after = [ "network.target" ]; + serviceConfig = { + ExecStart = "${pkgs.do-agent}/bin/do-agent --syslog"; + Restart = "always"; + OOMScoreAdjust = -900; + SyslogIdentifier = "DigitalOceanAgent"; + PrivateTmp = "yes"; + ProtectSystem = "full"; + ProtectHome = "yes"; + NoNewPrivileges = "yes"; + }; + }; + + users.users = optionalAttrs (cfg.user == "do-agent") (singleton + { name = "do-agent"; + group = cfg.group; + }); + + users.groups = optionalAttrs (cfg.group == "do-agent") (singleton + { name = "do-agent"; + }); + }; +} From 74e1d473ede1447dc31530bc9dcbccfd29776e29 Mon Sep 17 00:00:00 2001 From: yvt Date: Mon, 23 Sep 2019 17:17:58 +0900 Subject: [PATCH 4/9] do-agent: Use pname instead of name --- pkgs/servers/monitoring/do-agent/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/monitoring/do-agent/default.nix b/pkgs/servers/monitoring/do-agent/default.nix index b1b3160bc5b2..025aa2024d0d 100644 --- a/pkgs/servers/monitoring/do-agent/default.nix +++ b/pkgs/servers/monitoring/do-agent/default.nix @@ -1,7 +1,7 @@ { lib, buildGoModule, fetchFromGitHub }: buildGoModule rec { - name = "do-agent-${version}"; + pname = "do-agent"; version = "3.5.6"; src = fetchFromGitHub { From 1745ab38a0189299f15d0b31a9d1ddf85d871d50 Mon Sep 17 00:00:00 2001 From: yvt Date: Mon, 23 Sep 2019 17:22:22 +0900 Subject: [PATCH 5/9] nixos/do-agent: Update description --- pkgs/servers/monitoring/do-agent/default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/servers/monitoring/do-agent/default.nix b/pkgs/servers/monitoring/do-agent/default.nix index 025aa2024d0d..9a180b24383d 100644 --- a/pkgs/servers/monitoring/do-agent/default.nix +++ b/pkgs/servers/monitoring/do-agent/default.nix @@ -19,9 +19,11 @@ buildGoModule rec { modSha256 = "0ydjwxdkcz0blpzwapiaq66vh7nrcg4j91z6h7v4ynnw2rgp7pmy"; meta = with lib; { - description = '' - Collects system metrics from a DigitalOcean Droplet (on which the program - runs) and sends them to DigitalOcean + description = "DigitalOcean droplet system metrics agent"; + longDescription = '' + do-agent is a program provided by DigitalOcean that collects system + metrics from a DigitalOcean Droplet (on which the program runs) and sends + them to DigitalOcean to provide resource usage graphs and alerting. ''; homepage = https://github.com/digitalocean/do-agent; license = licenses.asl20; From 4fd8034b7df499b444542a278576259a69b74962 Mon Sep 17 00:00:00 2001 From: yvt Date: Tue, 24 Sep 2019 17:52:52 +0900 Subject: [PATCH 6/9] do-agent: Fix modSha256 --- pkgs/servers/monitoring/do-agent/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/monitoring/do-agent/default.nix b/pkgs/servers/monitoring/do-agent/default.nix index 9a180b24383d..572535b7fcd0 100644 --- a/pkgs/servers/monitoring/do-agent/default.nix +++ b/pkgs/servers/monitoring/do-agent/default.nix @@ -16,7 +16,7 @@ buildGoModule rec { -X main.version=${version} ''; - modSha256 = "0ydjwxdkcz0blpzwapiaq66vh7nrcg4j91z6h7v4ynnw2rgp7pmy"; + modSha256 = "164bwqg996097db399j7lar6gj9xpshjdmyapvzg7zh655xlkf3d"; meta = with lib; { description = "DigitalOcean droplet system metrics agent"; From b1acc7dc8b4ce7e80dc48c9cb1c5522de982d1e2 Mon Sep 17 00:00:00 2001 From: yvt Date: Thu, 3 Oct 2019 01:09:27 +0900 Subject: [PATCH 7/9] maintainer: Set githubId of yvt --- maintainers/maintainer-list.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index bb27e1108445..d43613e67e02 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -7067,6 +7067,7 @@ yvt = { email = "i@yvt.jp"; github = "yvt"; + githubId = 5253988; name = "yvt"; }; z77z = { From e3c1ecf11155902c59909bc3862536f474d00b1e Mon Sep 17 00:00:00 2001 From: yvt Date: Thu, 3 Oct 2019 01:30:41 +0900 Subject: [PATCH 8/9] nixos/do-agent: Use DynamicUser --- .../modules/services/monitoring/do-agent.nix | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/nixos/modules/services/monitoring/do-agent.nix b/nixos/modules/services/monitoring/do-agent.nix index a03c33303481..a9471994e327 100644 --- a/nixos/modules/services/monitoring/do-agent.nix +++ b/nixos/modules/services/monitoring/do-agent.nix @@ -8,18 +8,6 @@ in { options.services.do-agent = { enable = mkEnableOption "do-agent, the DigitalOcean droplet metrics agent"; - - user = mkOption { - type = types.str; - default = "do-agent"; - description = "User account under which do-agent runs."; - }; - - group = mkOption { - type = types.str; - default = "do-agent"; - description = "Group account under which do-agent runs."; - }; }; config = mkIf cfg.enable { @@ -38,16 +26,8 @@ in ProtectSystem = "full"; ProtectHome = "yes"; NoNewPrivileges = "yes"; + DynamicUser = "yes"; }; }; - - users.users = optionalAttrs (cfg.user == "do-agent") (singleton - { name = "do-agent"; - group = cfg.group; - }); - - users.groups = optionalAttrs (cfg.group == "do-agent") (singleton - { name = "do-agent"; - }); }; } From 00a54207e01a27c60814828ac8f464f1d2c80c58 Mon Sep 17 00:00:00 2001 From: yvt Date: Thu, 3 Oct 2019 02:44:33 +0900 Subject: [PATCH 9/9] nixos/do-agent: Depend on network-online.target --- nixos/modules/services/monitoring/do-agent.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/monitoring/do-agent.nix b/nixos/modules/services/monitoring/do-agent.nix index a9471994e327..2d3fe2f79768 100644 --- a/nixos/modules/services/monitoring/do-agent.nix +++ b/nixos/modules/services/monitoring/do-agent.nix @@ -16,7 +16,8 @@ in systemd.services.do-agent = { description = "DigitalOcean Droplet Metrics Agent"; wantedBy = [ "multi-user.target" ]; - after = [ "network.target" ]; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; serviceConfig = { ExecStart = "${pkgs.do-agent}/bin/do-agent --syslog"; Restart = "always";