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 // {
|
import ./nixos/lib/eval-config.nix (args // {
|
||||||
modules =
|
modules =
|
||||||
let
|
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 =
|
moduleDeclarationFile =
|
||||||
let
|
let
|
||||||
# Even though `modules` is a mandatory argument for `nixosSystem`, it doesn't
|
# Even though `modules` is a mandatory argument for `nixosSystem`, it doesn't
|
||||||
|
@ -63,11 +45,6 @@
|
||||||
system.nixos.versionSuffix =
|
system.nixos.versionSuffix =
|
||||||
".${final.substring 0 8 (self.lastModifiedDate or self.lastModified or "19700101")}.${self.shortRev or "dirty"}";
|
".${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.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 ];
|
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
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -37,7 +16,5 @@ in
|
||||||
|
|
||||||
system = eval.config.system.build.toplevel;
|
system = eval.config.system.build.toplevel;
|
||||||
|
|
||||||
vm = vmConfig.system.build.vm;
|
inherit (eval.config.system.build) vm vmWithBootLoader;
|
||||||
|
|
||||||
vmWithBootLoader = vmWithBootLoaderConfig.system.build.vm;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -341,6 +341,28 @@
|
||||||
socket <literal>/run/redis-${serverName}/redis.sock</literal>.
|
socket <literal>/run/redis-${serverName}/redis.sock</literal>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</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>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
The
|
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}`
|
to the members of the Unix group `redis-${serverName}`
|
||||||
through the Unix socket `/run/redis-${serverName}/redis.sock`.
|
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 `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
|
- The `influxdb2` package was split into `influxdb2-server` and
|
||||||
|
|
|
@ -88,13 +88,8 @@ let
|
||||||
|
|
||||||
nixosWithUserModules = noUserModules.extendModules { modules = allUserModules; };
|
nixosWithUserModules = noUserModules.extendModules { modules = allUserModules; };
|
||||||
|
|
||||||
in withWarnings {
|
in
|
||||||
|
withWarnings nixosWithUserModules // {
|
||||||
# Merge the option definitions in all modules, forming the full
|
|
||||||
# system configuration.
|
|
||||||
inherit (nixosWithUserModules) config options _module type;
|
|
||||||
|
|
||||||
inherit extraArgs;
|
inherit extraArgs;
|
||||||
|
|
||||||
inherit (nixosWithUserModules._module.args) pkgs;
|
inherit (nixosWithUserModules._module.args) pkgs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1187,6 +1187,7 @@
|
||||||
./tasks/powertop.nix
|
./tasks/powertop.nix
|
||||||
./testing/service-runner.nix
|
./testing/service-runner.nix
|
||||||
./virtualisation/anbox.nix
|
./virtualisation/anbox.nix
|
||||||
|
./virtualisation/build-vm.nix
|
||||||
./virtualisation/container-config.nix
|
./virtualisation/container-config.nix
|
||||||
./virtualisation/containerd.nix
|
./virtualisation/containerd.nix
|
||||||
./virtualisation/containers.nix
|
./virtualisation/containers.nix
|
||||||
|
|
|
@ -148,7 +148,7 @@ in
|
||||||
system.build = mkOption {
|
system.build = mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
default = {};
|
default = {};
|
||||||
type = types.attrs;
|
type = types.lazyAttrsOf types.unspecified;
|
||||||
description = ''
|
description = ''
|
||||||
Attribute set of derivations used to setup the system.
|
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 a new issue