summary refs log tree commit diff
path: root/nixos/modules/virtualisation/ecs-agent.nix
diff options
context:
space:
mode:
authorDan Peebles <pumpkin@me.com>2017-02-10 05:37:36 +0000
committerDan Peebles <pumpkin@me.com>2017-02-10 05:37:38 +0000
commita0ebb1497f46b9487c7148bb5528d21f81c82894 (patch)
tree9815afc2ce01615aab49ec9323f504e9e9db8be4 /nixos/modules/virtualisation/ecs-agent.nix
parent03cab2d923afec294e068a30c8bdb4a851415880 (diff)
downloadnixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar.gz
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar.bz2
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar.lz
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar.xz
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.tar.zst
nixpkgs-a0ebb1497f46b9487c7148bb5528d21f81c82894.zip
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.
Diffstat (limited to 'nixos/modules/virtualisation/ecs-agent.nix')
-rw-r--r--nixos/modules/virtualisation/ecs-agent.nix42
1 files changed, 42 insertions, 0 deletions
diff --git a/nixos/modules/virtualisation/ecs-agent.nix b/nixos/modules/virtualisation/ecs-agent.nix
new file mode 100644
index 00000000000..5e28d8379cb
--- /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
+      '';
+    };
+  };
+}
+