liminix/.forgejo/ci-files/vm-base.nix

100 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
modulesPath,
...
}:
let
sqshStore = pkgs.callPackage (pkgs.path + /nixos/lib/make-squashfs.nix) {
storeContents = [
config.system.build.toplevel
];
comp = null; # no time for this
};
in
{
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
environment.systemPackages = with pkgs; [ tcpdump ];
networking = {
useNetworkd = true;
firewall.enable = false;
};
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";
}