diff options
author | Bas van Dijk <v.dijk.bas@gmail.com> | 2020-04-20 23:53:31 +0200 |
---|---|---|
committer | Bas van Dijk <v.dijk.bas@gmail.com> | 2020-07-20 13:44:18 +0200 |
commit | d06de760f8f4a3c304addb33c372d706cc6c6c9e (patch) | |
tree | 7a0a6fc9ffe1daf182129f538e5535f76686d6a3 /nixos/modules/virtualisation | |
parent | 27296cc5c572da9a7ba35638a139a168a301ee14 (diff) | |
download | nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar.gz nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar.bz2 nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar.lz nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar.xz nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.tar.zst nixpkgs-d06de760f8f4a3c304addb33c372d706cc6c6c9e.zip |
nixos/modules/system/activation/top-level.nix: allow overriding system.name
The toplevel derivations of systems that have `networking.hostName` set to `""` (because they want their hostname to be set by DHCP) used to be all named `nixos-system-unnamed-${config.system.nixos.label}`. This makes them hard to distinguish. A similar problem existed in NixOS tests where `vmName` is used in the `testScript` to refer to the VM. It defaulted to the `networking.hostName` which when set to `""` won't allow you to refer to the machine from the `testScript`. This commit makes the `system.name` configurable. It still defaults to: ``` if config.networking.hostName == "" then "unnamed" else config.networking.hostName; ``` but in case `networking.hostName` needs to be to `""` the `system.name` can be set to a distinguishable name.
Diffstat (limited to 'nixos/modules/virtualisation')
-rw-r--r-- | nixos/modules/virtualisation/qemu-vm.nix | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/nixos/modules/virtualisation/qemu-vm.nix b/nixos/modules/virtualisation/qemu-vm.nix index 9154b0c00d7..2e5e276308d 100644 --- a/nixos/modules/virtualisation/qemu-vm.nix +++ b/nixos/modules/virtualisation/qemu-vm.nix @@ -16,11 +16,6 @@ let qemu = config.system.build.qemu or pkgs.qemu_test; - vmName = - if config.networking.hostName == "" - then "noname" - else config.networking.hostName; - cfg = config.virtualisation; consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles; @@ -156,7 +151,7 @@ let # Start QEMU. exec ${qemuBinary qemu} \ - -name ${vmName} \ + -name ${config.system.name} \ -m ${toString config.virtualisation.memorySize} \ -smp ${toString config.virtualisation.cores} \ -device virtio-rng-pci \ @@ -294,7 +289,7 @@ in virtualisation.diskImage = mkOption { - default = "./${vmName}.qcow2"; + default = "./${config.system.name}.qcow2"; description = '' Path to the disk image containing the root filesystem. @@ -712,7 +707,7 @@ in '' mkdir -p $out/bin ln -s ${config.system.build.toplevel} $out/system - ln -s ${pkgs.writeScript "run-nixos-vm" startVM} $out/bin/run-${vmName}-vm + ln -s ${pkgs.writeScript "run-nixos-vm" startVM} $out/bin/run-${config.system.name}-vm ''; # When building a regular system configuration, override whatever |