git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #85638 from basvandijk/virtualisation.vmName
7d061ceBas van Dijk
nixos/modules/system/activation/top-level.nix+16−3
@@ -92,9 +92,7 @@ let
92 # `switch-to-configuration' that activates the configuration and
92 # `switch-to-configuration' that activates the configuration and
93 # makes it bootable.
93 # makes it bootable.
94 baseSystem = pkgs.stdenvNoCC.mkDerivation {
94 baseSystem = pkgs.stdenvNoCC.mkDerivation {
95− name = let hn = config.networking.hostName;
96− nn = if (hn != "") then hn else "unnamed";
97− in "nixos-system-${nn}-${config.system.nixos.label}";
95+ name = "nixos-system-${config.system.name}-${config.system.nixos.label}";
98 preferLocalBuild = true;
96 preferLocalBuild = true;
99 allowSubstitutes = false;
97 allowSubstitutes = false;
100 buildCommand = systemBuilder;
98 buildCommand = systemBuilder;
@@ -265,6 +263,21 @@ in
265 '';
263 '';
266 };
264 };
267
265
266+ system.name = mkOption {
267+ type = types.str;
268+ default =
269+ if config.networking.hostName == ""
270+ then "unnamed"
271+ else config.networking.hostName;
272+ defaultText = '''networking.hostName' if non empty else "unnamed"'';
273+ description = ''
274+ The name of the system used in the <option>system.build.toplevel</option> derivation.
275+ </para><para>
276+ That derivation has the following name:
277+ <literal>"nixos-system-''${config.system.name}-''${config.system.nixos.label}"</literal>
278+ '';
279+ };
280+
268 };
281 };
269
282
270
283
nixos/modules/virtualisation/qemu-vm.nix+3−8
@@ -16,11 +16,6 @@ let
16
16
17 qemu = config.system.build.qemu or pkgs.qemu_test;
17 qemu = config.system.build.qemu or pkgs.qemu_test;
18
18
19− vmName =
20− if config.networking.hostName == ""
21− then "noname"
22− else config.networking.hostName;
23−
24 cfg = config.virtualisation;
19 cfg = config.virtualisation;
25
20
26 consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
21 consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
@@ -156,7 +151,7 @@ let
156
151
157 # Start QEMU.
152 # Start QEMU.
158 exec ${qemuBinary qemu} \
153 exec ${qemuBinary qemu} \
159− -name ${vmName} \
154+ -name ${config.system.name} \
160 -m ${toString config.virtualisation.memorySize} \
155 -m ${toString config.virtualisation.memorySize} \
161 -smp ${toString config.virtualisation.cores} \
156 -smp ${toString config.virtualisation.cores} \
162 -device virtio-rng-pci \
157 -device virtio-rng-pci \
@@ -294,7 +289,7 @@ in
294
289
295 virtualisation.diskImage =
290 virtualisation.diskImage =
296 mkOption {
291 mkOption {
297− default = "./${vmName}.qcow2";
292+ default = "./${config.system.name}.qcow2";
298 description =
293 description =
299 ''
294 ''
300 Path to the disk image containing the root filesystem.
295 Path to the disk image containing the root filesystem.
@@ -712,7 +707,7 @@ in
712 ''
707 ''
713 mkdir -p $out/bin
708 mkdir -p $out/bin
714 ln -s ${config.system.build.toplevel} $out/system
709 ln -s ${config.system.build.toplevel} $out/system
715− ln -s ${pkgs.writeScript "run-nixos-vm" startVM} $out/bin/run-${vmName}-vm
710+ ln -s ${pkgs.writeScript "run-nixos-vm" startVM} $out/bin/run-${config.system.name}-vm
716 '';
711 '';
717
712
718 # When building a regular system configuration, override whatever
713 # When building a regular system configuration, override whatever