mirror of
https://github.com/elitak/nixos-infect.git
synced 2024-12-22 08:08:29 +03:00
Add support for VMs that use efi sysmount
This commit is contained in:
parent
5dbf3d676f
commit
1261e34cd9
1 changed files with 29 additions and 7 deletions
36
nixos-infect
36
nixos-infect
|
@ -56,15 +56,30 @@ makeConf() {
|
|||
EOF
|
||||
|
||||
if isEFI; then
|
||||
bootcfg=$(cat << EOF
|
||||
if [[ $bootFs == /boot ]]; then
|
||||
bootcfg=$(cat << EOF
|
||||
boot.loader.grub = {
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
device = "nodev";
|
||||
};
|
||||
fileSystems."/boot" = { device = "$esp"; fsType = "vfat"; };
|
||||
fileSystems."$bootFs" = { device = "$esp"; fsType = "vfat"; };
|
||||
EOF
|
||||
)
|
||||
else
|
||||
bootcfg=$(cat << EOF
|
||||
boot.loader = {
|
||||
efi.efiSysMountPoint = "/boot/efi";
|
||||
grub = {
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
device = "nodev";
|
||||
};
|
||||
};
|
||||
fileSystems."$bootFs" = { device = "$esp"; fsType = "vfat"; };
|
||||
EOF
|
||||
)
|
||||
fi
|
||||
else
|
||||
bootcfg=$(cat << EOF
|
||||
boot.loader.grub.device = "$grubdev";
|
||||
|
@ -234,6 +249,13 @@ prepareEnv() {
|
|||
# $esp and $grubdev are used in makeConf()
|
||||
if isEFI; then
|
||||
esp="$(findESP)"
|
||||
if mount | grep -q /boot/efi; then
|
||||
bootFs=/boot/efi
|
||||
elif mount | grep -q /boot/EFI; then
|
||||
bootFs=/boot/EFI
|
||||
else
|
||||
bootFs=/boot
|
||||
fi
|
||||
else
|
||||
for grubdev in /dev/vda /dev/sda /dev/xvda /dev/nvme0n1 ; do [[ -e $grubdev ]] && break; done
|
||||
fi
|
||||
|
@ -370,14 +392,14 @@ infect() {
|
|||
echo root/.nix-defexpr/channels >> /etc/NIXOS_LUSTRATE
|
||||
(cd / && ls etc/ssh/ssh_host_*_key* || true) >> /etc/NIXOS_LUSTRATE
|
||||
|
||||
rm -rf /boot.bak
|
||||
rm -rf $bootFs.bak
|
||||
isEFI && umount "$esp"
|
||||
|
||||
mv -v /boot /boot.bak || { cp -a /boot /boot.bak ; rm -rf /boot/* ; umount /boot ; }
|
||||
mv -v $bootFs $bootFs.bak || { cp -a $bootFs $bootFs.bak ; rm -rf $bootFs/* ; umount $bootFs ; }
|
||||
if isEFI; then
|
||||
mkdir -p /boot
|
||||
mount "$esp" /boot
|
||||
find /boot -depth ! -path /boot -exec rm -rf {} +
|
||||
mkdir -p $bootFs
|
||||
mount "$esp" $bootFs
|
||||
find $bootFs -depth ! -path $bootFs -exec rm -rf {} +
|
||||
fi
|
||||
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue