I am an absolute beginner using the Nix configuration.
Context: I am interested in the way Nixos makes it possible to create virtual machines. I recently achieved creating VM’s by using Proxmox. Now I want to achieve the same with NixOs.
Therefore I copied the code from the NixOps/Virtualization - NixOS Wiki website.
let
machine = {host, port ? 22, name, hostNic, guests ? {}}: {pkgs, lib, ...}@args:
{
imports = [ ./baseline.nix ];
# We still want to be able to boot, adjust as needed based on your setup
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
kernelParams = [ "nomodeset" ];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-label/${name}-root";
};
"/boot" = {
device = "/dev/disk/by-label/${name}-boot";
};
};
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ];
# Tell NixOps how to find the machine
deployment.targetEnv = "none";
deployment.targetHost = host;
deployment.targetPort = port;
networking.privateIPv4 = host;
};
in
{
# Tell NixOps about the hosts it should manage
athens = machine {
host = "192.168.0.2";
name = "athens";
hostNic = "enp30s0";
guests = {
some-athens-guest = {
memory = "4"; # GB
diskSize = "50"; # GB
mac = "D2:91:69:C0:14:9A";
ip = "192.168.0.101"; # Ignored, only for personal reference
};
};
rome = machine {
host = "192.168.0.3";
name = "rome";
hostNic = "enp3s0";
};
}
When I entered the command nixos rebuild switch
, the following error message appeared:
error: 'machine' at /etc/nixos/network.nix:2:13 called with unexpected argument 'rome'
at /etc/nixos/network.nix:33:14
33| athens = machine {
|
34| host = "192.168.0.2";
Did you mean name?
For me the Nix language is a little bit confusing.
My questions are:
- why am I getting this error?
- How can I fix it?