aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
diff options
context:
space:
mode:
authorMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
committerMx Kookie <kookie@spacekookie.de>2020-10-31 19:35:09 +0100
commitc4625b175f8200f643fd6e11010932ea44c78433 (patch)
treebce3f89888c8ac3991fa5569a878a9eab6801ccc /infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
parent49f735974dd103039ddc4cb576bb76555164a9e7 (diff)
parentd661aa56a8843e991261510c1bb28fdc2f6975ae (diff)
Add 'infra/libkookie/' from commit 'd661aa56a8843e991261510c1bb28fdc2f6975ae'
git-subtree-dir: infra/libkookie git-subtree-mainline: 49f735974dd103039ddc4cb576bb76555164a9e7 git-subtree-split: d661aa56a8843e991261510c1bb28fdc2f6975ae
Diffstat (limited to 'infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix')
-rw-r--r--infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix45
1 files changed, 45 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix b/infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
new file mode 100644
index 000000000000..93fefe56d1a5
--- /dev/null
+++ b/infra/libkookie/nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
@@ -0,0 +1,45 @@
+{ 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/agent
+ '';
+ };
+ };
+}