Make the service name available to the service config

This commit is contained in:
Robert Hensing 2019-03-11 14:44:18 +01:00
parent 6fd435c38e
commit 00f7b3e711
4 changed files with 12 additions and 3 deletions

View file

@ -61,7 +61,7 @@ let
declarations = map (d: "src/nix" + (lib.strings.removePrefix (toString ${src}) (toString d))) opt.declarations;
};
inherit (pkgs) lib;
composition = pkgs.callPackage ${src}/eval-service.nix {} { modules = []; host = {}; };
composition = pkgs.callPackage ${src}/eval-service.nix {} { modules = []; host = {}; name = abort "The manual's service options section must not depend on the service name."; };
in map fixPaths (lib.filter (opt: opt.visible && !opt.internal) (lib.optionAttrSetToDocList composition.options))
'';
};

View file

@ -1,6 +1,6 @@
{ lib, pkgs, ... }:
{ modules, host }:
{ modules, host, name }:
let
composite = lib.evalModules {
check = true;
@ -21,6 +21,7 @@ let
key = ./docker-compose.nix;
config._module.args.pkgs = lib.mkForce pkgs;
config.host = host;
config.service.name = name;
};
in

View file

@ -11,7 +11,7 @@
*/
{ pkgs, lib, config, ... }:
let
evalService = name: modules: (pkgs.callPackage ../../eval-service.nix {} { inherit modules; inherit (config) host; }).config.build.service;
evalService = name: modules: (pkgs.callPackage ../../eval-service.nix {} { inherit name modules; inherit (config) host; }).config.build.service;
in
{

View file

@ -33,6 +33,14 @@ in
'';
};
service.name = mkOption {
type = str;
description = ''
The name of the service - <code>&lt;name></code> in the composition-level <code>docker-compose.services.&lt;name></code>
'';
readOnly = true;
};
service.volumes = mkOption {
type = listOf types.unspecified;
default = [];