77 lines
1.8 KiB
Nix
Raw Normal View History

2025-05-25 11:55:51 +02:00
{
pkgs,
lib,
config,
...
}:
with lib;
let
cfg = config.modules.profiles.vm;
in
{
options.modules.profiles.vm = {
enable = mkEnableOption "Base VM profile";
};
config = mkIf cfg.enable {
# Enabled modules
modules = {
profiles.base.enable = true;
2025-05-29 14:19:19 +02:00
disko = {
enable = true;
profile = "vm";
};
2025-05-29 16:34:24 +02:00
impermanence = {
enable = true;
resetScript = ''
# Revert to the blank state for the root directory
zfs rollback -r tank/root@blank
'';
};
2025-05-25 11:55:51 +02:00
ssh.enable = true;
};
# Autologin to root for access from hypervisor
services.getty.autologinUser = "root";
2025-05-29 20:20:18 +02:00
# Local user
2025-05-30 16:15:42 +02:00
modules.secrets.secrets."passwords/local-hashed".neededForUsers = true;
2025-05-29 20:20:18 +02:00
users.mutableUsers = false;
2025-05-28 13:59:30 +02:00
users.users.local = {
2025-05-30 16:15:42 +02:00
hashedPasswordFile = config.sops.secrets."passwords/local-hashed".path;
2025-05-28 13:59:30 +02:00
extraGroups = [ "wheel" ];
2025-05-30 16:19:12 +02:00
openssh.authorizedKeys.keys = [
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKKxoQSxfYqf9ITN8Fhckk8WbY4dwtBAXOhC9jxihJvq Admin"
2025-05-28 13:59:30 +02:00
];
};
2025-05-29 20:37:12 +02:00
# System packages
environment.systemPackages = with pkgs; [
# TODO: Make module for utilities/scripts
2025-05-30 14:03:05 +02:00
(writeShellScriptBin "system-update" "nixos-rebuild switch --flake git+https://git.bulthuis.dev/Jan/nixos-config")
2025-05-29 20:37:12 +02:00
];
2025-05-25 11:55:51 +02:00
# Enable qemu guest agent
services.qemuGuest.enable = true;
2025-05-28 12:23:31 +02:00
# Machine platform
nixpkgs.hostPlatform = "x86_64-linux";
2025-05-29 15:10:10 +02:00
# Set hostid for ZFS
2025-05-29 14:19:19 +02:00
networking.hostId = "deadbeef";
2025-05-25 11:55:51 +02:00
# Hardware configuration
hardware.enableRedistributableFirmware = true;
boot.initrd.availableKernelModules = [
"ata_piix"
"uhci_hcd"
"virtio_pci"
"virtio_scsi"
"sd_mod"
"sr_mod"
];
boot.kernelModules = [ "kvm-intel" ];
};
}