t #2

Closed
lbailly wants to merge 57 commits from CI into main
4 changed files with 140 additions and 0 deletions
Showing only changes of commit ca41e04e7d - Show all commits

View file

@ -0,0 +1,4 @@
{ lib, pkgs, ... }:
{
networking.hostName = "border-vm";
}

View file

@ -0,0 +1,4 @@
{ lib, pkgs, ... }:
{
networking.hostName = "client-vm";
}

View file

@ -0,0 +1,40 @@
{
pkgs ? (import <nixpkgs> { }),
lib ? pkgs.lib,
}:
let
base-cmd = vm: ''
${pkgs.qemu}/bin/qemu-system-x86_64 -m 4G \
-kernel ${vm.kernel}/bzImage \
-initrd ${vm.ramdisk}/initrd \
-append "init=${vm.toplevel}/init loglevel=4 console=ttyS0" \
-display none -serial mon:stdio
'';
border-vm =
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
system = "x86_64-linux";
modules = [
./border.nix
./vm-base.nix
];
}).config.system.build;
client-vm =
(import (pkgs.path + "/nixos/lib/eval-config.nix") {
system = "x86_64-linux";
modules = [
./client.nix
./vm-base.nix
];
}).config.system.build;
border-launch = pkgs.writeShellScript "lauch-border" ''
${base-cmd border-vm}
'';
client-launch = pkgs.writeShellScript "lauch-client" ''
${base-cmd client-vm}
'';
in
{ }

View file

@ -0,0 +1,92 @@
{
config,
lib,
pkgs,
...
}:
let
sqshStore = pkgs.callPackage (pkgs.path + /nixos/lib/make-squashfs.nix) {
storeContents = [
config.system.build.toplevel
];
comp = null; # no time for this
};
in
{
system.build.ramdisk = pkgs.makeInitrdNG {
inherit (config.boot.initrd) compressor;
prepend = [ "${config.system.build.initialRamdisk}/initrd" ];
contents = [
{
source = sqshStore;
target = "/nix-store.squashfs";
}
];
};
fileSystems = {
"/" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
};
"/nix/.ro-store" = {
fsType = "squashfs";
device = "../nix-store.squashfs";
options = [ "loop" ];
neededForBoot = true;
};
"/nix/.rw-store" = {
fsType = "tmpfs";
options = [ "mode=0755" ];
neededForBoot = true;
};
"/nix/store" = {
overlay = {
lowerdir = [ "/nix/.ro-store" ];
upperdir = "/nix/.rw-store/store";
workdir = "/nix/.rw-store/work";
};
neededForBoot = true;
};
};
boot = {
loader.grub.enable = false;
initrd = {
availableKernelModules = [
"squashfs"
"overlay"
];
kernelModules = [
"loop"
"overlay"
];
};
postBootCommands = ''
# After booting, register the contents of the Nix store
# in the Nix database in the tmpfs.
${config.nix.package}/bin/nix-store --load-db < /nix/store/nix-path-registration
'';
};
services = {
getty.autologinUser = lib.mkForce "root";
openssh.enable = true;
qemuGuest.enable = true;
};
nix = {
nixPath = [
"nixpkgs=${builtins.storePath pkgs.path}"
"nixos=${builtins.storePath pkgs.path}"
];
channel.enable = false;
settings.nix-path = config.nix.nixPath;
package = pkgs.lix;
};
console.keyMap = "fr";
}