From db3f7ae7f7f3919415f38e253acc3c9e8b684c86 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sun, 8 Sep 2024 12:13:44 +0200 Subject: [PATCH] flakes/wayland stuff --- .envrc | 1 + .gitignore | 1 + flake.lock | 100 ++++++++++++++++++++++++++++++++++++ flake.nix | 51 ++++++++++++++++++ hui-examples/Cargo.toml | 2 +- hui-examples/boilerplate.rs | 3 ++ 6 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 .envrc create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..a5dbbcb --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake . diff --git a/.gitignore b/.gitignore index 3762245..6ecd142 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ Cargo.lock **/*.rs.bk *.pdb rustc-ice-*.txt +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a16a835 --- /dev/null +++ b/flake.lock @@ -0,0 +1,100 @@ +{ + "nodes": { + "fenix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "rust-analyzer-src": "rust-analyzer-src" + }, + "locked": { + "lastModified": 1725777030, + "narHash": "sha256-mieHgCmdbr/Tok3djbEVnNyLtnxEv5PHngN8wBu+RJA=", + "owner": "nix-community", + "repo": "fenix", + "rev": "7c59cc75e7d2328753b00766ab0a78a075609b25", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "fenix", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1725534445, + "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9bb1e7571aadf31ddb4af77fc64b2d59580f9a39", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "fenix": "fenix", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "rust-analyzer-src": { + "flake": false, + "locked": { + "lastModified": 1725630423, + "narHash": "sha256-gNCLk3Zg7JlAwmWbVHTH6f3+iqdeQ4fheOotCZy8x5M=", + "owner": "rust-lang", + "repo": "rust-analyzer", + "rev": "08c7bbc2dbe4dcc8968484f1a0e1e6fe7a1d4f6d", + "type": "github" + }, + "original": { + "owner": "rust-lang", + "ref": "nightly", + "repo": "rust-analyzer", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..973c1ae --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = { self, nixpkgs, flake-utils, fenix }: + flake-utils.lib.eachDefaultSystem (system: let + pkgs = nixpkgs.legacyPackages.${system}; + in { + devShell = pkgs.mkShell.override { + stdenv = if pkgs.stdenv.isLinux then + pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv + else + pkgs.clangStdenv; + } rec { + packages = with pkgs; [ + (fenix.packages.${system}.complete.withComponents [ + "cargo" + "rustc" + "rust-src" + "rustfmt" + "rust-analyzer" + "clippy" + ]) + pkg-config + cmake + ]; + buildInputs = with pkgs; [ + wayland + xorg.libxcb + libxkbcommon + vulkan-tools + vulkan-headers + vulkan-loader + libGL + xorg.libX11 + xorg.libXcursor + xorg.libXi + xorg.libXrandr + glslang + ]; + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; + # RUSTFLAGS = "-Zthreads=8"; (causes rustc to ICE) + MANGOHUD_DLSYM = "1"; # mangohud glium fix + }; + }); +} diff --git a/hui-examples/Cargo.toml b/hui-examples/Cargo.toml index 9a30f18..c6dfadf 100644 --- a/hui-examples/Cargo.toml +++ b/hui-examples/Cargo.toml @@ -9,7 +9,7 @@ publish = false hui = { path = "../hui" } hui-glium = { path = "../hui-glium" } hui-winit = { path = "../hui-winit" } -kubi-logging = { git = "https://github.com/griffi-gh/kubi", rev = "c162893fd" } +kubi-logging = { git = "https://github.com/griffi-gh/kubi", rev = "be1e24ba0c9e6d24128e7d0e74bebd8b90c23be7" } glium = "0.35" winit = "0.30" glam = "0.28" diff --git a/hui-examples/boilerplate.rs b/hui-examples/boilerplate.rs index 86eec94..9c0d1ab 100644 --- a/hui-examples/boilerplate.rs +++ b/hui-examples/boilerplate.rs @@ -53,6 +53,9 @@ pub fn ui( WindowEvent::CloseRequested => { window_target.exit(); }, + WindowEvent::Resized(size) => { + display.resize((size.width, size.height)); + }, WindowEvent::RedrawRequested => { let mut frame = display.draw(); frame.clear_color_srgb(0.5, 0.5, 0.5, 1.);