nix-community / raspberry-pi-nix

NixOS modules to aid in configuring NixOS for raspberry pi products
MIT License
144 stars 34 forks source link

Rebuild error with latest raspberry-pi-nix and nixpkgs 24.05 #48

Closed PowerUser64 closed 2 weeks ago

PowerUser64 commented 4 weeks ago

I was updating my system, when I got the following error:

       error: The option `boot.loader.generic-extlinux-compatible.enable' has conflicting definition values:
       - In `/nix/store/4f9cx80vcs558qa1i68aa74yhc0lxsk5-source/raspberry-pi/4': true
       - In `/nix/store/7sprarsdfz9qcd7859phvr9nvhi14mri-source/flake.nix': false
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

The first file listed in the error is from raspberry-pi-nix, and the second one is from nixpkgs. It seems that raspberry-pi-nix tries to set a value that nixpkgs also sets. I solved this by using lib.mkForce in my config, but it seems like something that should be solved in rpi nix or nixpkgs. I only started getting this error recently. Any idea where this should be solved?

Update: I'm now getting a subsequent error:

       error: The option `system.build.installBootLoader' is defined multiple times while it's expected to be unique.
       Only one bootloader can be enabled at a time. This requirement has not
       been checked until NixOS 22.05. Earlier versions defaulted to the last
       definition. Change your configuration to enable only one bootloader.

       Definition values:
       - In `/nix/store/7sprarsdfz9qcd7859phvr9nvhi14mri-source/nixos/modules/system/boot/loader/generic-extlinux-compatible': "/nix/store/gr0aydmfa2i3ivg1x85pmr4cr5rlq0bc-extlinux-conf-builder.sh -g 20 -t 5 -r -c"
       - In `/nix/store/7sprarsdfz9qcd7859phvr9nvhi14mri-source/nixos/modules/system/boot/loader/init-script/init-script.nix': <derivation init-script-builder.sh>
       Use `lib.mkForce value` or `lib.mkDefault value` to change the priority on any of these definitions.

Not sure if I can lib.mkForce my way out of this one.

PowerUser64 commented 3 weeks ago

I manually set boot.loader.generic-extlinux-compatible.enable to false with lib.mkForce to avoid the second error, and now my pi won't boot :face_with_diagonal_mouth:

I'm recovering it, with the main disk hooked up to my desktop. I'm not 100% sure what to do to satisfy nix here, but I'll post updates here as I go.

Still battling the same errors as mentioned before. Resolving the first one by setting boot.loader.generic-extlinux-compatible.enable (with mkForce) to false leads to no boot, and setting it to true causes the second error above. I can't resolve the second error by setting system.build.installBootLoader to anything because it causes another error saying the option doesn't exist.

PowerUser64 commented 3 weeks ago

Turns out rpi-nix looks at the uboot option, and sets boot.loader.generic-extlinux-compatible.enable as well as boot.loader.initScript.enable automatically. nixpkgs looks at boot.loader.initScript.enable as its way of knowing whether to set this mysterious system.build.installBootLoader option.

I have uboot disabled (the default), which should cause rpi nix to disable both initScript and generic-extlinux-compatible. This causes nixpkgs to disable system.build.installBootLoader ... I'm going crazy trying to figure this out lol.

Anyway, what's happening is rpi-nix wants to enable an option (generic-extlinux-compatible), but nixpkgs wants it disabled. mkForcing the option to be disabled causes my pi to not boot, so I need to mkForce it to be enabled. But, if I do that, an internal nixpkgs option gets set for me (declaration: system.build.installBootLoader - set here) to a value that conflicts with one that rpi-nix changes through initScript. This feels like a circular dependency tree of things being broken and I don't know how to fix it.

Sorry if this reads more like a journal entry than a github issue, I'm trying to process what's going on and these are my observations.

@tstat I'm really lost with this, do you have any insight?

PowerUser64 commented 2 weeks ago

I'm not sure if I can salvage the boot disk, I'm going to rebuild it from scratch and copy files over. It's not that big of a deal because I've been meaning to start from a fresh nix config for a while now. Just means more downtime.

By the way, @tstat it might be a good idea to mention somewhere in the readme that you need to set networking.networkmanager.plugins = lib.mkForce [] or else you have to build webkitgtk (in my experience). Found this using nix-tree.

PowerUser64 commented 1 week ago

UPDATE: It's working now! I'm pretty sure the problem was that I had a really old eeprom version (from 2020). I think the eeprom I had wasn't compatible with booting with the extlinux options, and the recent removal of u-boot caused my system to break. Either way, I've updated the bootloader to the latest version following these steps on the nixos wiki and now I can boot!

I haven't tested booting with rpi-nix yet, but I'm pretty sure if I tried now it would work.