1 { config, pkgs, lib, ... }:
6 cfg = config.services.ecs-agent;
8 options.services.ecs-agent = {
9 enable = mkEnableOption "Amazon ECS agent";
11 package = mkPackageOption pkgs "ecs-agent" { };
13 extra-environment = mkOption {
14 type = types.attrsOf types.str;
15 description = "The environment the ECS agent should run with. See the ECS agent documentation for keys that work here.";
20 config = lib.mkIf cfg.enable {
21 # This service doesn't run if docker isn't running, and unlike potentially remote services like e.g., postgresql, docker has
22 # to be running locally so `docker.enable` will always be set if the ECS agent is enabled.
23 virtualisation.docker.enable = true;
25 systemd.services.ecs-agent = {
26 inherit (cfg.package.meta) description;
27 after = [ "network.target" ];
28 wantedBy = [ "multi-user.target" ];
30 environment = cfg.extra-environment;
33 if [ ! -z "$ECS_DATADIR" ]; then
34 mkdir -p "$ECS_DATADIR"
36 ${cfg.package}/bin/agent