at 24.11-pre 1.1 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let 6 cfg = config.services.ecs-agent; 7in { 8 options.services.ecs-agent = { 9 enable = mkEnableOption "Amazon ECS agent"; 10 11 package = mkPackageOption pkgs "ecs-agent" { }; 12 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."; 16 default = {}; 17 }; 18 }; 19 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; 24 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 mkdir -p "$ECS_DATADIR" 35 fi 36 ${cfg.package}/bin/agent 37 ''; 38 }; 39 }; 40}