Add default network with name = project.name
This commit is contained in:
parent
ca785e548b
commit
037c87837f
3 changed files with 49 additions and 8 deletions
|
@ -22,6 +22,30 @@ Attribute set that will be turned into the docker-compose.yaml file, using Nix's
|
|||
Type:: attribute set
|
||||
No Default:: {blank}
|
||||
|
||||
No Example:: {blank}
|
||||
|
||||
== enableDefaultNetwork
|
||||
|
||||
Whether to define the default network:
|
||||
|
||||
```nix
|
||||
networks.default = {
|
||||
name = config.project.name;
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
[discrete]
|
||||
=== details
|
||||
|
||||
Type:: boolean
|
||||
Default::
|
||||
+
|
||||
----
|
||||
true
|
||||
----
|
||||
|
||||
|
||||
No Example:: {blank}
|
||||
|
||||
== host.nixStorePrefix
|
||||
|
@ -79,12 +103,7 @@ See link:https://docs.docker.com/compose/compose-file/#networks-top-level-elemen
|
|||
=== details
|
||||
|
||||
Type:: lazy attribute set of submodules
|
||||
Default::
|
||||
+
|
||||
----
|
||||
{}
|
||||
----
|
||||
|
||||
No Default:: {blank}
|
||||
|
||||
No Example:: {blank}
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
"networks": {},
|
||||
"networks": {
|
||||
"default": {
|
||||
"name": "unit-test-data"
|
||||
}
|
||||
},
|
||||
"services": {
|
||||
"webserver": {
|
||||
"command": [
|
||||
|
|
|
@ -21,13 +21,31 @@ in
|
|||
description = ''
|
||||
${dockerComposeRef "networks-top-level-element"}
|
||||
'';
|
||||
default = {};
|
||||
};
|
||||
enableDefaultNetwork = mkOption {
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to define the default network:
|
||||
|
||||
```nix
|
||||
networks.default = {
|
||||
name = config.project.name;
|
||||
};
|
||||
```
|
||||
'';
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = {
|
||||
|
||||
networks = optionalAttrs config.enableDefaultNetwork {
|
||||
default = {
|
||||
name = config.project.name;
|
||||
};
|
||||
};
|
||||
|
||||
docker-compose.raw.networks =
|
||||
lib.mapAttrs (k: v: v.out) config.networks;
|
||||
|
||||
|
|
Loading…
Reference in a new issue