# NixOS support for CM4

**URL:** <https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925>\
**Category:** uConsole\
**Created:** [April 3, 2024, 9:33pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925 "2024-04-03T21:33:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [April 3, 2024, 9:33pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/1 "2024-04-03T21:33:22Z")

</div>

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:

- main repo: [voidcontext/nixos-uconsole - forgejo @ git.vdx.hu](https://git.vdx.hu/voidcontext/nixos-uconsole)
- GitHub mirror (for collaboration purposes): [GitHub - voidcontext/nixos-uconsole: Mirror of https://git.vdx.hu/voidcontext/nixos-uconsole](https://github.com/voidcontext/nixos-uconsole)

---

<div class="post-metadata">

**Author:** ![Cris3zoo](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/cris3zoo/32/7999_2.png) [@Cris3zoo](https://forum.clockworkpi.com/u/Cris3zoo)\
**Post date:** [April 3, 2024, 9:40pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/2 "2024-04-03T21:40:47Z")

</div>

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

> **[uConsole/Code at master · clockworkpi/uConsole](https://github.com/clockworkpi/uConsole/tree/master/Code)**
>
> This code repository offers downloads for the latest images of various uConsole models, along with kernel patches, firmware for the keyboard and 4G expansion module, hardware schematics, assembly i...

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

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [April 3, 2024, 9:51pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/3 "2024-04-03T21:51:42Z")

</div>

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

> **[GitHub - PotatoMania/uconsole-cm3: Now you can put RPi CM3 in your uConsole!](https://github.com/PotatoMania/uconsole-cm3)**
>
> Now you can put RPi CM3 in your uConsole! Contribute to PotatoMania/uconsole-cm3 development by creating an account on GitHub.

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

> **[clockworkpi-uconsole: new device (!4751) · Merge requests · postmarketOS /...](https://gitlab.com/postmarketOS/pmaports/-/merge_requests/4751/diffs#bd79144e5cc837bf2ff3f43b19a303078b1b9008)**
>
> I ported postmarketOS to the ClockworkPi uConsole. I supported the Raspberry CM4 edition, as it's what I have. I think...

---

<div class="post-metadata">

**Author:** ![Snoozer94](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Snoozer94](https://forum.clockworkpi.com/u/Snoozer94)\
**Post date:** [April 3, 2024, 10:56pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/4 "2024-04-03T22:56:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hihihihinick](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/hihihihinick/32/9270_2.png) [@hihihihinick](https://forum.clockworkpi.com/u/hihihihinick)\
**Post date:** [April 4, 2024, 3:52pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/5 "2024-04-04T15:52:54Z")

</div>

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](https://jhewitt.net/uconsole)

---

<div class="post-metadata">

**Author:** ![TGHx](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@TGHx](https://forum.clockworkpi.com/u/TGHx)\
**Post date:** [April 5, 2024, 12:09am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/6 "2024-04-05T00:09:40Z")

</div>

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](https://wiki.nixos.org/wiki/NixOS_on_ARM/Clockworkpi_A06_uConsole)

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [April 5, 2024, 6:33am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/7 "2024-04-05T06:33:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yochi](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@Yochi](https://forum.clockworkpi.com/u/Yochi)\
**Post date:** [April 5, 2024, 5:01pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/9 "2024-04-05T17:01:57Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [April 5, 2024, 8:36pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/10 "2024-04-05T20:36:40Z")

</div>

Current state:

 ![IMG_7467](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/c/c3ca467b5650a009e191e506e6b11592a6901404.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [April 10, 2024, 9:08pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/11 "2024-04-10T21:08:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![0x17](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/0x17/32/9584_2.png) [@0x17](https://forum.clockworkpi.com/u/0x17)\
**Post date:** [June 3, 2024, 11:19am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/12 "2024-06-03T11:19:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [June 4, 2024, 9:59am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/14 "2024-06-04T09:59:22Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![0x17](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/0x17/32/9584_2.png) [@0x17](https://forum.clockworkpi.com/u/0x17)\
**Post date:** [June 4, 2024, 10:06am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/15 "2024-06-04T10:06:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![0x17](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/0x17/32/9584_2.png) [@0x17](https://forum.clockworkpi.com/u/0x17)\
**Post date:** [June 6, 2024, 9:13am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/16 "2024-06-06T09:13:19Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [June 6, 2024, 9:43am UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/17 "2024-06-06T09:43:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [June 6, 2024, 12:25pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/18 "2024-06-06T12:25:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![0x17](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/0x17/32/9584_2.png) [@0x17](https://forum.clockworkpi.com/u/0x17)\
**Post date:** [June 6, 2024, 1:05pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/19 "2024-06-06T13:05:25Z")

</div>

that would be cool - please do it 🥰

---

<div class="post-metadata">

**Author:** ![J340m3](https://yyz1.discourse-cdn.com/flex029/user_avatar/forum.clockworkpi.com/j340m3/32/8852_2.png) [@J340m3](https://forum.clockworkpi.com/u/J340m3)\
**Post date:** [June 20, 2024, 2:34pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/20 "2024-06-20T14:34:03Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![voidcontext](https://avatars.discourse-cdn.com/v4/letter/v/ba8739/32.png) [@voidcontext](https://forum.clockworkpi.com/u/voidcontext)\
**Post date:** [June 21, 2024, 8:48pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/21 "2024-06-21T20:48:02Z")

</div>

Hi @J340m3, this is my current configuration: [https://git.vdx.hu/voidcontext/nix-config/src/branch/main/hosts/orkaria/configuration.nix](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.

---

<div class="post-metadata">

**Author:** ![johndoe](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@johndoe](https://forum.clockworkpi.com/u/johndoe)\
**Post date:** [October 9, 2024, 5:34pm UTC](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925/22 "2024-10-09T17:34:42Z")

</div>

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…

 ![rpi-nixos](https://canada1.discourse-cdn.com/flex029/uploads/clockworkpi/original/2X/2/2d118a652803f1df7b07bc288c8332cab3b7d3fc.jpeg)

[Next page](https://forum.clockworkpi.com/t/nixos-support-for-cm4/12925.md?page=2)
