Open aij opened 2 years ago
I tried switching my monitor from HDMI-0 to HDMI-1 and found the missing output.
When rebooting with HDMI-1, I see the bootloader output, but then nothing from the kernel until the login prompt appears. I'm guessing the kernel output is still being sent to HDMI-0 until it switches to a framebuffer mode.
So, I can change the outputs as a workaround, but it would still be nice to understand what changed and how to fix it properly.
Besides bisecting the changes, I also don't have a good suggestion here. :(
Using HDMI-1 instead of HDMI-0 is also working for me.
The default Raspberry Pi OS doesn't need this workaround.
Some raspberry pi resources [0, 1] suggest setting hdmi_force_hotplug = 1
. Perhaps that's worth a try?
[0] https://forums.raspberrypi.com/viewtopic.php?t=34061 [1] https://forums.raspberrypi.com/viewtopic.php?f=28&t=58151
Has anyone found a reliable work around for this? None of the mentioned ideas are working for me, and I can't even use the last working image, it's not compatible with Pi4B I just received.
I see console output for a while, then the monitor turns off and I see double green flashes for a while. But nothing further happens.
@ryanbrooker perhaps try https://github.com/NixOS/nixpkgs/issues/191095#issuecomment-1320982678?
Thanks for the tip @RyanGibb. I'm trying to follow this guide at: https://nixos.org/guides/installing-nixos-on-a-raspberry-pi.html
I'm not sure where I would update that nixos configuration after creating the image on the SD card as described in the guide?
I see! I wasn't aware of this guide. It's a shame that the most recent working build your directed to doesn't seem to work. I had a dig around and it looks like it's a little over 2 years old: https://hydra.nixos.org/build/134721359. (I'm not sure whether this is intentional or not).
Can I ask how familiar you are with NixOS? Are you using it on any other machines?
This is my maiden voyage with NixOS. I use nix for packages on my Macs, but I've never used NixOS before. The Pi is working with Raspbian. But I bought it for tinkering. :)
Oh, and I've tried the latest build from Hydra (about to try the one mentioned in the actual guide). In case it's not clear above, I've also tried the "working" build suggested and it is not compatible with the current Pi4Bs.
I'm not sure where I would update that nixos configuration after creating the image on the SD card as described in the guide?
So normally you would be able to modify the Nixos configuration on the SD image on the Pi itself, but in this case the lack of display output is preventing that. You could try and SSH in, but that would require a SSH server up and running as well as a network connection -- which might require WiFi authentication if you don't have an easily available ethernet connection -- which also requires a configuration change. It's the chicken and the egg!
Fortunately we can pre-compile a custom SD image instead of having to modify it on the Pi directly.
Basically what the default SD image is building is defined here: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image.nix
You can build this yourself with:
$ git clone git@github.com:NixOS/nixpkgs.git
$ cd nixpkgs
$ nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-aarch64.nix -A config.system.build.sdImage
So if you modify nixos/modules/installer/sd-card/sd-image-aarch64.nix
to add boot.kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
I (hope) this image would work.
This is my maiden voyage with NixOS. I use nix for packages on my Macs, but I've never used NixOS before. The Pi is working with Raspbian. But I bought it for tinkering. :)
Glad to hear it it :-)
The reason I ask about your familiarity with nixos is it's also possible to define such an image in your own nixos configuration. My example, using Nix flakes, is here with this fix. I also have an SSH server, authenticated keys, and WiFi connections authenticated through this. But given that this is your first system I would just try the above initially.
Brilliant. Thanks so much for the information. I'll let you know the outcome. :)
You're welcome, and good luck!
It seems that I need to do the build on a linux machine? I found something called darwin.builder that suggests it can be a build runner for linux builds on macOS, but I can't get it to work.
Ah yes, that could be an issue. I've gotten architecture cross compilation working but not OS cross compilation. This is the relevant manual sections: https://nixos.org/manual/nixpkgs/stable/#chap-cross
Can you share the error messages? And is your mac aarch64 or x86_64?
If you have access to a linux box, it might be easier to build the image on that.
Thanks for the link. My Mac is aarch64
. I found this, which sounds like it is for this purpose?
https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder
This is the error I see, even with darwin.builder
running—which appears to be working, as direnv
sees it as an option when building local environments.
% nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-aarch64.nix -A config.system.build.sdImage
error: assertion '(stdenv).isLinux' failed
at /Users/ryanbooker/Developer/foss/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix:72:1:
71|
72| assert stdenv.isLinux;
| ^
73|
(use '--show-trace' to show detailed location information)
Thanks for the link. My Mac is
aarch64
. I found this, which sounds like it is for this purpose? https://nixos.org/manual/nixpkgs/unstable/#sec-darwin-builder
That looks like exactly what we need! It looks like it runs a linux VM as a (local) remote builder.
This is the error I see, even with
darwin.builder
running—which appears to be working, asdirenv
sees it as an option when building local environments.% nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-aarch64.nix -A config.system.build.sdImage error: assertion '(stdenv).isLinux' failed at /Users/ryanbooker/Developer/foss/nixpkgs/pkgs/os-specific/linux/kernel/generic.nix:72:1: 71| 72| assert stdenv.isLinux; | ^ 73| (use '--show-trace' to show detailed location information)
Hmm, it looks like your not using the Linux VM as a remote builder for some reason... When you say direnv
sees it as an option for building local environments, what do you mean exactly?
Looks like darwin.builder
was merged recently: https://github.com/NixOS/nixpkgs/pull/206951
I have direnv
enabled via home-manager
on my Mac. When it triggers a build for an environment in a directory that has a shell.nix
a log message is output indicating that there is a builder ready to do aarch64-linux
builds. I think that really means nix-shell
sees the builder…
The log message(s) look like this:
1 available machines:
(systems, maxjobs, supportedFeatures, mandatoryFeatures)
([aarch64-linux], 4, [], [])
So that makes me think nix knows about the builder.
It couldn't be because it needs to run as sudo could it? I ran into that as described here: https://github.com/NixOS/nix/issues/1572#issuecomment-1307986633.
Also, it's worth testing the connectivity as described here with:
nix store ping --store 'ssh-ng://builder@localhost aarch64-linux /etc/nix/builder_ed25519 4 - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo='
Otherwise I'm not too sure how to debug this with the old CLI. I know with the new CLI that you can use nix build --max-jobs 0
to force a build on the remote only (max-jobs
referring to local jobs). Maybe try the following flake:
$ mkdir sd-image-flake
$ cd sd-image-flake
$ echo '{
outputs = { self, nixpkgs, ... }: {
nixosConfigurations.sd-image =
nixpkgs.lib.nixosSystem {
system = null;
pkgs = null;
modules =
[
"${nixpkgs}/nixos/modules/installer/sd-card/sd-image-aarch64.nix"
({ config, pkgs, ... }: {
networking.hostName = "sd-image";
nixpkgs.hostPlatform.system = "aarch64-linux";
system.stateVersion = "22.11";
boot.kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;
})
];
};
};
}' > flake.nix
$ nix build .#nixosConfigurations.sd-image.config.system.build.toplevel --max-jobs 0 --builders 'ssh-ng://builder@localhost aarch64-linux /etc/nix/builder_ed25519 4 - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo='
And add -vvvv
to nix build
for verbose debugging if this doesn't work.
Also, I should have said this sooner, but have you tried the other HDMI port and/or another (low resolution) monitor?
Also, I should have said this sooner, but have you tried the other HDMI port and/or another (low resolution) monitor?
Looking into the details of your other comment (thank you again), but yeah I've tried the only two monitor options I have and both HDMI ports.
Ok. This doesn't work… but I think this passing the builder description for --store
:
nix store ping --store 'ssh-ng://builder@localhost aarch64-linux /etc/nix/builder_ed25519 4 - - - c3NoLWVkMjU1MTkgQUFBQUMzTnphQzFsWkRJMU5URTVBQUFBSUpCV2N4Yi9CbGFxdDFhdU90RStGOFFVV3JVb3RpQzVxQkorVXVFV2RWQ2Igcm9vdEBuaXhvcwo='
However, this does work:
nix store ping --store 'ssh-ng://builder@localhost?ssh-key=/etc/nix/builder_ed25519'
I have listed my user in /etc/nix/nix.conf
in extra-trusted-users = foo
as described in the darwin.builder
instructions.
Turns out, this almost works:
nix-build nixos -I nixos-config=nixos/modules/installer/sd-card/sd-image-aarch64.nix -A config.system.build.sdImage --system aarch64-linux
It starts building, and then:
building '/nix/store/bxqfqa3yxp8w4kyfac07aqq9nw126lzf-config.txt.drv'...
building '/nix/store/ifci4y1rakx0a1db2fp9k1iyy2qg8vq1-nixos-manual-combined.drv' on 'ssh-ng://builder@localhost'...
building '/nix/store/p67b4n2912hz23rqsgvx5r8pn5gnrdnf-options-docbook.xml.drv' on 'ssh-ng://builder@localhost'...
/nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: /nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: cannot execute binary file
copying 0 paths...
building '/nix/store/ifci4y1rakx0a1db2fp9k1iyy2qg8vq1-nixos-manual-combined.drv'...
error: builder for '/nix/store/bxqfqa3yxp8w4kyfac07aqq9nw126lzf-config.txt.drv' failed with exit code 126;
last 1 log lines:
> /nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: /nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: cannot execute binary file
For full logs, run 'nix log /nix/store/bxqfqa3yxp8w4kyfac07aqq9nw126lzf-config.txt.drv'.
error: 1 dependencies of derivation '/nix/store/np5r3159q0acgl1c85gzpy02mji1calk-nixos-sd-image-23.05pre-git-aarch64-linux.img.drv' failed to build
nix log contains:
/nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: /nix/store/fz80arp0cldc6lprk1z11g3d62vpmj78-bash-5.2-p15/bin/bash: cannot execute binary file
I think it may be time to install nix on the raspberry pi's standard install, and then build the nixos image there.
Okay, so, I don't think --system aarch64-linux
will help you here. That's just for the new CLI: https://nixos.org/manual/nix/stable/command-ref/new-cli/nix.html?highlight=--system#options. The equivalent for nix-build
I think is --argstr system aarch64-linux
. I think you're not actually building on the remote as a result of this.
Also, I noticed that 'ssh-ng://builder@localhost?ssh-key=/etc/nix/builder_ed25519'
doesn't include the system of the linux VM. I think it should be 'ssh-ng://builder@localhost?ssh-key=/etc/nix/builder_ed25519 aarch64-linux'
.
NB there shouldn't be any cross compilation (from Nix's perspective here) as our virtualization buildPlatform
(nomenclature from https://nixos.org/manual/nixpkgs/stable/#chap-cross) matches our hostPlatform
of aarch64-linux
.
If the above doesn't work out I'd encourage you to try the flake option above (the new CLI has a better UX imo).
I'm also happy to build this image for you and share the binary which might be a lot easier!
Thank you again for your help. Part of this is to aid my understanding/learning. So I'm happy to keep trying, though I appreciate the offer.
Re the nix store
command, definitely only this works:
nix store ping --store 'ssh-ng://builder@localhost?ssh-key=/etc/nix/builder_ed25519'
If I include the arch it thinks it's part of the key path and fails.
However, on the nix build
command, it is now finding the full builder definition that I have in /etc/nix/nix.conf
, which does include the arch, etc.
Now we're getting close. I think it's all working as far as the darwin.builder
goes. But there is an actual build error now (I've verified the same error is occurring on the Pi and on the builder:
error: build of '/nix/store/600mg4p4h448iyj28788cds6sjsncvwc-linux-5.15.84-1.20230106-modules-shrunk.drv' on 'ssh-ng://builder@localhost' failed: builder for '/nix/store/600mg4p4h448iyj28788cds6sjsncvwc-linux-5.15.84-1.20230106-modules-shrunk.drv' failed with exit code 1;
last 10 log lines:
> copying dependency: /nix/store/4wj95ngckp0zg3ihyw5x62b0af39xkaj-linux-5.15.84-1.20230106-modules/lib/modules/5.15.84/kernel/drivers/message/fusion/mptscsih.ko.xz
> copying dependency: /nix/store/4wj95ngckp0zg3ihyw5x62b0af39xkaj-linux-5.15.84-1.20230106-modules/lib/modules/5.15.84/kernel/drivers/message/fusion/mptspi.ko.xz
> root module: vmxnet3
> copying dependency: /nix/store/4wj95ngckp0zg3ihyw5x62b0af39xkaj-linux-5.15.84-1.20230106-modules/lib/modules/5.15.84/kernel/drivers/net/vmxnet3/vmxnet3.ko.xz
> root module: vsock
> copying dependency: /nix/store/4wj95ngckp0zg3ihyw5x62b0af39xkaj-linux-5.15.84-1.20230106-modules/lib/modules/5.15.84/kernel/net/vmw_vsock/vsock.ko.xz
> root module: simplefb
> builtin dependency: simplefb
> root module: sun4i-drm
> modprobe: FATAL: Module sun4i-drm not found in directory /nix/store/4wj95ngckp0zg3ihyw5x62b0af39xkaj-linux-5.15.84-1.20230106-modules/lib/modules/5.15.84
For full logs, run 'nix log /nix/store/600mg4p4h448iyj28788cds6sjsncvwc-linux-5.15.84-1.20230106-modules-shrunk.drv'.
error: builder for '/nix/store/600mg4p4h448iyj28788cds6sjsncvwc-linux-5.15.84-1.20230106-modules-shrunk.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/fdqr3dv8c14i8gxf8wwrycv9xgbf6pc6-stage-1-init.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/92hcy2ji71cp9liw8qah12b7479v6kf2-initrd-linux-5.15.84-1.20230106.drv' failed to build
error: 1 dependencies of derivation '/nix/store/s82blwyr204yxr28c1jcqjddcrfmnvlq-nixos-system-nixos-23.05pre-git.drv' failed to build
error: 1 dependencies of derivation '/nix/store/vbjighz5hv6hjqpsjwbyasai8y0fg73w-ext4-fs.img.zst.drv' failed to build
error: 1 dependencies of derivation '/nix/store/np5r3159q0acgl1c85gzpy02mji1calk-nixos-sd-image-23.05pre-git-aarch64-linux.img.drv' failed to build
Which appears to be this issue (link to preposed solution that I haven't tried yet): https://github.com/NixOS/nixpkgs/issues/154163#issuecomment-1350599022
Whoa. I added the overlay in that link and bam. It compiled!
Re the
nix store
command, definitely only this works:nix store ping --store 'ssh-ng://builder@localhost?ssh-key=/etc/nix/builder_ed25519'
If I include the arch it thinks it's part of the key path and fails.
Strange...
Whoa. I added the overlay in that link and bam. It compiled!
Magic! Let me know if it boots on the Pi okay.
It boots, but the manual and the installation guide suggest I should have been automatically logged in. However, there is a login prompt and I have no idea what the login details are!
I tried nixos
with no password. But that's not it. So close!
Ah, I think you need users.users.root.initialHashedPassword = "";
!
This is defined here (and the nixos user here).
That's my bad, it looks like what we really wanted was https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix, which imports https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/sd-card/sd-image-aarch64.nix.
Yep. I worked it out. Just copying the new image across to my SD card now…
I'm in. Awesome. Thank you so much or your guidance. I learned a lot, including more places to look for info and answers. Cheers. 🎉
You're welcome! Glad I could help :)
@ryanbooker Would you consider writing up a gist on the full sequence to set up a builder on Mac and create a working bootable NixOS image for RPi 4? It's a little hard to piece together from this thread. Thank you.
I would be very interested in the write up as well. I spent way to much time on this little thing already. Unbelievable that high resolution monitors (1080p+) are still such a big problem with it. I'm trying to get my rpi4 up and running with a 1440p one here.
One other alternative is using GitHub Actions to build the image. This is example is for a Pi 3 but builds an image and uploads it as a release artifact: https://github.com/n8henrie/nixos-btrfs-pi
Similar idea but builds an x86_64 NixOS rescue image that I can download from anywhere and throw on a USB: https://github.com/n8henrie/nixos-rescue
Describe the bug
If I do a
nixos-rebuild switch && reboot
or boot from the latestnixos-sd-image-22.05.1241.5ec2af9f483-aarch64-linux.img.zst
, I no longer get a login prompt/shell and the monitor goes into power saving mode.Steps To Reproduce
Steps to reproduce the behavior:
nixos-sd-image-21.11.335677.ceaca998029-aarch64-linux.img.zst
nixos-generate-config && nixos-rebuild switch && reboot
(System comes back up fine)nix-channel --update && nixos-rebuild switch
(Note that console font size changes but otherwise things seem ok)reboot
No Signal
Expected behavior
I expect to see a login prompt after boot, or at least console output showing an error. When booting from the latest installer I expect to see a
bash
shell prompt.Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
This is a minimal config with no xserver enabled. If I enable openssh, it seemed to take a really long time before accepting connections, but eventually it did and I was able to get these errors from
dmesg
nvd diff
shows these changes betweenceaca998029
and891016b5cf1
(sorry this was after including my standard configuration [on both sides], so includes some irrelevant packages):Notify maintainers
Not sure. @blitz @samueldr maybe know something?
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.