diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2020-04-13 17:43:44 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2020-04-13 17:50:13 +0200 |
commit | ec6bac99cc3c7094ea9fa3d1eff2764be245e861 (patch) | |
tree | c5a79629cdd9cffe9e48416d8d7ece64efe4ae7b | |
parent | 6f6d2124fc890c41c7aaf0bee50f386866d30c15 (diff) |
nixos/build-vms: propagate file location
When trying to build a VM using `nixos-build-vms` with a configuration
that doesn't evaluate, an error "at `<unknown-file>`" is usually shown.
This happens since the `build-vms.nix` creates a VM-network of
NixOS-configurations that are attr-sets or functions and don't contain
any file information. This patch manually adds the `_file`-attribute to
tell the module-system which file contained broken configuration:
```
$ cat vm.nix
{ vm.invalid-option = 1; }
$ nixos-build-vms vm.nix
error: The option `invalid-option' defined in `/home/ma27/Projects/nixpkgs/vm.nix@node-vm' does not exist.
(use '--show-trace' to show detailed location information)
```
-rw-r--r-- | nixos/modules/installer/tools/nixos-build-vms/build-vms.nix | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix b/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix index 90f0702f7173..0c9f8522cc12 100644 --- a/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix +++ b/nixos/modules/installer/tools/nixos-build-vms/build-vms.nix @@ -3,7 +3,12 @@ , networkExpr }: -let nodes = import networkExpr; in +let + nodes = builtins.mapAttrs (vm: module: { + _file = "${networkExpr}@node-${vm}"; + imports = [ module ]; + }) (import networkExpr); +in with import ../../../../lib/testing-python.nix { inherit system; |