From 8f1172e8880ba0697fe68af52f45f453f6ebd754 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Tue, 19 Nov 2024 17:42:35 +0100 Subject: [PATCH] Add possibility to run program from nix shell --- .envrc | 2 +- flake.lock | 24 ++++++++++++++++++++++++ flake.nix | 16 ++++++++++++---- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.envrc b/.envrc index 3550a30..2f8e1d3 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake +use flake --impure diff --git a/flake.lock b/flake.lock index bc5b28e..9ff2d00 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,29 @@ "type": "github" } }, + "nixgl": { + "inputs": { + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713543440, + "narHash": "sha256-lnzZQYG0+EXl/6NkGpyIz+FEOc/DSEG57AP1VsdeNrM=", + "owner": "nix-community", + "repo": "nixGL", + "rev": "310f8e49a149e4c9ea52f1adf70cdc768ec53f8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixGL", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1730831018, @@ -37,6 +60,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "nixgl": "nixgl", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay" } diff --git a/flake.nix b/flake.nix index e8506cf..4fbbfca 100644 --- a/flake.nix +++ b/flake.nix @@ -8,14 +8,20 @@ url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixgl = { + url = "github:nix-community/nixGL"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + }; }; - outputs = { self, nixpkgs, flake-utils, rust-overlay }: + outputs = { self, nixpkgs, flake-utils, rust-overlay, nixgl }: flake-utils.lib.eachSystem flake-utils.lib.allSystems (system: let - overlays = [ (import rust-overlay) ]; + overlays = [ (import rust-overlay) nixgl.overlay ]; pkgs = import nixpkgs { inherit system overlays; + config.allowUnfree = true; }; rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; @@ -24,7 +30,7 @@ cargo = rust; }); - libs = with pkgs; [ vulkan-headers vulkan-loader ] + libs = with pkgs; [ vulkan-headers vulkan-loader vulkan-validation-layers ] ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux (with pkgs; [ libxkbcommon wayland libGL ]) ++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin (with pkgs; [ darwin.apple_sdk.frameworks.SystemConfiguration ]); in @@ -36,7 +42,9 @@ pkg-config ]; - buildInputs = libs; + buildInputs = libs ++ [ + pkgs.nixgl.auto.nixVulkanNvidia pkgs.nixgl.nixVulkanIntel + ]; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ libxkbcommon wayland libGL ]); };