diff options
| -rw-r--r-- | default.nix | 8 | ||||
| -rw-r--r-- | flake.lock | 8 | ||||
| -rw-r--r-- | flake.nix | 26 | ||||
| -rw-r--r-- | src/GFX/Window.cpp | 5 |
4 files changed, 20 insertions, 27 deletions
diff --git a/default.nix b/default.nix index e2e14cd..a019566 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{ lib, clangStdenv, meson, ninja, pkg-config, lld, glew, glfw, Cocoa, OpenGL, wayland, wayland-protocols, libffi }: +{ lib, clangStdenv, meson, ninja, pkg-config, lld, glew, glfw, wayland, wayland-protocols, libffi }: let stdenv = clangStdenv; @@ -10,8 +10,8 @@ stdenv.mkDerivation { src = ./.; nativeBuildInputs = [ meson ninja pkg-config lld ]; + # darwin provides the apple sdk dependencies by default buildInputs = [ glew glfw ] - ++ lib.optionals stdenv.isDarwin [ Cocoa OpenGL ] ++ lib.optionals stdenv.isLinux [ wayland wayland-protocols libffi ]; mesonFlags = [ @@ -26,7 +26,7 @@ stdenv.mkDerivation { description = "a dumb minecraft in c++ and opengl."; homepage = "https://git.rnrd.eu/meowcraft"; license = licenses.free; # TODO: Choose a specific license. - platforms = [ "x86_64-linux" "x86_64-darwin" ]; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; mainProgram = "meowcraft"; }; -}
\ No newline at end of file +} @@ -2,16 +2,16 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1712741485, - "narHash": "sha256-bCs0+MSTra80oXAsnM6Oq62WsirOIaijQ/BbUY59tR4=", + "lastModified": 1782847189, + "narHash": "sha256-twXPFqFsrrY5r28Zh7Homgcp2gUMBgQ6WDS98Q/3xFI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b2cf36f43f9ef2ded5711b30b1f393ac423d8f72", + "rev": "b6018f87da91d19d0ab4cf979885689b469cdd41", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-23.11", + "ref": "nixos-25.11", "type": "indirect" } }, @@ -2,12 +2,12 @@ description = "a dumb minecraft in c++ and opengl."; inputs = { - nixpkgs.url = "nixpkgs/nixos-23.11"; + nixpkgs.url = "nixpkgs/nixos-25.11"; }; - outputs = { self, nixpkgs }: + outputs = { self, nixpkgs }: let - allSystems = [ "x86_64-linux" "x86_64-darwin" ]; + allSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; pkgsForSystem = system: nixpkgs.legacyPackages.${system}; @@ -15,24 +15,18 @@ (system: f { inherit system; pkgs = pkgsForSystem system; }); in { - packages = forAllSystems ({ system, pkgs }: { + packages = forAllSystems ({ system, pkgs }: { default = pkgs.callPackage ./. { - inherit (pkgs.darwin.apple_sdk.frameworks) - Cocoa OpenGL; - glfw = self.packages.${system}.glfw-static; glew = self.packages.${system}.glew-static; }; - # 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 (oldAttrs: { + glfw-static = pkgs.glfw.overrideAttrs (oldAttrs: { pname = "glfw-static"; cmakeFlags = oldAttrs.cmakeFlags ++ [ "-DBUILD_SHARED_LIBS=OFF" ]; - })).override { waylandSupport = pkgs.stdenv.isLinux; }; + }); glew-static = pkgs.glew.overrideAttrs { pname = "glew-static"; @@ -40,20 +34,16 @@ }; }); - devShells = forAllSystems ({ system, pkgs }: + devShells = forAllSystems ({ system, pkgs }: let inherit (pkgs) lib stdenv; - - darwinFrameworks = pkgs.darwin.apple_sdk.frameworks; in - { + { default = pkgs.mkShell { buildInputs = (with pkgs; [ pkg-config ninja cmake meson lldb ]) ++ (with self.packages.${system}; [ glfw-static glew-static - ]) ++ lib.optionals stdenv.isDarwin (with darwinFrameworks; [ - Cocoa OpenGL ]) ++ lib.optionals stdenv.isLinux (with pkgs; [ wayland wayland-protocols libffi ]); diff --git a/src/GFX/Window.cpp b/src/GFX/Window.cpp index 5c391c8..75e7613 100644 --- a/src/GFX/Window.cpp +++ b/src/GFX/Window.cpp @@ -18,7 +18,10 @@ Window::Window(std::string const& title, U32 const width, U32 const height) { m_window = glfwCreateWindow(TO(I32, width), TO(I32, height), title.c_str(), nullptr, nullptr); if (m_window == nullptr) { - throw std::runtime_error("Failed to create window."); + Char const* error_description; + UInt error_code = glfwGetError(&error_description); + std::string error_string = "Failed to create window: " + std::string(error_description) + " (" + std::to_string(error_code) + ")"; + throw std::runtime_error(error_string); } glfwMakeContextCurrent(m_window); |
