ryan4yin / nixos-rk3588

Minimal NixOS running on RK3588/RK3588s based SBC(Orange Pi 5 Plus, Orange Pi 5, Rock 5A, etc)
MIT License
130 stars 15 forks source link

OpenGL can't be installed due to panfork/mesa repository absence. #32

Open HeroBrine1st opened 4 months ago

HeroBrine1st commented 4 months ago

Hi

First, the actual issue:

This happens when you add hardware.opengl.enable = true to system configuration.

error: builder for '/nix/store/xy5dp5aggr6i803ib5z5vc2895hrwbj1-source.drv' failed with exit code 1;
       last 7 log lines:
       >
       > trying https://gitlab.com/api/v4/projects/panfork%2Fmesa/repository/archive.tar.gz?sha=120202c675749c5ef81ae4c8cdc30019b4de08f4
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >   0    35    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > error: cannot download source from any mirror
       For full logs, run 'nix log /nix/store/xy5dp5aggr6i803ib5z5vc2895hrwbj1-source.drv'.
error: 1 dependencies of derivation '/nix/store/gvhj13xj5slchablw89y28gfmpbwzk3y-mesa-panfork-23.0.0-panfork.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2iilbimbzvnby4k82csvb73a7g4ibkxw-opengl-drivers.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mzy6qgbn8za6hjfbj4f8kzg0hjpzb9z7-nixos-tmpfiles.d.drv' failed to build
error: 1 dependencies of derivation '/nix/store/wzpan2h56gnh04ppfcxg30zqqaf2rwlj-tmpfiles.d.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mzz37bhkxq7sds45r6gxp97z82b2l97r-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/l3d3mq3vfh2dk9ajad29phgvlg0ahs93-nixos-system-opi5-23.11.20240301.79baff8.drv' failed to build

Aforementioned file is required here:

https://github.com/ryan4yin/nixos-rk3588/blob/349f39dcaafeb41250544bcc066db8668a7762ce/modules/boards/base.nix#L70-L79

To be clear, I use this flake as input for my flake and installed NixOS directly on SSD.

I.e. I installed it like that ```nixos { description = "NixOS configuration"; inputs = { unstable.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-23.11"; nixos-rk3588.url = "github:ryan4yin/nixos-rk3588?rev=349f39dcaafeb41250544bcc066db8668a7762ce"; }; outputs = { nixpkgs, nixos-rk3588, ... }: let # using the same nixpkgs as nixos-rk3588 to utilize the cross-compilation cache. inherit (nixos-rk3588.inputs) nixpkgs; system = "aarch64-linux"; in { nixosConfigurations = { opi5 = nixpkgs.lib.nixosSystem { inherit system; specialArgs = { rk3588 = { inherit nixpkgs; pkgsKernel = import nixpkgs { inherit system; }; }; }; modules = [ nixos-rk3588.nixosModules.orangepi5.core # nixos-rk3588.nixosModules.orangepi5.sd-image ./system/configuration.nix ./system/hardware-configuration.nix ]; }; }; }; } ``` And configuration/hardware configuration is just like on flakeless system. (P.s. I'm new to NixOS, I have been installing this flake for 2 days (mostly due to 5 SD cards that have died in process) but it does work normally for my "home enterprise")

Second, my background research about this issue

Looks like panfork/mesa is gone without any information about that. After two days of searching I found this PR which explains almost everything.

Basically, panfork/mesa is gone due to personal nature of its maintainer. Also, AUR package mesa-panfork-git was available yesterday but is deleted today. Looks like panfork removal is just started so that I'm first to notice it.

There's also tsukumijima/libmali-rockchip that is mentioned in jellyfin PR. Some parts of it are probably needed for this flake to work with mainline Mesa, because Mesa probably already supports it. Again, probably - I'm a total noob in such hardware. I simply got excited that there's a working ffmpeg included in nightly jellyfin and now I'm frustrated.

And also there's a soft fork of panfork/mesa on github. I don't trust that and I'm honestly pretty suspicious of this fork, but seems like it is the same exact code and you can swap it clean and it'll work.

I leave this for other people's time sake for now.

HeroBrine1st commented 3 months ago

Mali G610 is just landed to Mesa 24.1. Probably we can go without panfork after nixpkgs have mesa 24.1.

If someone is less lazy than me to get their server Orange Pi from under the table or already have long enough HDMI cable, try hardware.opengl.package = lib.mkForce pkgs.mesa after Mesa 24.1 lands to nixpkgs. I'm going to test it too, but I probably will be postponing it until the sun dies.

This issue will be avoided (because panfork is not used), so you'll be sure that it uses mainstream mesa.

UPD: Actually, Mesa 24.1 is experimental, so we wait for 24.1.1 :-( Or override src and build locally

HeroBrine1st commented 2 months ago

Mesa 24.1.1 is just landed to unstable channel. I did no tests though.

HeroBrine1st commented 2 months ago

I did some tests. Using X11 forwarding, I got "Error: couldn't get an RGB, Double-buffered visual x11 forwarding" for glxgears.

Then I got OPi 5 on the table and did proper tests with proper configuraton. Got highly distorted image (green rectangle of 1/3 screen size on bottom, rendered picture stretched like on three monitors with single-pixel horizontal gaps filled with pixels from other regions and skipped pixels on vertical, making text highly distorted and unreadable), otherwise FPS was "ok". I took a screenshot, but it looks normal.

I did not see any hardware acceleration. There was no animations, and GNOME disables them when it falls back to software, so it obviously skipped it. I think the reason behind that is linux version requirement (6.6 minimum iirc), but I can't confirm that (no dmesg messages, nothing).

Could someone with panfork-mesa and hardware accelerated DE share their configuration? And it would be good if you confirm that x11 forwarding with glxgears works, because I'd rather not move my opi5 again.

I'll also probably keep and eye on armbian folks. Probably. I don't need OpenGL, so I did all that from pure curiosity.

I use UEFI btw, in device tree mode as said in UEFI.md.

UPD: A week passed, and I realized that the "proper configuration" used old mesa 24.0.7. I forgot about flake.lock. What a shame.

HeroBrine1st commented 2 months ago

I tested again:

{ pkgs, lib, ... }: {
  hardware.graphics.enable = true;
  hardware.graphics.package = lib.mkForce pkgs.mesa.drivers;
  environment.systemPackages = [
    pkgs.mesa-demos
  ];

  services.xserver.enable = true;
  services.xserver.videoDrivers = [ "panfrost" ];
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
}

This time mesa was 24.1.1 (I even ran nix flake update on target host to confirm that), and I also added panfrost driver (services.xserver.videoDrivers). Still stretched image, so I didn't even log in via gdm as it is obvious panfrost is not loaded. dmesg | grep panfrost still shows no output, even after modprobe panfrost.

Also nixpkgs deprecated hardware.opengl in favor of hardware.graphics, but this shouldn't be an issue.

UPD: Panthor driver is also required - we don't have it in our kernel.