From 97c6939a26b3d4dcac843030aa9911aff6b2e5f6 Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 17 Apr 2024 00:02:32 +0200 Subject: Nix build Linux with Wayland --- default.nix | 7 ++----- flake.nix | 12 +++++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/default.nix b/default.nix index 2c39828..e2e14cd 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ lib, clangStdenv, meson, ninja, pkg-config, lld, glew, glfw, Cocoa, OpenGL, libX11, libXau, libXdmcp }: +{ lib, clangStdenv, meson, ninja, pkg-config, lld, glew, glfw, Cocoa, OpenGL, wayland, wayland-protocols, libffi }: let stdenv = clangStdenv; @@ -12,10 +12,7 @@ stdenv.mkDerivation { nativeBuildInputs = [ meson ninja pkg-config lld ]; buildInputs = [ glew glfw ] ++ lib.optionals stdenv.isDarwin [ Cocoa OpenGL ] - # TODO: Wayland support. - # NOTE: Also, even without Wayland, do we really need to link against libXau and - # libXdmcp of all things?? - ++ lib.optionals stdenv.isLinux [ libX11 libXau libXdmcp ]; + ++ lib.optionals stdenv.isLinux [ wayland wayland-protocols libffi ]; mesonFlags = [ "--buildtype=release" diff --git a/flake.nix b/flake.nix index 2124904..b13d1e9 100644 --- a/flake.nix +++ b/flake.nix @@ -27,10 +27,12 @@ # NOTE: GLFW depends on OpenSSL and coreutils, which are very # large dependencies and have to be rebuilt from source to be able # to be linked statically. Maybe there is a way to avoid this? - glfw-static = pkgs.glfw.overrideAttrs { + glfw-static = (pkgs.glfw.overrideAttrs (oldAttrs: { pname = "glfw-static"; - cmakeFlags = [ "-DBUILD_SHARED_LIBS=OFF" ]; - }; + cmakeFlags = oldAttrs.cmakeFlags ++ [ + "-DBUILD_SHARED_LIBS=OFF" + ]; + })).override { waylandSupport = pkgs.stdenv.isLinux; }; glew-static = pkgs.glew.overrideAttrs { pname = "glew-static"; @@ -52,8 +54,8 @@ glfw-static glew-static ]) ++ lib.optionals stdenv.isDarwin (with darwinFrameworks; [ Cocoa OpenGL - ]) ++ lib.optionals stdenv.isLinux (with pkgs.xorg; [ - libX11 libXau libXdmcp + ]) ++ lib.optionals stdenv.isLinux (with pkgs; [ + wayland wayland-protocols libffi ]); }; }); -- cgit 1.4.1