From ed2d58c8bd2e11f78284ba4c761eab3753ef03f8 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 11 Mar 2019 14:55:55 +0100 Subject: [PATCH] Add read-only option docker-compose.evaluatedServices --- src/arion | 2 +- src/nix/modules/composition/docker-compose.nix | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/arion b/src/arion index 15eab98..27f49c0 100755 --- a/src/arion +++ b/src/arion @@ -184,7 +184,7 @@ To get started: To see deployment-wide configuration type config. and hit TAB To see the services - type config.docker-compose.services TAB or ENTER + type config.docker-compose.evaluatedServices TAB or ENTER To bring the top-level Nixpkgs attributes into scope type :a (config._module.args.pkgs) // { inherit config; } diff --git a/src/nix/modules/composition/docker-compose.nix b/src/nix/modules/composition/docker-compose.nix index 6f0d2d8..3ec39a6 100644 --- a/src/nix/modules/composition/docker-compose.nix +++ b/src/nix/modules/composition/docker-compose.nix @@ -11,7 +11,7 @@ */ { pkgs, lib, config, ... }: let - evalService = name: modules: (pkgs.callPackage ../../eval-service.nix {} { inherit name modules; inherit (config) host; }).config.build.service; + evalService = name: modules: pkgs.callPackage ../../eval-service.nix {} { inherit name modules; inherit (config) host; }; in { @@ -33,14 +33,20 @@ in type = with lib.types; attrsOf (coercedTo unspecified (a: [a]) (listOf unspecified)); description = "A attribute set of service configurations. A service specifies how to run an image. Each of these service configurations is specified using modules whose options are described in the Service Options section."; }; + docker-compose.evaluatedServices = lib.mkOption { + type = lib.types.attrsOf lib.types.attrs; + description = "Attribute set of evaluated service configurations."; + readOnly = true; + }; }; config = { build.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" config.build.dockerComposeYamlText; build.dockerComposeYamlText = builtins.toJSON (config.docker-compose.raw); + docker-compose.evaluatedServices = lib.mapAttrs evalService config.docker-compose.services; docker-compose.raw = { version = "3"; - services = lib.mapAttrs evalService config.docker-compose.services; + services = lib.mapAttrs (k: c: c.config.build.service) config.docker-compose.evaluatedServices; }; }; }