This commit is contained in:
Mars 2024-10-08 23:56:24 -04:00
parent 7762cb4712
commit 9b93436efd
Signed by: pupbrained
GPG key ID: 874E22DF2F9DFCB5
2 changed files with 40 additions and 41 deletions

View file

@ -24,19 +24,14 @@
}; };
}; };
stdenv = stdenv = with pkgs;
if pkgs.hostPlatform.isLinux if hostPlatform.isLinux
then pkgs.stdenvAdapters.useMoldLinker pkgs.llvmPackages_18.libcxxStdenv then stdenvAdapters.useMoldLinker llvmPackages_18.libcxxStdenv
else pkgs.llvmPackages_18.libcxxStdenv; else llvmPackages_18.libcxxStdenv;
sources = import ./_sources/generated.nix { sources = import ./_sources/generated.nix {inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;};
inherit (pkgs) fetchFromGitHub fetchgit fetchurl dockerTools;
};
mkPkg = name: mkPkg = name: pkgs.${name}.overrideAttrs {inherit (sources.${name}) pname version src;};
pkgs.${name}.overrideAttrs {
inherit (sources.${name}) pname version src;
};
fmt = mkPkg "fmt"; fmt = mkPkg "fmt";
@ -51,15 +46,14 @@
vulkan-loader vulkan-loader
vulkan-tools vulkan-tools
]; ];
in in rec {
with pkgs; rec {
packages = rec { packages = rec {
graphics-test = stdenv.mkDerivation { graphics-test = stdenv.mkDerivation {
name = "graphics-test"; name = "graphics-test";
version = "0.1.0"; version = "0.1.0";
src = self; src = self;
nativeBuildInputs = [ nativeBuildInputs = with pkgs; [
meson meson
ninja ninja
pkg-config pkg-config
@ -84,19 +78,21 @@
default = graphics-test; default = graphics-test;
}; };
formatter = treefmt-nix.lib.mkWrapper pkgs { formatter = with pkgs;
treefmt-nix.lib.mkWrapper pkgs {
projectRootFile = "flake.nix"; projectRootFile = "flake.nix";
programs = { programs = {
alejandra.enable = true; alejandra.enable = true;
clang-format = { clang-format = {
enable = true; enable = true;
package = pkgs.llvmPackages_18.clang-tools; package = llvmPackages_18.clang-tools;
}; };
}; };
}; };
devShell = mkShell.override {inherit stdenv;} { devShell = with pkgs;
mkShell.override {inherit stdenv;} {
packages = packages =
[ [
alejandra alejandra

View file

@ -38,6 +38,7 @@ constexpr bool enableValidationLayers = true;
class VulkanApp { class VulkanApp {
public: public:
fn run() -> void { fn run() -> void {
// Create a window
initWindow(); initWindow();
initVulkan(); initVulkan();
mainLoop(); mainLoop();
@ -854,11 +855,13 @@ class VulkanApp {
}; };
fn main() -> i32 { fn main() -> i32 {
// Allows for loading functions dynamically at runtime
vk::DynamicLoader dynamicLoader; vk::DynamicLoader dynamicLoader;
auto vkGetInstanceProcAddr = auto vkGetInstanceProcAddr =
dynamicLoader.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr"); dynamicLoader.getProcAddress<PFN_vkGetInstanceProcAddr>("vkGetInstanceProcAddr");
VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr); VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
// Create app object
VulkanApp app; VulkanApp app;
try { try {