Hello,
I am an arch user, trying to install my first nixos to a virtual machine. I would like to create the exact replica of my current system in arch with nixos. I will consider switching to nixos if I am able to do this and use final configuration files for the formating the current production system.
I have difficutty setting up the system with with systemd-boot, luks, lvm, btrfs in libvirt/virt-manager. The configuration presented below stucks at Booting from Hard Disk
I have following partition, mount hierarch on a single disk
- boot (fat32-boot/efi) (non-encrypted)
- luks
- lvm
- swap
- root (btrfs)
- home (btrfs)
- vm (ext4)
- data (btfts)
- lvm
I have created necessary partions and done the relavant formatting for partitions and filesystem. There is no error there. I have a few submodules in btrfs root filesystem which you can observe in hardware-configuration.nix
file below.
My current harware-configuration.nix
is as follows. I have labeled luks device as luks
After os install and reboot, unfortunately, I can not get to the point where luks password is asked. I am sure I am missing some necessary configuration and the manual just skips these tricky parts.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/profiles/qemu-guest.nix")
];
boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ];
boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.initrd.luks.devices = {
crypted = {
device = "/dev/disk/by-label/luks";
preLVM = true;
};
};
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/boot" =
{ device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
fileSystems."/nix" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@nix" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/opt" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@opt" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/var" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@var" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/var/log" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@var/log" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/var/cache" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@var/cache" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/tmp" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@tmp" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/.snapshots" =
{ device = "/dev/vg/lvroot";
fsType = "btrfs";
options = [ "subvol=@.snapshots" "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/home" =
{ device = "/dev/vg/lvhome";
fsType = "btrfs";
options = [ "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/data" =
{ device = "/dev/vg/lvdata";
fsType = "btrfs";
options = [ "defaults" "noatime" "compress=zstd" ];
};
fileSystems."/vms" =
{ device = "/dev/vg/lvvms";
fsType = "ext4";
};
swapDevices =
[ { device = "/dev/vg/lvswap"; }
];
# 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.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp1s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}
my configuration.nix
is as follows
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
boot.supportedFilesystems = [ "btrfs" ];
boot.loader.systemd-boot.enable = true;
boot.loader.systemd-boot.consoleMode = "auto";
boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = "nixos-vms-pc"; # Define your hostname.
users.users.user1 = {
isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
};
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
wget
tmux
git
];
services.openssh.enable = true;
system.stateVersion = "22.11"; # Did you read the comment?
}
Could someone provide a working example for this setup with systemd-boot options. I appreciate any help.