nixos/containers: give a name to an anonymous container module

See https://github.com/NixOS/nixpkgs/issues/15747. Previously this module was called `<unknown-file>`
in error messages, now it is called a bit more close to real:
```
module at /home/danbst/dev/nixpkgs/nixos/modules/virtualisation/containers.nix:470
```
This commit is contained in:
danbst 2019-06-05 02:55:30 +03:00
parent bfb6ef1d59
commit f7940bb95d

View file

@ -465,20 +465,24 @@ in
merge = loc: defs: (import ../../lib/eval-config.nix { merge = loc: defs: (import ../../lib/eval-config.nix {
inherit system; inherit system;
modules = modules =
let extraConfig = let
{ boot.isContainer = true; extraConfig = {
networking.hostName = mkDefault name; _file = "module at ${__curPos.file}:${toString __curPos.line}";
networking.useDHCP = false; config = {
assertions = [ boot.isContainer = true;
{ networking.hostName = mkDefault name;
assertion = config.privateNetwork -> stringLength name < 12; networking.useDHCP = false;
message = '' assertions = [
Container name `${name}` is too long: When `privateNetwork` is enabled, container names can {
not be longer than 11 characters, because the container's interface name is derived from it. assertion = config.privateNetwork -> stringLength name < 12;
This might be fixed in the future. See https://github.com/NixOS/nixpkgs/issues/38509 message = ''
''; Container name `${name}` is too long: When `privateNetwork` is enabled, container names can
} not be longer than 11 characters, because the container's interface name is derived from it.
]; This might be fixed in the future. See https://github.com/NixOS/nixpkgs/issues/38509
'';
}
];
};
}; };
in [ extraConfig ] ++ (map (x: x.value) defs); in [ extraConfig ] ++ (map (x: x.value) defs);
prefix = [ "containers" name ]; prefix = [ "containers" name ];