Merge pull request #151082 from hercules-ci/nixos-cleanup-vmWithBootLoader
nixos: turn vmWithBootLoader into option (`nixos-rebuild build-vm`)
This commit is contained in:
commit
2bf5958169
23
flake.nix
23
flake.nix
@ -22,24 +22,6 @@
|
||||
import ./nixos/lib/eval-config.nix (args // {
|
||||
modules =
|
||||
let
|
||||
vmConfig = (import ./nixos/lib/eval-config.nix
|
||||
(args // {
|
||||
modules = modules ++ [ ./nixos/modules/virtualisation/qemu-vm.nix ];
|
||||
})).config;
|
||||
|
||||
vmWithBootLoaderConfig = (import ./nixos/lib/eval-config.nix
|
||||
(args // {
|
||||
modules = modules ++ [
|
||||
./nixos/modules/virtualisation/qemu-vm.nix
|
||||
{ virtualisation.useBootLoader = true; }
|
||||
({ config, ... }: {
|
||||
virtualisation.useEFIBoot =
|
||||
config.boot.loader.systemd-boot.enable ||
|
||||
config.boot.loader.efi.canTouchEfiVariables;
|
||||
})
|
||||
];
|
||||
})).config;
|
||||
|
||||
moduleDeclarationFile =
|
||||
let
|
||||
# Even though `modules` is a mandatory argument for `nixosSystem`, it doesn't
|
||||
@ -63,11 +45,6 @@
|
||||
system.nixos.versionSuffix =
|
||||
".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
|
||||
system.nixos.revision = final.mkIf (self ? rev) self.rev;
|
||||
|
||||
system.build = {
|
||||
vm = vmConfig.system.build.vm;
|
||||
vmWithBootLoader = vmWithBootLoaderConfig.system.build.vm;
|
||||
};
|
||||
}
|
||||
];
|
||||
});
|
||||
|
@ -9,27 +9,6 @@ let
|
||||
modules = [ configuration ];
|
||||
};
|
||||
|
||||
# This is for `nixos-rebuild build-vm'.
|
||||
vmConfig = (import ./lib/eval-config.nix {
|
||||
inherit system;
|
||||
modules = [ configuration ./modules/virtualisation/qemu-vm.nix ];
|
||||
}).config;
|
||||
|
||||
# This is for `nixos-rebuild build-vm-with-bootloader'.
|
||||
vmWithBootLoaderConfig = (import ./lib/eval-config.nix {
|
||||
inherit system;
|
||||
modules =
|
||||
[ configuration
|
||||
./modules/virtualisation/qemu-vm.nix
|
||||
{ virtualisation.useBootLoader = true; }
|
||||
({ config, ... }: {
|
||||
virtualisation.useEFIBoot =
|
||||
config.boot.loader.systemd-boot.enable ||
|
||||
config.boot.loader.efi.canTouchEfiVariables;
|
||||
})
|
||||
];
|
||||
}).config;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
@ -37,7 +16,5 @@ in
|
||||
|
||||
system = eval.config.system.build.toplevel;
|
||||
|
||||
vm = vmConfig.system.build.vm;
|
||||
|
||||
vmWithBootLoader = vmWithBootLoaderConfig.system.build.vm;
|
||||
inherit (eval.config.system.build) vm vmWithBootLoader;
|
||||
}
|
||||
|
@ -341,6 +341,28 @@
|
||||
socket <literal>/run/redis-${serverName}/redis.sock</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The option
|
||||
<link linkend="opt-virtualisation.vmVariant">virtualisation.vmVariant</link>
|
||||
was added to allow users to make changes to the
|
||||
<literal>nixos-rebuild build-vm</literal> configuration that
|
||||
do not apply to their normal system.
|
||||
</para>
|
||||
<para>
|
||||
The <literal>config.system.build.vm</literal> attribute now
|
||||
always exists and defaults to the value from
|
||||
<literal>vmVariant</literal>. Configurations that import the
|
||||
<literal>virtualisation/qemu-vm.nix</literal> module
|
||||
themselves will override this value, such that
|
||||
<literal>vmVariant</literal> is not used.
|
||||
</para>
|
||||
<para>
|
||||
Similarly
|
||||
<link linkend="opt-virtualisation.vmVariantWithBootLoader">virtualisation.vmVariantWithBootloader</link>
|
||||
was added.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The
|
||||
|
@ -118,6 +118,16 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||
to the members of the Unix group `redis-${serverName}`
|
||||
through the Unix socket `/run/redis-${serverName}/redis.sock`.
|
||||
|
||||
- The option [virtualisation.vmVariant](#opt-virtualisation.vmVariant) was added
|
||||
to allow users to make changes to the `nixos-rebuild build-vm` configuration
|
||||
that do not apply to their normal system.
|
||||
|
||||
The `config.system.build.vm` attribute now always exists and defaults to the
|
||||
value from `vmVariant`. Configurations that import the `virtualisation/qemu-vm.nix`
|
||||
module themselves will override this value, such that `vmVariant` is not used.
|
||||
|
||||
Similarly [virtualisation.vmVariantWithBootloader](#opt-virtualisation.vmVariantWithBootLoader) was added.
|
||||
|
||||
- The `writers.writePyPy2`/`writers.writePyPy3` and corresponding `writers.writePyPy2Bin`/`writers.writePyPy3Bin` convenience functions to create executable Python 2/3 scripts using the PyPy interpreter were added.
|
||||
|
||||
- The `influxdb2` package was split into `influxdb2-server` and
|
||||
|
@ -88,13 +88,8 @@ let
|
||||
|
||||
nixosWithUserModules = noUserModules.extendModules { modules = allUserModules; };
|
||||
|
||||
in withWarnings {
|
||||
|
||||
# Merge the option definitions in all modules, forming the full
|
||||
# system configuration.
|
||||
inherit (nixosWithUserModules) config options _module type;
|
||||
|
||||
in
|
||||
withWarnings nixosWithUserModules // {
|
||||
inherit extraArgs;
|
||||
|
||||
inherit (nixosWithUserModules._module.args) pkgs;
|
||||
}
|
||||
|
@ -1187,6 +1187,7 @@
|
||||
./tasks/powertop.nix
|
||||
./testing/service-runner.nix
|
||||
./virtualisation/anbox.nix
|
||||
./virtualisation/build-vm.nix
|
||||
./virtualisation/container-config.nix
|
||||
./virtualisation/containerd.nix
|
||||
./virtualisation/containers.nix
|
||||
|
@ -148,7 +148,7 @@ in
|
||||
system.build = mkOption {
|
||||
internal = true;
|
||||
default = {};
|
||||
type = types.attrs;
|
||||
type = types.lazyAttrsOf types.unspecified;
|
||||
description = ''
|
||||
Attribute set of derivations used to setup the system.
|
||||
'';
|
||||
|
55
nixos/modules/virtualisation/build-vm.nix
Normal file
55
nixos/modules/virtualisation/build-vm.nix
Normal file
@ -0,0 +1,55 @@
|
||||
{ config, extendModules, lib, ... }:
|
||||
let
|
||||
|
||||
inherit (lib)
|
||||
mkOption
|
||||
;
|
||||
|
||||
vmVariant = extendModules {
|
||||
modules = [ ./qemu-vm.nix ];
|
||||
};
|
||||
|
||||
vmVariantWithBootLoader = vmVariant.extendModules {
|
||||
modules = [
|
||||
({ config, ... }: {
|
||||
_file = "nixos/default.nix##vmWithBootLoader";
|
||||
virtualisation.useBootLoader = true;
|
||||
virtualisation.useEFIBoot =
|
||||
config.boot.loader.systemd-boot.enable ||
|
||||
config.boot.loader.efi.canTouchEfiVariables;
|
||||
})
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
||||
virtualisation.vmVariant = mkOption {
|
||||
description = ''
|
||||
Machine configuration to be added for the vm script produced by <literal>nixos-rebuild build-vm</literal>.
|
||||
'';
|
||||
inherit (vmVariant) type;
|
||||
default = {};
|
||||
visible = "shallow";
|
||||
};
|
||||
|
||||
virtualisation.vmVariantWithBootLoader = mkOption {
|
||||
description = ''
|
||||
Machine configuration to be added for the vm script produced by <literal>nixos-rebuild build-vm-with-bootloader</literal>.
|
||||
'';
|
||||
inherit (vmVariantWithBootLoader) type;
|
||||
default = {};
|
||||
visible = "shallow";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
system.build = {
|
||||
vm = lib.mkDefault config.virtualisation.vmVariant.system.build.vm;
|
||||
vmWithBootLoader = lib.mkDefault config.virtualisation.vmVariantWithBootLoader.system.build.vm;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user