Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NixOS #120

Open
thias opened this issue Oct 20, 2023 · 1 comment
Open

Add support for NixOS #120

thias opened this issue Oct 20, 2023 · 1 comment

Comments

@thias
Copy link
Owner

thias commented Oct 20, 2023

Creating this for reference, since I've just tried and failed. Maybe someone else will have better luck than me...

This almost works, but gives an error about not being able to mount the GLIM filesystem on /findiso because of "device of resource busy":

# NixOS
function add_menu {
  isofile="$1"

  regexp \
    --set 1:isoname \
    --set 2:variant \
    --set 3:version \
    "^${isopath}/nixos/(nixos-([^-]+)-([0-9]+\.[0-9]+).*-([^-]+)-linux\.iso)\$" "${isofile}"
  menuentry "NixOS ${version} ${variant}" "${isofile}" "${isoname}" --class nixos {
    set isofile=$2
    set isoname=$3
    use "${isoname}"
    loop $isofile
    probe --set isolabel --label (loop)
    linux (loop)/boot/bzImage findiso=${isofile} init=/nix/store/3d6j0n5fjw1yrdpfdyy70072zm8iq04v-nixos-system-nixos-23.05.4407.80c1aab72515/init  root=LABEL=${isolabel} # boot.shell_on_fail video=hyperv_fb:1152x864 elevator=noop nohibernate splash loglevel=4 nomodeset
    initrd (loop)/boot/initrd
  }
}

for_each_sorted add_menu "$isopath"/nixos/nixos-*-linux.iso

Since the above has a very unique init= parameter, I also tried using the provided grub2 loobpack configuration. That loads the provided grub menu, but entries freeze for me:

# NixOS
function add_menu {
  isofile="$1"

  regexp \
    --set 1:isoname \
    --set 2:variant \
    --set 3:version \
    "^${isopath}/nixos/(nixos-([^-]+)-([0-9]+\.[0-9]+).*-([^-]+)-linux\.iso)\$" "${isofile}"
  menuentry "NixOS ${version} ${variant}" "${isofile}" "${isoname}" --class nixos { 
    set isofile=$2
    set isoname=$3
    use "${isoname}"
    loop $isofile
    change_root (loop)
    set iso_path=$isofile
    export iso_path
    configfile /boot/grub/loopback.cfg
    restore_root
  }
}

for_each_sorted add_menu "$isopath"/nixos/nixos-*-linux.iso

Possibly something that needs to be sanitized better.

@akaihola
Copy link

akaihola commented May 9, 2024

Hey @thias, your second configuration worked out of the box for me for nixos-rescue! I'll try the NixOS installer next.

Creating this for reference, since I've just tried and failed. Maybe someone else will have better luck than me...

[...] I also tried using the provided grub2 loobpack configuration. That loads the provided grub menu, but entries freeze for me:

# NixOS
function add_menu {
  isofile="$1"

  regexp \
    --set 1:isoname \
    --set 2:variant \
    --set 3:version \
    "^${isopath}/nixos/(nixos-([^-]+)-([0-9]+\.[0-9]+).*-([^-]+)-linux\.iso)\$" "${isofile}"
  menuentry "NixOS ${version} ${variant}" "${isofile}" "${isoname}" --class nixos { 
    set isofile=$2
    set isoname=$3
    use "${isoname}"
    loop $isofile
    change_root (loop)
    set iso_path=$isofile
    export iso_path
    configfile /boot/grub/loopback.cfg
    restore_root
  }
}

for_each_sorted add_menu "$isopath"/nixos/nixos-*-linux.iso

Possibly something that needs to be sanitized better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants