Merge pull request #85638 from basvandijk/virtualisation.vmName
nixos/modules/system/activation/top-level.nix: allow overriding system.name
This commit is contained in:
commit
7d061cefb7
@ -92,9 +92,7 @@ let
|
|||||||
# `switch-to-configuration' that activates the configuration and
|
# `switch-to-configuration' that activates the configuration and
|
||||||
# makes it bootable.
|
# makes it bootable.
|
||||||
baseSystem = pkgs.stdenvNoCC.mkDerivation {
|
baseSystem = pkgs.stdenvNoCC.mkDerivation {
|
||||||
name = let hn = config.networking.hostName;
|
name = "nixos-system-${config.system.name}-${config.system.nixos.label}";
|
||||||
nn = if (hn != "") then hn else "unnamed";
|
|
||||||
in "nixos-system-${nn}-${config.system.nixos.label}";
|
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
allowSubstitutes = false;
|
allowSubstitutes = false;
|
||||||
buildCommand = systemBuilder;
|
buildCommand = systemBuilder;
|
||||||
@ -265,6 +263,21 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
system.name = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default =
|
||||||
|
if config.networking.hostName == ""
|
||||||
|
then "unnamed"
|
||||||
|
else config.networking.hostName;
|
||||||
|
defaultText = '''networking.hostName' if non empty else "unnamed"'';
|
||||||
|
description = ''
|
||||||
|
The name of the system used in the <option>system.build.toplevel</option> derivation.
|
||||||
|
</para><para>
|
||||||
|
That derivation has the following name:
|
||||||
|
<literal>"nixos-system-''${config.system.name}-''${config.system.nixos.label}"</literal>
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,11 +16,6 @@ let
|
|||||||
|
|
||||||
qemu = config.system.build.qemu or pkgs.qemu_test;
|
qemu = config.system.build.qemu or pkgs.qemu_test;
|
||||||
|
|
||||||
vmName =
|
|
||||||
if config.networking.hostName == ""
|
|
||||||
then "noname"
|
|
||||||
else config.networking.hostName;
|
|
||||||
|
|
||||||
cfg = config.virtualisation;
|
cfg = config.virtualisation;
|
||||||
|
|
||||||
consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
|
consoles = lib.concatMapStringsSep " " (c: "console=${c}") cfg.qemu.consoles;
|
||||||
@ -156,7 +151,7 @@ let
|
|||||||
|
|
||||||
# Start QEMU.
|
# Start QEMU.
|
||||||
exec ${qemuBinary qemu} \
|
exec ${qemuBinary qemu} \
|
||||||
-name ${vmName} \
|
-name ${config.system.name} \
|
||||||
-m ${toString config.virtualisation.memorySize} \
|
-m ${toString config.virtualisation.memorySize} \
|
||||||
-smp ${toString config.virtualisation.cores} \
|
-smp ${toString config.virtualisation.cores} \
|
||||||
-device virtio-rng-pci \
|
-device virtio-rng-pci \
|
||||||
@ -294,7 +289,7 @@ in
|
|||||||
|
|
||||||
virtualisation.diskImage =
|
virtualisation.diskImage =
|
||||||
mkOption {
|
mkOption {
|
||||||
default = "./${vmName}.qcow2";
|
default = "./${config.system.name}.qcow2";
|
||||||
description =
|
description =
|
||||||
''
|
''
|
||||||
Path to the disk image containing the root filesystem.
|
Path to the disk image containing the root filesystem.
|
||||||
@ -712,7 +707,7 @@ in
|
|||||||
''
|
''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
ln -s ${config.system.build.toplevel} $out/system
|
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
|
# When building a regular system configuration, override whatever
|
||||||
|
Loading…
x
Reference in New Issue
Block a user