aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/virtualisation/ecs-agent.nix')
-rw-r--r--nixpkgs/nixos/modules/virtualisation/ecs-agent.nix46
1 files changed, 46 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix b/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
new file mode 100644
index 00000000000..fc51b159579
--- /dev/null
+++ b/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
@@ -0,0 +1,46 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+ cfg = config.services.ecs-agent;
+in {
+ options.services.ecs-agent = {
+ enable = mkEnableOption "Amazon ECS agent";
+
+ package = mkOption {
+ type = types.path;
+ description = "The ECS agent package to use";
+ default = pkgs.ecs-agent;
+ defaultText = "pkgs.ecs-agent";
+ };
+
+ extra-environment = mkOption {
+ type = types.attrsOf types.str;
+ description = "The environment the ECS agent should run with. See the ECS agent documentation for keys that work here.";
+ default = {};
+ };
+ };
+
+ config = lib.mkIf cfg.enable {
+ # This service doesn't run if docker isn't running, and unlike potentially remote services like e.g., postgresql, docker has
+ # to be running locally so `docker.enable` will always be set if the ECS agent is enabled.
+ virtualisation.docker.enable = true;
+
+ systemd.services.ecs-agent = {
+ inherit (cfg.package.meta) description;
+ after = [ "network.target" ];
+ wantedBy = [ "multi-user.target" ];
+
+ environment = cfg.extra-environment;
+
+ script = ''
+ if [ ! -z "$ECS_DATADIR" ]; then
+ mkdir -p "$ECS_DATADIR"
+ fi
+ ${cfg.package.bin}/bin/agent
+ '';
+ };
+ };
+}
+