Skip to content

nixos/iso-image: fix isoImage.grubTheme = null; logic#156754

Merged
Artturin merged 1 commit intoNixOS:masterfrom
jonringer:fix-grubtheme
Nov 25, 2024
Merged

nixos/iso-image: fix isoImage.grubTheme = null; logic#156754
Artturin merged 1 commit intoNixOS:masterfrom
jonringer:fix-grubtheme

Conversation

@jonringer
Copy link
Contributor

Motivation for this change

To fix:

error: cannot coerce null to a string

       at /nix/store/ha4ld6wd29q1igjmhjdvkvbxpxxxxbxf-source/nixos/modules/installer/cd-dvd/iso-image.nix:255:5:

closes: #156753

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jan 25, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jan 25, 2022
@samueldr
Copy link
Member

Untested, but the logic looks sound.

@dmadisetti
Copy link
Contributor

Do you need someone to test this?

@jonringer
Copy link
Contributor Author

ideally, that would be great :)

@jonringer
Copy link
Contributor Author

I rebased the PR on the latest master

@dmadisetti
Copy link
Contributor

dmadisetti commented Mar 22, 2022

Hm. It doesn't even build. May have stumbled upon deeper bug.

Without patch, isoImage.grubTheme = null;

error: cannot coerce null to a string

       at /nix/store/w748fpqx5fjxa3b1j10c5lyashbrvm36-source/nixos/modules/installer/cd-dvd/iso-image.nix:321:14:

          320|     hiddenentry 'GUI mode' --hotkey 'g' {
          321|       $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (\$root)/EFI/boot/grub-theme/%P\n")
             |              ^
          322|       set textmode=false
(use '--show-trace' to show detailed location information)

at head
curl https://patch-diff.githubusercontent.com/raw/NixOS/nixpkgs/pull/156754.diff | git apply -v --index

With patch (isoImage.grubTheme = null;, and default)

error: builder for '/nix/store/gllbslpsbviv88vy7khcz9q1p0j9r1kp-efi-image_eltorito.drv' failed with exit code 2;
       last 1 log lines:
       > /build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 608: unexpected EOF while looking for matching `''
       For full logs, run 'nix log /nix/store/gllbslpsbviv88vy7khcz9q1p0j9r1kp-efi-image_eltorito.drv'.

and nix log /nix/store/gllbslpsbviv88vy7khcz9q1p0j9r1kp-efi-image_eltorito.drv
/build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 608: unexpected EOF while looking for matching `''

Derivation attached
7nwzgj5jyg6ixkj735kwzbidhqw29f4m-efi-image_eltorito.drv.txt

@dmadisetti
Copy link
Contributor

Ok, squashfs takes awhile... But this works
You were just missing a pair of parens. Or this works (and is more consistent with the rest of the file):

diff --git a/nixos/modules/installer/cd-dvd/iso-image.nix b/nixos/modules/installer/cd-dvd/iso-image.nix
--- a/nixos/modules/installer/cd-dvd/iso-image.nix
+++ b/nixos/modules/installer/cd-dvd/iso-image.nix
@@ -317,13 +317,13 @@ let
       set textmode=true
       terminal_output gfxterm console
     }
-    '' + lib.optionalString (config.isoImage.grubTheme != null) ''
+    ${lib.optionalString (config.isoImage.grubTheme != null) ''
     hiddenentry 'GUI mode' --hotkey 'g' {
       $(find ${config.isoImage.grubTheme} -iname '*.pf2' -printf "loadfont (\$root)/EFI/boot/grub-theme/%P\n")
       set textmode=false
       terminal_output gfxterm
     }
-    '' + ''
+    ''}
 
     # If the parameter iso_path is set, append the findiso parameter to the kernel
     # line. We need this to allow the nixos iso to be booted from grub directly.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 21, 2022
@RaitoBezarius
Copy link
Member

Can I help to get this merged?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 22, 2022
@ripx80
Copy link

ripx80 commented Jul 3, 2023

can this be merged to fix this bug?

@jonringer
Copy link
Contributor Author

jonringer commented Nov 23, 2023

testing with:

$ cat ./iso.nix
{ config, lib, pkgs, ... }:

{
  imports = [
    ./nixos/modules/installer/cd-dvd/iso-image.nix
  ];

  isoImage.grubTheme = null;
}

[11:03:21] jon@jon-desktop /home/jon/projects/nixpkgs (fix-grubtheme)
$ NIXOS_CONFIG=$(realpath ./iso.nix) nix-build ./nixos -A config.system.build.isoImage
...
/nix/store/a29l5drlh3pi8ljq8h3j076n48r235kn-nixos.iso
[11:21:01] jon@jon-desktop /home/jon/projects/nixpkgs (fix-grubtheme)

@jonringer
Copy link
Contributor Author

@ofborg test installer

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@Artturin Artturin merged commit fa4b963 into NixOS:master Nov 25, 2024
@phaer
Copy link
Member

phaer commented Nov 26, 2024

@Artturin I believe this broke the installer iso on master:

The parent 914616a builds ine, since fa4b963 I get the following

nixpkgs/nixos on  HEAD (fa4b963) [?]
❯ nix-build -A config.system.build.isoImage -I nixos-config=modules/installer/cd-dvd/installation-cd-minimal.nix default.nix -K

these 4 derivations will be built:
  /nix/store/1vshq09zfmvkjl1vg1hjwn7yznfpxfns-efi-image_eltorito.drv
  /nix/store/fq15h7g2laag1y8w7j19g226hqjmssp8-isolinux.cfg-in.drv
  /nix/store/a8kxzd0a2r8i70dik3qbb40rnwssz5am-isolinux.cfg.drv
  /nix/store/l65d9k1r8975znm6hiimxg3zk7hhmpca-nixos-25.05pre-git-x86_64-linux.iso.drv
building '/nix/store/fq15h7g2laag1y8w7j19g226hqjmssp8-isolinux.cfg-in.drv'...
building '/nix/store/1vshq09zfmvkjl1vg1hjwn7yznfpxfns-efi-image_eltorito.drv'...
/build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 608: unexpected EOF while looking for matching `''
note: keeping build directory '/tmp/nix-build-efi-image_eltorito.drv-0'
error: builder for '/nix/store/1vshq09zfmvkjl1vg1hjwn7yznfpxfns-efi-image_eltorito.drv' failed with exit code 2;
       last 1 log lines:
       > /build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 608: unexpected EOF while looking for matching `''
       For full logs, run 'nix log /nix/store/1vshq09zfmvkjl1vg1hjwn7yznfpxfns-efi-image_eltorito.drv'.
note: keeping build directory '/tmp/nix-build-isolinux.cfg-in.drv-0'
error: 1 dependencies of derivation '/nix/store/l65d9k1r8975znm6hiimxg3zk7hhmpca-nixos-25.05pre-git-x86_64-linux.iso.drv' failed to build

Line 608 in the mentioned file is "usage_size=..." below, but it might be due to the single quote on 602 (first in this snippet)?


"/EFI/BOOT/{grub.cfg,*.EFI,*.efi} ./EFI/BOOT

# Rewrite dates for everything in the FS
find . -exec touch --date=2000-01-01 {} +

# Round up to the nearest multiple of 1MB, for more deterministic du output
usage_size=$(( $(du -s --block-size=1M --apparent-size . | tr -cd '[:digit:]') * 1024 * 1024 ))

@ElvishJerricco
Copy link
Contributor

ElvishJerricco commented Nov 26, 2024

@Artturin Why are we merging year old stale PRs without testing them? I'm going to revert this for now, after I double check that @phaer is right that reverting this fixes it.

@phaer
Copy link
Member

phaer commented Nov 26, 2024

The code is messy enough that I don't really feel too much like digging into it, but at first glance it looks like the added conditional confuses the nix parser and lets it return the last string instead of the pkg.runCommand call. You can verify by i.e. adding a lib.traceVal around efiDir or brackets around the efiDir declaration.

The later fixes the build, but I am fine with reverting and think it's reasonable to expect people to at least build an uncustomized isoImage before merging to that module.

@Artturin
Copy link
Member

I ran the simple installer test which i thought would test this but didn't, my bad.

@ElvishJerricco
Copy link
Contributor

The installer test ironically doesn't test the ISO. It tests the procedure of installing and rebuilding nixos with nixos-install / nixos-generate-config / nixos-rebuild on a variety of storage stacks, but the installation environment is run from a regular NixOS test VM, not the ISO.

@ElvishJerricco
Copy link
Contributor

nixos/tests/boot.nix tests the actual ISO.

@Artturin
Copy link
Member

Artturin commented Nov 26, 2024

#359374 does string interpolation like suggested earlier in this thread, I thought jonringer fixed it a another way since he pushed after that comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setting isoImage.grubTheme to null no longer works

9 participants