microvm host is stable (for now)

- per-system default.nix now inherits the source tree via `src` (this
allows modules to be optionally imported from `modules/opt/`)
- adds a default config for microvm hosts
  - enables systemd-networkd by default
  - allows passing in vms
  - binds vm nix-store to host nix-store
  - allows merging systemd jounals
- adds microvms to palatine-hill

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
2024-06-22 10:58:39 -04:00
parent f9d31cba65
commit 45610cb886
6 changed files with 56 additions and 39 deletions

View File

@ -1,33 +0,0 @@
{
config,
lib,
inputs,
...
}:
let
cfg = config.rad-dev.microvm-host;
inherit (inputs.microvm.nixosModules) microvm;
in
{
# imports = [microvm.host];
options.rad-dev.microvm-host = {
enable = lib.mkEnableOption "microvm-host";
};
config = lib.mkIf cfg.enable {
networking.useNetworkd = true;
# microvm.shares = [
# {
# tag = "ro-store";
# source = "/nix/store";
# mountPoint = "/nix/.ro-store";
# }
# ];
# systemd.tmpfiles.rules = map (vmHost:
# let
# machineId = lib.addresses.machineId.${vmHost};
# in
# # creates a symlink of each MicroVM's journal under the host's /var/log/journal
# "L+ /var/log/journal/${machineId} - - - - /var/lib/microvms/${vmHost}/journal/${machineId}"
# ) (builtins.attrNames lib.addresses.machineId);
};
}

5
modules/opt/default.nix Normal file
View File

@ -0,0 +1,5 @@
{ ... }:
{
}

View File

@ -0,0 +1,41 @@
{
config,
lib,
inputs,
...
}:
let
cfg = config.rad-dev.microvm-host;
microvm = inputs.microvm.nixosModules;
in
{
imports = [ microvm.host ];
options.rad-dev.microvm-host = {
vms = lib.mkOption {
type = lib.types.attrset;
default = { };
description = "A list of VMs to construct on the host";
};
};
config = {
networking.useNetworkd = true;
microvm.vms = cfg.vms;
microvm.shares = [
{
tag = "ro-store";
source = "/nix/store";
mountPoint = "/nix/.ro-store";
}
];
# TODO: deprecate this once we have syslog forwarders
systemd.tmpfiles.rules = map (
vmHost:
let
machineId = lib.addresses.machineId.${vmHost};
in
# creates a symlink of each MicroVM's journal under the host's /var/log/journal
"L+ /var/log/journal/${machineId} - - - - /var/lib/microvms/${vmHost}/journal/${machineId}"
) (builtins.attrNames lib.addresses.machineId);
};
}