NixOS support for CM4

I always wanted to run NixOS on my uConsole, even before it arrived. Now that I finally have it my hands, I’ve spent a lot of time reading, and trying stuff out. Based on different threads here and some github repos, I was able to come up with a basic NixOS configuration to build a base SD card image.

I can’t say it’s a success story: the system boots, but the built-in display doesn’t work, so the boot had to be confirmed over HDMI. Then it is impossible to log in since the keyboard doesn’t work (even USB keyboards aren’t).

I’ll keep tweaking it, but if anyone is interested and wants to try it out or help, the code is available at:

6 Likes

I’m doing the same with kali linux
Although I’m not expert in linux but these files might help

Also how did you manage to config an image?
Secondly did you manage to l
Patch it with the above files?

I guess the “how” is very NixOS specific, but I got lots of ideas and some patches from

and
https://jhewitt.net/uconsole
then, there’s this for inspiration as well:

Will have to give these a look through plus im happy to try a new os and mess about with it, ill let you know if i manage to figure anything out.

This isn’t the most helpful for NixOS but It’s a much more comprehensive guide, and explanation of how to patch the kernel with the DTO’s needed for the screen, keyboard, ect than clockworks, or other guides

https://jhewitt.net/uconsole

1 Like

I am interested in this as well. it seems like someone has had some success adding support for the A06 version to NixOS. Would like to see the same for the CM4. NixOS on ARM/Clockworkpi A06 uConsole - NixOS Wiki

1 Like

Actually yesterday I was able to sort out the display, the keyboard, etc. I just had to apply the device tree overlays properly, the NixOS way… Since I was able to log in using the keyboard, I also verified that the wifi is not working, so that’s the next. The config is available in the repo from the first post.

This is very exiting. I hope once major bugs are squashed, we could have an image that we could just flash, for the plebs like myself…

Current state:

Wifi works, bluetooth doesn’t. I’ll need to clean up the code then I’ll push the latest changes into the repo, probably early next week.

11 Likes

So I pushed the code, it’s a bit messy, but I expect it to change (that’s why I am keeping lots of commented out stuff around). Basically I am using PotatoMania’s kernel patches, and the offical device tree overlays. Bluetooth doesn’t work, and wifi is slow, but as you can see I managed to install Gnome, etc.

3 Likes

Hey. I found this post. Does this image also work with the CM3+ or only with CM4?

I am affraid it’s CM4 only at the moment. It shouldn’t be diffucult to make it compatible with CM3 though as I was mainly using an arch linux build for CM3 as inspiration, but I don’t have the hardware to test…

ok. I ordered the adapter and a CM4 to be safe. I am not really into creating NixOS images at the moment :expressionless:

I setup everthing within NixOS and try to build the image. How long did the build process take for you? (It’s been running for me for a few hours)

I think that is normal, building the full image on a Raspberry Pi 4B (4GB ram) took around 7-8 hours. When the kernel package is crossbuilt on an Intel Core i7-6600 and the rest on the Raspberry, then it’s around 1.5 hours.

1 Like

I’ll think about the best way to make a prebuilt image downloadable and to publish the kernel into a public binary cache.

that would be cool - please do it :smiling_face_with_three_hearts:

Can you provide a working configuration.nix? When I try the default one, the screen/keyboard become unconfigured and I’ll have to start over again (no HDMI-Adapter for now). Other than that, NixOS runs on my uConsole, took a bit of time to build it :slight_smile:

Hi @J340m3, this is my current configuration: https://git.vdx.hu/voidcontext/nix-config/src/branch/main/hosts/orkaria/configuration.nix. I was experimenting with a few things, so there might be some configs that are not actually necessary, or don’t really do anything.

What do you mean by “become unconfigured”?

Also, congrats! Unfortunately, it is not as starightforward as it should be / could be.

1 Like

Hi, first: sorry for reviving the old thread…

last days I received my uC and start preparing the NixOS config… Now, I have a linux_rpi4 6.6.31-based kernel with the uC support.

Working: boot, display, backlight, hdmi output (but it’s kinda broken), keyboard, USB (at once USB-Ethernet adapter, keep in mind that it is USB2.0 port), bluetooth (%@#$), charging, battery, etc…

not working: audio

@voidcontext mainly I build my config upon your code, but instead of potatomania-patches I used some patches from ak-rex repo.

a quick notes: I have to remap the UART0 (CM4 default Bluetooth connection) in DeviceTree overlay to make it working. It’s kind a bug of NixOS’s kernel…

2 Likes