Add read-only option docker-compose.evaluatedServices
This commit is contained in:
parent
00f7b3e711
commit
ed2d58c8bd
2 changed files with 9 additions and 3 deletions
|
@ -184,7 +184,7 @@ To get started:
|
||||||
To see deployment-wide configuration
|
To see deployment-wide configuration
|
||||||
type config. and hit TAB
|
type config. and hit TAB
|
||||||
To see the services
|
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
|
To bring the top-level Nixpkgs attributes into scope
|
||||||
type :a (config._module.args.pkgs) // { inherit config; }
|
type :a (config._module.args.pkgs) // { inherit config; }
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
*/
|
*/
|
||||||
{ pkgs, lib, config, ... }:
|
{ pkgs, lib, config, ... }:
|
||||||
let
|
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
|
in
|
||||||
{
|
{
|
||||||
|
@ -33,14 +33,20 @@ in
|
||||||
type = with lib.types; attrsOf (coercedTo unspecified (a: [a]) (listOf unspecified));
|
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.";
|
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 = {
|
config = {
|
||||||
build.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" config.build.dockerComposeYamlText;
|
build.dockerComposeYaml = pkgs.writeText "docker-compose.yaml" config.build.dockerComposeYamlText;
|
||||||
build.dockerComposeYamlText = builtins.toJSON (config.docker-compose.raw);
|
build.dockerComposeYamlText = builtins.toJSON (config.docker-compose.raw);
|
||||||
|
|
||||||
|
docker-compose.evaluatedServices = lib.mapAttrs evalService config.docker-compose.services;
|
||||||
docker-compose.raw = {
|
docker-compose.raw = {
|
||||||
version = "3";
|
version = "3";
|
||||||
services = lib.mapAttrs evalService config.docker-compose.services;
|
services = lib.mapAttrs (k: c: c.config.build.service) config.docker-compose.evaluatedServices;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue