mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-14 15:36:47 +03:00
0a37316d6c
This commit replaces a lot of usages of `mkOption` with the package type, to be `mkPackageOption`, in order to reduce the amount of code.
41 lines
1.1 KiB
Nix
41 lines
1.1 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 = mkPackageOption 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
|
|
'';
|
|
};
|
|
};
|
|
}
|