summary refs log tree commit diff
path: root/nixos/modules/virtualisation/containers.nix
diff options
context:
space:
mode:
authordanbst <abcz2.uprola@gmail.com>2019-06-05 02:55:30 +0300
committerdanbst <abcz2.uprola@gmail.com>2019-06-05 03:11:09 +0300
commitf7940bb95d1b88f17fb42cc13b98b660cec8aee4 (patch)
tree55ea9bcb2d53a58e194f58eaf0d0876f07c7c716 /nixos/modules/virtualisation/containers.nix
parentbfb6ef1d59338e07f94f395cc56c98c116987c3d (diff)
downloadnixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar.gz
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar.bz2
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar.lz
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar.xz
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.tar.zst
nixpkgs-f7940bb95d1b88f17fb42cc13b98b660cec8aee4.zip
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
```
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r--nixos/modules/virtualisation/containers.nix32
1 files changed, 18 insertions, 14 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index d10c4feecb4..9069bfb77ea 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -465,20 +465,24 @@ in
                 merge = loc: defs: (import ../../lib/eval-config.nix {
                   inherit system;
                   modules =
-                    let extraConfig =
-                      { boot.isContainer = true;
-                        networking.hostName = mkDefault name;
-                        networking.useDHCP = false;
-                        assertions = [
-                          {
-                            assertion =  config.privateNetwork -> stringLength name < 12;
-                            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
-                            '';
-                          }
-                        ];
+                    let
+                      extraConfig = {
+                        _file = "module at ${__curPos.file}:${toString __curPos.line}";
+                        config = {
+                          boot.isContainer = true;
+                          networking.hostName = mkDefault name;
+                          networking.useDHCP = false;
+                          assertions = [
+                            {
+                              assertion =  config.privateNetwork -> stringLength name < 12;
+                              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);
                   prefix = [ "containers" name ];