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:
parent
f9d31cba65
commit
45610cb886
@ -160,7 +160,12 @@ rec {
|
|||||||
lib.nixosSystem {
|
lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
inherit inputs server system;
|
inherit
|
||||||
|
inputs
|
||||||
|
server
|
||||||
|
system
|
||||||
|
src
|
||||||
|
;
|
||||||
};
|
};
|
||||||
modules =
|
modules =
|
||||||
[
|
[
|
||||||
@ -208,7 +213,7 @@ rec {
|
|||||||
inherit inputs src configPath;
|
inherit inputs src configPath;
|
||||||
hostname = name;
|
hostname = name;
|
||||||
}
|
}
|
||||||
// import configPath { inherit inputs; }
|
// import configPath { inherit inputs src; }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
) (lib.rad-dev.lsdir path)
|
) (lib.rad-dev.lsdir path)
|
||||||
|
@ -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
5
modules/opt/default.nix
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{ ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
41
modules/opt/microvm-host.nix
Normal file
41
modules/opt/microvm-host.nix
Normal 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);
|
||||||
|
};
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{ inputs, ... }:
|
{ inputs, src, ... }:
|
||||||
{
|
{
|
||||||
users = [
|
users = [
|
||||||
"alice"
|
"alice"
|
||||||
@ -6,6 +6,6 @@
|
|||||||
];
|
];
|
||||||
modules = [
|
modules = [
|
||||||
inputs.attic.nixosModules.atticd
|
inputs.attic.nixosModules.atticd
|
||||||
inputs.microvm.nixosModules.host
|
(src + "/modules/opt/microvm-host.nix")
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
rad-dev.microvm-host.enable = true;
|
# rad-dev.microvm-host.enable = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user