git.iko.soy/typeable/nixpkgs
on master help sign in
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 ```

commitf7940bb95d1b88f17fb42cc13b98b660cec8aee4 authordanbst <abcz2.uprola@gmail.com> dateWed 5 Jun 2019, 02:55 (7 years ago) parentbfb6ef1
1 file changed+18−14
nixos/modules/virtualisation/containers.nix+18−14
nixos/modules/virtualisation/containers.nix+18−14
@@ -465,20 +465,24 @@ in
465465 merge = loc: defs: (import ../../lib/eval-config.nix {
466466 inherit system;
467467 modules =
468− let extraConfig =
469− { boot.isContainer = true;
470− networking.hostName = mkDefault name;
471− networking.useDHCP = false;
472− assertions = [
473− {
474− assertion = config.privateNetwork -> stringLength name < 12;
475− message = ''
476− Container name `${name}` is too long: When `privateNetwork` is enabled, container names can
477− not be longer than 11 characters, because the container's interface name is derived from it.
478− This might be fixed in the future. See https://github.com/NixOS/nixpkgs/issues/38509
479− '';
480− }
481− ];
468+ let
469+ extraConfig = {
470+ _file = "module at ${__curPos.file}:${toString __curPos.line}";
471+ config = {
472+ boot.isContainer = true;
473+ networking.hostName = mkDefault name;
474+ networking.useDHCP = false;
475+ assertions = [
476+ {
477+ assertion = config.privateNetwork -> stringLength name < 12;
478+ message = ''
479+ Container name `${name}` is too long: When `privateNetwork` is enabled, container names can
480+ not be longer than 11 characters, because the container's interface name is derived from it.
481+ This might be fixed in the future. See https://github.com/NixOS/nixpkgs/issues/38509
482+ '';
483+ }
484+ ];
485+ };
482486 };
483487 in [ extraConfig ] ++ (map (x: x.value) defs);
484488 prefix = [ "containers" name ];