Add Nodens, a VM to install NixOS VMs

This commit is contained in:
Gonne 2024-11-29 11:55:58 +01:00
parent ac85711356
commit 765f25022d
5 changed files with 86 additions and 24 deletions

View file

@ -14,7 +14,13 @@
importedConfig = import (./. + "/machines/${name}/configuration.nix");
systemConfig =
if lib.isFunction importedConfig
then x: importedConfig (x // {flake-inputs = inputs;})
then
x:
importedConfig (x
// {
flake-inputs = inputs;
inherit pkgs;
})
else importedConfig;
in
pkgs.nixos {

View file

@ -7,17 +7,17 @@
options = ["size=1G" "mode=755"];
};
fileSystems."/persist" = {
device = "/dev/disk/by-uuid/e0a160ef-7d46-4705-9152-a6b602898136";
device = "/dev/disk/by-label/nixos";
fsType = "btrfs";
options = ["subvol=persist"];
neededForBoot = true;
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/19da7f3a-69da-4fa8-bb68-b355d7697ba7";
device = "/dev/disk/by-label/boot";
fsType = "ext4";
};
fileSystems."/nix" = {
device = "/dev/disk/by-uuid/e0a160ef-7d46-4705-9152-a6b602898136";
device = "/dev/disk/by-label/nixos";
fsType = "btrfs";
options = ["subvol=nix"];
};

View file

@ -0,0 +1,16 @@
{pkgs, ...}: {
imports = [
./hardware-configuration.nix
../../roles
../../roles/vm.nix
../../modules/vmNetwork.nix
];
# System configuration here
environment.systemPackages = [pkgs.git];
networking.hostName = "nodens";
vmNetwork.ipv4 = "192.168.0.18";
system.stateVersion = "24.11";
}

View file

@ -0,0 +1,50 @@
# A machine that exists to install other NixOS machines from some config
{
lib,
pkgs,
...
}: {
imports = [];
fileSystems."/" = {
device = "root";
fsType = "tmpfs";
options = ["size=1G" "mode=755"];
};
# Different than usual names in order to automount other VMs
fileSystems."/persist" = {
device = "/dev/disk/by-label/nixosNodens";
fsType = "btrfs";
options = ["subvol=persist"];
neededForBoot = true;
};
fileSystems."/boot" = {
device = "/dev/disk/by-label/bootNodens";
fsType = "ext4";
};
fileSystems."/nix" = {
device = "/dev/disk/by-label/nixosNodens";
fsType = "btrfs";
options = ["subvol=nix"];
};
#Machine to be installed
fileSystems."/mnt/persist" = {
device = "/dev/disk/by-label/nixos";
fsType = "btrfs";
options = ["subvol=persist"];
};
fileSystems."/mnt/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "ext4";
};
fileSystems."/mnt/nix" = {
device = "/dev/disk/by-label/nixos";
fsType = "btrfs";
options = ["subvol=nix"];
};
swapDevices = [{device = "/dev/disk/by-uuid/89e13a83-506a-43b4-b06a-09424500ceda";}];
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}