git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #62712 from danbst/module-conflict-naming

NixOS module system: improve one of error messages

commite718eb624301cbf1147970701ca525573bd6fc1d authorDanylo Hlynskyi <abcz2.uprola@gmail.com> dateThu 13 Jun 2019, 11:59 (7 years ago) parent8c912d4f7940bb
2 files changed+19−15
lib/options.nix+1−1 nixos/modules/virtualisation/containers.nix+18−14
lib/options.nix+1−1
@@ -101,7 +101,7 @@ rec {
101101 mergeOneOption = loc: defs:
102102 if defs == [] then abort "This case should never happen."
103103 else if length defs != 1 then
104− throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}."
104+ throw "The unique option `${showOption loc}' is defined multiple times, in:\n - ${concatStringsSep "\n - " (getFiles defs)}."
105105 else (head defs).value;
106106
107107 /* "Merge" option definitions by checking that they all have the same value. */
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 ];