"EGL_EXT_platform_base not supported" after upgrade / moving to flakes

I tried to upgrade my system and converted my NixOS configuration to a flake. Now I ended up with a broken configuration and no path back because I didn’t keep my /etc/nixos in git (… :roll_eyes: yes, I know what you’re thinking). When I try to start sway from the cli I get the following error:

00:00:00.052 [ERROR] [wlr] [render/egl.c:204] EGL_EXT_platform_base not supported
00:00:00.052 [ERROR] [wlr] [render/egl.c:506] Failed to create EGL context
00:00:00.052 [ERROR] [wlr] [render/gles2/renderer.c:679] Could not initialize EGL
00:00:00.052 [ERROR] [wlr] [render/wlr_renderer.c:333] Could not initialize renderer
00:00:00.052 [ERROR] [sway/server.c:79] Failed to create renderer

I can’t share my full nixos configuration since I haven’t implemented proper secrets management. But these should be the relevant parts:

flake.nix

{
  description = "NixOS configuration";

  inputs = {
    nixpkgs.url = "nixpkgs/nixos-23.05";
    home-manager = {
      url = "github:nix-community/home-manager/release-23.05";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    sops-nix.url = "github:Mic92/sops-nix";
  };

  outputs = inputs @ { self, nixpkgs, home-manager, sops-nix }:
    let system = "x86_64-linux"; in {
      nixosConfigurations = {
        beni-machine = nixpkgs.lib.nixosSystem {
          inherit system;
          specialArgs = { inherit inputs; };
          modules = [
            ./hardware-configuration.nix 
            ./configuration.nix
            sops-nix.nixosModules.sops
            home-manager.nixosModules.home-manager
            {
              nix.registry.nixpkgs.flake = nixpkgs;
              home-manager = {
                useGlobalPkgs = true;
                useUserPackages = true;
                backupFileExtension = "home-manager-backup";
                users.beni = import ./home.nix;
              };
            }
          ];
        };
      };
    };
}

configuration.nix

{ config, pkgs, ... }:
{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      ./networking.nix
      ./vim.nix
      ./python.nix
      ./beni.nix
      ./tmux.nix
      ./podman.nix
      ./texlive.nix
      ./power.nix
      ./syncthing.nix
    ];
  nix.settings.experimental-features = [ "nix-command" "flakes" ];  
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi = {
    canTouchEfiVariables = true;
    efiSysMountPoint = "/boot/efi";
  };
  time.timeZone = "Europe/Zurich";
  i18n.defaultLocale = "en_US.UTF-8";
  i18n.extraLocaleSettings = {
    LC_TIME = "de_CH.UTF-8";
  };
  services.xserver.layout = "eu";
  services.printing.enable = true;
  security.sudo.wheelNeedsPassword  = false;
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };
  services.xserver.libinput = {
    enable = true;
    touchpad = {
      middleEmulation = true; 
      tapping = true;
    };
  };
  environment.systemPackages = with pkgs; [
     git
     wget
     htop
     pstree
     netcat
     file
     unzip
     jq
     dig
     sl
     cowsay
  ];
  programs.light.enable = true;
  security.polkit.enable = true;
  users.users.beni.extraGroups = [ "video" ];
  system.stateVersion = "22.11"; # Did you read the comment?
}

hardware-configuration.nix

{ config, lib, pkgs, modulesPath, ... }:
{
  imports =
    [ (modulesPath + "/installer/scan/not-detected.nix")
    ];
  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];
  fileSystems."/" =
    { device = "/dev/disk/by-uuid/67e510be-4fa1-4ee1-89c5-64354e7e89b8";
      fsType = "ext4";
    };
  boot.initrd.luks.devices = 
    { "luks-687c86b3-ce38-44b5-b992-571b6d79d0ee".device = "/dev/disk/by-uuid/687c86b3-ce38-44b5-b992-571b6d79d0ee";
      "luks-d499588e-b7a7-4e2b-a4f7-5f92574e5606".device = "/dev/disk/by-uuid/d499588e-b7a7-4e2b-a4f7-5f92574e5606";
    };
  fileSystems."/boot/efi" =
    { device = "/dev/disk/by-uuid/4CB3-5B6F";
      fsType = "vfat";
    };
  swapDevices =
    [ { device = "/dev/disk/by-uuid/121b1eab-6132-4c6b-857f-660e12e8d4c6"; }
    ];
  networking.useDHCP = lib.mkDefault true;
  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

sway.nix

{ config, pkgs, lib, ... }:
let
  dbus-sway-environment = pkgs.writeTextFile {
    name = "dbus-sway-environment";
    destination = "/bin/dbus-sway-environment";
    executable = true;
    text = ''
  dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
  systemctl --user stop pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
  systemctl --user start pipewire pipewire-media-session xdg-desktop-portal xdg-desktop-portal-wlr
      '';
  };
  configure-gtk = pkgs.writeTextFile {
      name = "configure-gtk";
      destination = "/bin/configure-gtk";
      executable = true;
      text = let
        schema = pkgs.gsettings-desktop-schemas;
        datadir = "${schema}/share/gsettings-schemas/${schema.name}";
      in ''
        export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
        gnome_schema=org.gnome.desktop.interface
        gsettings set $gnome_schema gtk-theme 'Dracula'
        '';
  };
in
{
  environment.systemPackages = with pkgs; [
    alacritty # gpu accelerated terminal
    foot
    sway
    dbus-sway-environment
    configure-gtk
    wayland
    xdg-utils # for opening default programs when clicking links
    glib # gsettings
    dracula-theme # gtk theme
    gnome3.adwaita-icon-theme  # default gnome cursors
    swaylock
    swayidle
    grim # screenshot functionality
    slurp # screenshot functionality
    wl-clipboard # wl-copy and wl-paste for copy/paste from stdin / stdout
    bemenu # wayland clone of dmenu
    mako # notification system developed by swaywm maintainer
    lm_sensors # Battery percentage
    pamixer # For the volume keys
  ];
  security.polkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    pulse.enable = true;
  };
  services.dbus.enable = true;
  xdg.portal = {
    enable = true;
    wlr.enable = true;
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
  };
  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
  };
  programs.light.enable = true;
}

I don’t even know where to start to debug this. Any tips or hints?

Thank you

–beni

For some reason I haven’t found this topic when I researched my problem. However, its solution fixes the problem:

TL;DR:

hardware.opengl.enable = true