From b2af6179d885f10e9ac5e98a7d931e0c69828de7 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Thu, 8 May 2025 23:09:15 +0100 Subject: [PATCH] Add nixos VM --- common.nix | 4 +-- hardware/esxi-vm.nix | 6 ++++ machines/nixos/configuration.nix | 26 ++++++++++++++++ machines/nixos/hardware-configuration.nix | 37 +++++++++++++++++++++++ server.nix | 5 +++ 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 hardware/esxi-vm.nix create mode 100644 machines/nixos/configuration.nix create mode 100644 machines/nixos/hardware-configuration.nix create mode 100644 server.nix diff --git a/common.nix b/common.nix index e8a04c4..4904c2d 100644 --- a/common.nix +++ b/common.nix @@ -22,8 +22,8 @@ # Select internationalisation properties. i18n.defaultLocale = "en_GB.UTF-8"; console = { - packages = [ pkgs.spleen pkgs.tamsyn ]; - font = "spleen-12x24"; + #packages = [ pkgs.spleen pkgs.tamsyn ]; + #font = "spleen-12x24"; useXkbConfig = true; # use xkb.options in tty. colors = [ "292d3e" diff --git a/hardware/esxi-vm.nix b/hardware/esxi-vm.nix new file mode 100644 index 0000000..2581a45 --- /dev/null +++ b/hardware/esxi-vm.nix @@ -0,0 +1,6 @@ + +{ config, lib, pkgs, ... }: + +{ +virtualisation.vmware.guest.enable = true; +} diff --git a/machines/nixos/configuration.nix b/machines/nixos/configuration.nix new file mode 100644 index 0000000..75d31d6 --- /dev/null +++ b/machines/nixos/configuration.nix @@ -0,0 +1,26 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page, on +# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). + +{ config, lib, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ../../common.nix + ../../server.nix + ../../hardware/esxi-vm.nix + ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.systemd-boot.configurationLimit = 2; + + networking.hostName = "nixos"; # Define your hostname. + + system.copySystemConfiguration = true; + + system.stateVersion = "24.11"; +} + diff --git a/machines/nixos/hardware-configuration.nix b/machines/nixos/hardware-configuration.nix new file mode 100644 index 0000000..7e9c32e --- /dev/null +++ b/machines/nixos/hardware-configuration.nix @@ -0,0 +1,37 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = [ ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "mptspi" "uhci_hcd" "ehci_pci" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ae78c1d6-3f33-425e-a35b-7a6b827a25a4"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/346D-280D"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/f2af1154-10ad-461a-b529-ed2680915c70"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.ens33.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} diff --git a/server.nix b/server.nix new file mode 100644 index 0000000..ef76a0e --- /dev/null +++ b/server.nix @@ -0,0 +1,5 @@ +{ config, lib, pkgs, ... }: + +{ + services.prometheus.exporters.node.enable = true; +}