Skip to content

Commit

Permalink
nixos/build-vms: propagate file location
Browse files Browse the repository at this point in the history
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)
```
  • Loading branch information
Ma27 committed Apr 13, 2020
1 parent 6f6d212 commit ec6bac9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion nixos/modules/installer/tools/nixos-build-vms/build-vms.nix
Expand Up @@ -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;
Expand Down

0 comments on commit ec6bac9

Please sign in to comment.