git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commita0ebb1497f46b9487c7148bb5528d21f81c82894 authorDan Peebles <pumpkin@me.com> dateFri 10 Feb 2017, 05:37 (10 years ago) parent03cab2d
2 files changed+43
nixos/modules/module-list.nix+1 nixos/modules/virtualisation/ecs-agent.nix+42
nixos/modules/module-list.nix+1
@@ -645,6 +645,7 @@
645645 ./virtualisation/container-config.nix
646646 ./virtualisation/containers.nix
647647 ./virtualisation/docker.nix
648+ ./virtualisation/ecs-agent.nix
648649 ./virtualisation/libvirtd.nix
649650 ./virtualisation/lxc.nix
650651 ./virtualisation/lxcfs.nix
nixos/modules/virtualisation/ecs-agent.nixnew file+42
@@ -0,0 +1,42 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.ecs-agent;
7+in {
8+ options.services.ecs-agent = {
9+ enable = mkEnableOption "Amazon ECS agent";
10+
11+ package = mkOption {
12+ type = types.path;
13+ description = "The ECS agent package to use";
14+ default = pkgs.ecs-agent;
15+ };
16+
17+ extra-environment = mkOption {
18+ type = types.attrsOf types.str;
19+ description = "The environment the ECS agent should run with. See the ECS agent documentation for keys that work here.";
20+ default = {};
21+ };
22+ };
23+
24+ config = lib.mkIf cfg.enable {
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+ echo "FOOOO"
35+ mkdir -p "$ECS_DATADIR"
36+ fi
37+ ${cfg.package.bin}/bin/agent
38+ '';
39+ };
40+ };
41+}
42+