From a0ebb1497f46b9487c7148bb5528d21f81c82894 Mon Sep 17 00:00:00 2001 From: Dan Peebles Date: Fri, 10 Feb 2017 05:37:36 +0000 Subject: [PATCH] ecs-agent NixOS module: init A very simple skeleton for now that doesn't attempt to model any of the agent configuration, but we can grow it later. Tested and works on an EC2 instance with ECS. --- nixos/modules/module-list.nix | 1 + nixos/modules/virtualisation/ecs-agent.nix | 42 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 nixos/modules/virtualisation/ecs-agent.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d2d7203119a6..afaaccb01562 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -645,6 +645,7 @@ ./virtualisation/container-config.nix ./virtualisation/containers.nix ./virtualisation/docker.nix + ./virtualisation/ecs-agent.nix ./virtualisation/libvirtd.nix ./virtualisation/lxc.nix ./virtualisation/lxcfs.nix diff --git a/nixos/modules/virtualisation/ecs-agent.nix b/nixos/modules/virtualisation/ecs-agent.nix new file mode 100644 index 000000000000..5e28d8379cb0 --- /dev/null +++ b/nixos/modules/virtualisation/ecs-agent.nix @@ -0,0 +1,42 @@ +{ 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; + }; + + 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 { + 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 + echo "FOOOO" + mkdir -p "$ECS_DATADIR" + fi + ${cfg.package.bin}/bin/agent + ''; + }; + }; +} +