nixpkgs/nixos/modules/virtualisation/ecs-agent.nix
pennae ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00

46 lines
1.3 KiB
Nix

{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.ecs-agent;
in {
options.services.ecs-agent = {
enable = mkEnableOption (lib.mdDoc "Amazon ECS agent");
package = mkOption {
type = types.path;
description = lib.mdDoc "The ECS agent package to use";
default = pkgs.ecs-agent;
defaultText = literalExpression "pkgs.ecs-agent";
};
extra-environment = mkOption {
type = types.attrsOf types.str;
description = lib.mdDoc "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
'';
};
};
}