forked from Fediversity/Fediversity
Valentin Gagarin
919642f528
git-subtree-dir: deployment git-subtree-mainline:9a573df05f
git-subtree-split:df36e09c1d
166 lines
3.3 KiB
Nix
166 lines
3.3 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
modulesPath,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib) mkOption;
|
|
inherit (lib.types) types;
|
|
|
|
vmIdTo03d =
|
|
id:
|
|
let
|
|
sid = toString id;
|
|
in
|
|
if id >= 0 && id <= 9 then
|
|
"00${sid}"
|
|
else if id >= 10 && id <= 99 then
|
|
"0${sid}"
|
|
else
|
|
sid;
|
|
in
|
|
|
|
{
|
|
imports = [ (modulesPath + "/profiles/qemu-guest.nix") ];
|
|
|
|
options = {
|
|
procolix = {
|
|
vmid = mkOption {
|
|
type = types.int;
|
|
description = ''
|
|
Identifier of the machine. This is a number between 10 and 255.
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = {
|
|
########################################################################
|
|
## Network
|
|
|
|
services.openssh.enable = true;
|
|
|
|
networking = {
|
|
hostName = "fedi${vmIdTo03d config.procolix.vmid}";
|
|
domain = "procolix.com";
|
|
|
|
interfaces = {
|
|
eth0 = {
|
|
ipv4 = {
|
|
addresses = [
|
|
{
|
|
address = "95.215.187.${vmIdTo03d config.procolix.vmid}";
|
|
prefixLength = 24;
|
|
}
|
|
];
|
|
};
|
|
ipv6 = {
|
|
addresses = [
|
|
{
|
|
address = "2a00:51c0:13:1305::${vmIdTo03d config.procolix.vmid}";
|
|
prefixLength = 64;
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
defaultGateway = {
|
|
address = "95.215.187.1";
|
|
interface = "eth0";
|
|
};
|
|
defaultGateway6 = {
|
|
address = "2a00:51c0:13:1305::1";
|
|
interface = "eth0";
|
|
};
|
|
|
|
nameservers = [
|
|
"95.215.185.6"
|
|
"95.215.185.7"
|
|
];
|
|
};
|
|
|
|
########################################################################
|
|
## Hardware
|
|
|
|
boot = {
|
|
loader = {
|
|
systemd-boot.enable = true;
|
|
efi.canTouchEfiVariables = true;
|
|
};
|
|
initrd = {
|
|
availableKernelModules = [
|
|
"ata_piix"
|
|
"uhci_hcd"
|
|
"virtio_pci"
|
|
"virtio_scsi"
|
|
"sd_mod"
|
|
"sr_mod"
|
|
];
|
|
kernelModules = [ "dm-snapshot" ];
|
|
};
|
|
};
|
|
|
|
disko.devices.disk.main = {
|
|
device = "/dev/sda";
|
|
type = "disk";
|
|
|
|
content = {
|
|
type = "gpt";
|
|
|
|
partitions = {
|
|
MBR = {
|
|
priority = 0;
|
|
size = "1M";
|
|
type = "EF02";
|
|
};
|
|
|
|
ESP = {
|
|
priority = 1;
|
|
size = "500M";
|
|
type = "EF00";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "vfat";
|
|
mountpoint = "/boot";
|
|
};
|
|
};
|
|
|
|
root = {
|
|
priority = 2;
|
|
size = "100%";
|
|
content = {
|
|
type = "filesystem";
|
|
format = "ext4";
|
|
mountpoint = "/";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
|
|
########################################################################
|
|
## Miscellaneous
|
|
|
|
services.qemuGuest.enable = true;
|
|
|
|
time.timeZone = "Europe/Amsterdam";
|
|
|
|
i18n.defaultLocale = "en_US.UTF-8";
|
|
|
|
users.users.root.openssh.authorizedKeys.keys = [
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEElREJN0AC7lbp+5X204pQ5r030IbgCllsIxyU3iiKY"
|
|
];
|
|
|
|
nix.extraOptions = ''
|
|
experimental-features = nix-command flakes
|
|
'';
|
|
|
|
system.stateVersion = "24.05"; # Did you read the comment?
|
|
};
|
|
}
|