Sdl application broken after upgrading from 25.05 to 25.11

Hi I have a HTPC where I use NixOS and as my start interface i use flex-launcher that is built using SDL2.

I start it using wayland and cage and I have created a minimal config to reproduce the issue (I have used a hyper-v vm to reproduce the issue, but the same or a similar issue happens on real hardware)

# Base minimum configuration to get started
{ config, lib, pkgs, ... }:

{
  imports =
    [
      ./hardware-configuration.nix
    ];
  virtualisation.hypervGuest.enable = true;
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  networking.networkmanager.enable = true;

  users = {
    users = {
      htpc = {
        uid = 1001;
        isNormalUser = true;
        extraGroups = [
          "input"
          "dialout"
          "video"
          "render"
          "audio"
        ];
        group = "htpc";
        packages =  with pkgs; [
          xterm
          flex-launcher
        ];
      };
    };
    groups.htpc = {
      gid = 1001;
    };
  };

  users.extraUsers.htpc.isNormalUser = true;
  services.cage = {
    enable = true;
    user = "htpc";
    program = "${pkgs.flex-launcher}/bin/flex-launcher -d";
    extraArguments = [ "-d" ];
  };

  services.openssh = {
    enable = true;
    settings = {
      PasswordAuthentication = true;
      AllowUsers = null;
      PermitRootLogin = "yes";
    };
  };

  hardware = {
    graphics.enable = true;
    #alsa.enable = true;
  };

  system.stateVersion = "25.05"; # Do not change this value you fool!
}

After upgrading to 25.11 I’m only met with a black screen with nothing on it..

If I instead force nixos to use the latest commit of flex-launcher (plus som additional logging i added my self) with the following

  # Force flex-launcher to use a fork with improved logging (also contains fixes for sdl that aren't in any release yet)
  nixpkgs.overlays = [
    (final: prev: {
      # nix-shell -p nix-prefetch-github
      # nix-prefetch-github --nix AnderssonPeter flex-launcher
      flex-launcher = prev.flex-launcher.overrideAttrs (old: {
        src = prev.fetchFromGitHub {
          owner = "AnderssonPeter";
          repo = "flex-launcher";
          rev = "b2640e734c70853e2e8c27ce7c2ff550f79102e5";
          hash = "sha256-SnkWM5xPA0YSBXWmSEM5OV+RCJp3ustpwg422dth88o=";
        };
      });
    })
  ];

The flex-launcher application just craches on 25.11 (but the application still works on 25.05 with the newer version of flex-launcher)

The application logs the following when crashing:

Flex Launcher version 2.2, using:
  SDL       2.32.60
  SDL_image 2.8.8
  SDL_ttf   2.24.0

Build date: Jan  1 1980
Compiler:   GCC 14.3

Config file found: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/config.ini
Initializing SDL
Initializing SDL_image
Initializing SDL_ttf
Validating settings...
Highlight padding value 25 too large to fit screen, shrinking to 0
Icon spacing value 51 too large to fit screen, shrinking to 0
Initializing SVG rasterizer
Creating SDL Window and Renderer
Hiding mouse cursor
Creating SDL Renderer

So it crashes on the following line: flex-launcher/src/launcher.c at b2640e734c70853e2e8c27ce7c2ff550f79102e5 · AnderssonPeter/flex-launcher · GitHub

And the systemd cage log says the following

Mar 10 19:31:17 nixos systemd[1]: Started cage-tty1.service.
Mar 10 19:31:17 nixos (cage)[3572]: pam_unix(cage:session): session opened for user htpc(uid=1001) by htpc(uid=0)
Mar 10 19:31:18 nixos systemd[1]: cage-tty1.service: Main process exited, code=dumped, status=6/ABRT
Mar 10 19:31:18 nixos systemd[1]: cage-tty1.service: Failed with result 'core-dump'.

From checking the log of flex-launcher on 25.05 I can see that sdl seems to use a x11 video driver.

So I managed to force it to use wayland by setting the env variables SDL_VIDEODRIVER and SDL_VIDEO_DRIVE to ”wayland” while the application no longer crashes it just displays a black screen.

the flex-launcher log can be found under /home/htpc/.local/share/flex-launcher/flex-launcher.log and when it starts up and displays a black screen i get the following log

Flex Launcher version 2.2, using:
  SDL       2.32.60
  SDL_image 2.8.8
  SDL_ttf   2.24.0

Build date: Jan  1 1980
Compiler:   GCC 14.3

Config file found: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/config.ini
Initializing SDL
Initializing SDL_image
Initializing SDL_ttf
Validating settings...
Highlight padding value 25 too large to fit screen, shrinking to 0
Icon spacing value 51 too large to fit screen, shrinking to 0
Initializing SVG rasterizer
Creating SDL Window and Renderer
Hiding mouse cursor
Creating SDL Renderer
Setting renderer blend mode to blend
Setting renderer draw color
================== Video Information ===================

Resolution:    1024x768
Refresh rate:  60 Hz
Video driver:  wayland

Supported Texture formats:
  SDL_PIXELFORMAT_ARGB8888
  SDL_PIXELFORMAT_ABGR8888
  SDL_PIXELFORMAT_RGB888
  SDL_PIXELFORMAT_BGR888
  SDL_PIXELFORMAT_YV12
  SDL_PIXELFORMAT_IYUV
  SDL_PIXELFORMAT_NV12
  SDL_PIXELFORMAT_NV21

======================= General ========================

DefaultMenu:              Main
VSync:                    true
FPSLimit:                 -1
ApplicationTimeout:       15
OnLaunch:                 Blank
WrapEntries:              false
ResetOnBack:              false
MouseSelect:              false
InhibitOSScreensaver:     true
StartupCmd:               (null)
QuitCmd:                  (null)

===================== Background =======================

Mode:                     Color
Color:                    #000000FF
Image:                    (null)
SlideshowDirectory:       (null)
SlideshowImageDuration:   30
SlideshowTransitionTime:  1.50
Overlay:                  false
OverlayColor:             #0000007F

======================= Layout =========================

MaxButtons:               4
IconSize:                 256
IconSpacing:              0
VCenter:                  50%

======================== Titles ========================

Enabled:                  true
Font:                     /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/fonts/OpenSans-Regular.ttf
FontSize:                 36
Color:                    #FFFFFFFF
Shadows:                  false
ShadowColor:              #000000FF
OversizeMode:             Shrink
Padding:                  20

====================== Highlight =======================

FillColor:                #FFFFFF3F
OutlineSize:              0
OutlineColor:             #0000FFFF
CornerRadius:             0
VPadding:                 30
HPadding:                 0

================== Scroll Indicators ===================

Enabled:                  true
FillColor:                #FFFFFFFF
OutlineSize:              0
OutlineColor:             #000000FF

======================== Clock =========================

Enabled:                  false
ShowDate:                 false
Alignment:                Left
Font:                     /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/fonts/SourceSansPro-Regular.ttf
FontSize:                 50
Margin:                   38
FontColor:                #FFFFFFFF
Shadows:                  false
ShadowColor:              #000000FF
TimeFormat:               Auto
DateFormat:               Auto
IncludeWeekday:           true

===================== Screensaver ======================

Enabled:                  false
IdleTime:                 300
Intensity:                70%
PauseSlideshow:           true

======================= Gamepad ========================

Enabled:                  false
DeviceIndex:              -1
ControllerMappingsFile:   (null)
LStickX-                  :left
LStickX+                  :right
ButtonA                   :select
ButtonB                   :back
ButtonDPadLeft            :left
ButtonDPadRight           :right

======================== Hotkeys =========================

Hotkey 0 Keycode: 1B
Hotkey 0 Command: :quit

======================= Menu Entries =======================

Menu Name: Main
Number of Entries: 4
Entry 0 Title: Kodi
Entry 0 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/kodi.png
Entry 0 Command: /usr/share/applications/kodi.desktop

Entry 1 Title: Plex
Entry 1 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/plex.png
Entry 1 Command: /usr/share/applications/plexmediaplayer.desktop;TVF

Entry 2 Title: Steam
Entry 2 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/steam.png
Entry 2 Command: /usr/share/applications/steam.desktop;BigPicture

Entry 3 Title: System
Entry 3 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/system.png
Entry 3 Command: :submenu System
----------------------------------------------------------
Menu Name: System
Number of Entries: 3
Entry 0 Title: Shutdown
Entry 0 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/system.png
Entry 0 Command: :shutdown

Entry 1 Title: Restart
Entry 1 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/restart.png
Entry 1 Command: :restart

Entry 2 Title: Sleep
Entry 2 Icon Path: /nix/store/pvh35nfa77xpcj946szn66lfkmp3730y-flex-launcher-2.2/share/flex-launcher/assets/icons/sleep.png
Entry 2 Command: :sleep

Loading menu 'Main'
Begin program loop
Gained keyboard focus
Key Numlock (#40000053) detected
Key Numlock (#40000053) detected

I’m no C developer or Linux expert so I’m a bit lost on how to debug the issue further, does anyone have a idea what could be the issue or how to solve it?

At the moment my only idea is to switch to x11, but that would mean I would have to setup a number of application all again (With som luck they just work on x11 but who knows).

It appears to be an issue with cage 0.2.1, and not isolated to just flex-launcher, here’s an issue raised with Kodi Kodi black screen with 73bf1c8 · Issue #469 · cage-kiosk/cage · GitHub . They mention in that issue that it works with 0.2.0.

If you’re using flakes, you could do what I’ve done. Add this into your inputs, which is just referencing an older nixpkgs commit when cage was still 0.2.0.

"nixpkgs-cage-0.2.0".url = "github:NixOS/nixpkgs/aa725fdeba9963ed389ff641aaf6209988adda7d";

And then you can add cage to your overlays.

  nixpkgs.overlays = [
    (final: prev: {
      cage = inputs."nixpkgs-cage-0.2.0".legacyPackages.${prev.stdenv.hostPlatform.system}.cage;

      # and your flex-launcher overlay if you want.
    })
  ];
1 Like

Is there any way to do this when not using flakes?, I have tried to do it using overlays, but I got some build errors :confused:

  nixpkgs.overlays = [
    (self: prev: {
      cage = prev.cage.overrideAttrs (old: {
        src = prev.fetchFromGitHub {
          owner = "cage-kiosk";
          repo = "cage";
          rev = "e128a9f2511644529fa47701a7147d65d9920488";
          hash = "sha256-2SFtz62z0EF8cpFTC6wGi125MD4a5mkXqP/C+7fH+3g=";
        };
      });
    })
  ];

When I run nisos-rebuild switch I get the following error:

The Meson build system
Version: 1.9.1
Source dir: /build/source
Build dir: /build/source/build
Build type: native build
Project name: cage
Project version: 0.2.0
C compiler for the host machine: gcc (gcc 14.3.0 "gcc (GCC) 14.3.0")
C linker for the host machine: gcc ld.bfd 2.44
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: YES (/nix/store/x06h0jfzv99c3dmb8pj8wbmy0v9wj6bd-pkg-config-wrapper-0.29.2/bin/pkg-config) 0.29.2
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency wlroots-0.18 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency wlroots-0.18
ERROR: Subproject wlroots is buildable: NO

meson.build:38:17: ERROR: Attempted to resolve subproject without subprojects directory present.

A full log can be found at /build/source/build/meson-logs/meson-log.txt
error: Cannot build '/nix/store/ws3hlypdchzrsmrf13s954aklalh8hq3-cage-0.2.1.drv'.
       Reason: builder failed with exit code 1.
       Output paths:
         /nix/store/v18ccadx8ijpmc5j2bwrcq0qig2449nq-cage-0.2.1
error: Cannot build '/nix/store/x3d7zg88jpyc9nnb779j43r5fnga1a1k-unit-cage-tty1.service.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/wnk6llk9wmkhc3masppvm4ijnibg49aw-unit-cage-tty1.service
error: Cannot build '/nix/store/2amgkz885z0f9r1xipyk53zm1axm2aka-system-units.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/5n4bhxyb5v8dxwlyjvd4hbzryd4lz340-system-units
error: Cannot build '/nix/store/dx7kqd1vf95n67j07fhm8pzshgwddppb-etc.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/qfmqv0laip4klbcmw8789xdxy2489k84-etc
error: Cannot build '/nix/store/qk7pkrldq2qczgaixm3lb2kpq14vw18c-nixos-system-nixos-25.11.7346.44bae273f9f8.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/q0i0cg3xl105kqxpgfmhr6m32vj5r5rk-nixos-system-nixos-25.11.7346.44bae273f9f8
Command 'nix-build '<nixpkgs/nixos>' --attr config.system.build.toplevel --no-out-link' returned non-zero exit status 100.

I’m hoping this page will help you: FAQ/Pinning Nixpkgs - Official NixOS Wiki

Because what I’m doing in the flake is getting an older version of nixpkgs in its entirety, which includes both the older version of the package and the older build instructions. With just the override you’re doing it’s an old version of the code with the new nixpkgs build instructions, which could be why it’s breaking.

I tested this in my flake, but tweaked it to match what you’re trying to do, hopefully it works for you?

nixpkgs.overlays = [
  (final: prev: {
    cage = (import (fetchGit {
      # Descriptive name to make the store path easier to identify
      name = "nixpkgs-cage-0_2_0";
      url = "https://github.com/NixOS/nixpkgs/";
      rev = "aa725fdeba9963ed389ff641aaf6209988adda7d";
      shallow = true;
    }) { }).pkgs.cage;
  };
];

If someone is trying to use this in a flake, it’ll complain about missing builtins.currentSystem. You can use it if you run the flake with --impure, but I think you can also specify localSystem = … when you import it (not at all tested).

For what it’s worth, having gone back to this, it seems like cage 0.3.0 was added recently, and that’s working for me now, as well. So you may not require the older version anymore (I think it’s available on stable 26.05) cage: 0.2.1 -> 0.3.0 · NixOS/nixpkgs@adc71aa · GitHub

1 Like

Hi I just upgraded my htpc to nix os 26.05, but sadly it has the same problem, I verified that i have cage version 0.3.0, but the issue presists.

After checking the cage github, it seems the fix was first included in 0.3.1.

I managed to fix the issue by forcing 0.3.1 with the following:

  nixpkgs.overlays = [
    (final: prev: {
      # nix-shell -p nix-prefetch-github
      # nix-prefetch-github --nix AnderssonPeter flex-launcher
      cage = prev.cage.overrideAttrs (old: {
        src = prev.fetchFromGitHub {
          owner = "cage-kiosk";
          repo = "cage";
          rev = "b7b774ac957b6d8c7b39f0dcb9ebe19de3e8a45d";
          hash = "sha256-FHIOicRBL881Kvvui4HTKy0g7K9HcQ0ineLECh6MqFI=";
        };
      });
    })
  ];

And now it seems to work, the only thing I have noticed is that kodi takes a loooong time to exit