@@ -0,0 +1,42 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.ecs-agent;
7+in {
8+ options.services.ecs-agent = {
9+ enable = mkEnableOption "Amazon ECS agent";
10+
11+ package = mkOption {
12+ type = types.path;
13+ description = "The ECS agent package to use";
14+ default = pkgs.ecs-agent;
15+ };
16+
17+ extra-environment = mkOption {
18+ type = types.attrsOf types.str;
19+ description = "The environment the ECS agent should run with. See the ECS agent documentation for keys that work here.";
20+ default = {};
21+ };
22+ };
23+
24+ config = lib.mkIf cfg.enable {
25+ systemd.services.ecs-agent = {
26+ inherit (cfg.package.meta) description;
27+ after = [ "network.target" ];
28+ wantedBy = [ "multi-user.target" ];
29+
30+ environment = cfg.extra-environment;
31+
32+ script = ''
33+ if [ ! -z "$ECS_DATADIR" ]; then
34+ echo "FOOOO"
35+ mkdir -p "$ECS_DATADIR"
36+ fi
37+ ${cfg.package.bin}/bin/agent
38+ '';
39+ };
40+ };
41+}
42+