mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-11 03:36:52 +02:00
feat: remove nur & devenv feat: adjust the structure to make it suitable for servers feat: add iso/proxmox generators and add docs about it feat: update ryan's openssh keys & add hashedPassword feat: add proxmox's nodes into ssh_config, with alias
68 lines
2.3 KiB
Nix
68 lines
2.3 KiB
Nix
{ config, lib, ... }:
|
|
|
|
##############################################################################
|
|
#
|
|
# Template for Proxmox's VM, mainly based on:
|
|
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/virtualisation/proxmox-image.nix
|
|
#
|
|
# the url above is used by `nixos-generator` to generate the Proxmox's VMA image file.
|
|
#
|
|
##############################################################################
|
|
|
|
let
|
|
bios = "seabios";
|
|
partitionTableType = if bios == "seabios" then "legacy" else "efi";
|
|
supportEfi = partitionTableType == "efi" || partitionTableType == "hybrid";
|
|
supportBios = partitionTableType == "legacy" || partitionTableType == "hybrid" || partitionTableType == "legacy+gpt";
|
|
hasBootPartition = partitionTableType == "efi" || partitionTableType == "hybrid";
|
|
hasNoFsPartition = partitionTableType == "hybrid" || partitionTableType == "legacy+gpt";
|
|
in
|
|
{
|
|
|
|
# DO NOT promote ryan to input password for sudo.
|
|
# this is a workaround for the issue of remote deploy:
|
|
# https://github.com/NixOS/nixpkgs/issues/118655
|
|
security.sudo.extraRules = [
|
|
{ users = [ "ryan" ];
|
|
commands = [
|
|
{ command = "ALL" ;
|
|
options = [ "NOPASSWD" ];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
|
|
boot = {
|
|
# after resize the disk, it will grow partition automatically.
|
|
growPartition = true;
|
|
kernelParams = [ "console=ttyS0" ];
|
|
loader.grub = {
|
|
device = lib.mkDefault (if (hasNoFsPartition || supportBios) then
|
|
# Even if there is a separate no-fs partition ("/dev/disk/by-partlabel/no-fs" i.e. "/dev/vda2"),
|
|
# which will be used the bootloader, do not set it as loader.grub.device.
|
|
# GRUB installation fails, unless the whole disk is selected.
|
|
"/dev/vda"
|
|
else
|
|
"nodev");
|
|
efiSupport = lib.mkDefault supportEfi;
|
|
efiInstallAsRemovable = lib.mkDefault supportEfi;
|
|
};
|
|
|
|
loader.timeout = 0;
|
|
initrd.availableKernelModules = [ "uas" "virtio_blk" "virtio_pci" ];
|
|
};
|
|
|
|
fileSystems."/" = {
|
|
device = "/dev/disk/by-label/nixos";
|
|
autoResize = true;
|
|
fsType = "ext4";
|
|
};
|
|
fileSystems."/boot" = lib.mkIf hasBootPartition {
|
|
device = "/dev/disk/by-label/ESP";
|
|
fsType = "vfat";
|
|
};
|
|
|
|
# it alse had qemu-guest-agent installed by default.
|
|
services.qemuGuest.enable = lib.mkDefault true;
|
|
}
|