From 760fbdf54fd561dee40a3b378f0b7ab7cc9e2270 Mon Sep 17 00:00:00 2001 From: Seth Flynn Date: Sun, 30 Mar 2025 18:41:06 -0400 Subject: [PATCH] build(nix): properly wrap development shell Allows actually running the executables built in the development shell Signed-off-by: Seth Flynn (cherry picked from commit 2d4bc09cb9bec621997e00c23acac0b7cf3e99d7) --- flake.nix | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index ceb4bad4b..55d8b0464 100644 --- a/flake.nix +++ b/flake.nix @@ -88,13 +88,35 @@ llvm = pkgs.llvmPackages_19; packages' = self.packages.${system}; + + # Re-use our package wrapper to wrap our development environment + qt-wrapper-env = packages'.prismlauncher.overrideAttrs (old: { + name = "qt-wrapper-env"; + + # Required to use script-based makeWrapper below + strictDeps = true; + + # We don't need/want the unwrapped Prism package + paths = [ ]; + + nativeBuildInputs = old.nativeBuildInputs or [ ] ++ [ + # Ensure the wrapper is script based so it can be sourced + pkgs.makeWrapper + ]; + + # Inspired by https://discourse.nixos.org/t/python-qt-woes/11808/10 + buildCommand = '' + makeQtWrapper ${lib.getExe pkgs.runtimeShellPackage} "$out" + sed -i '/^exec/d' "$out" + ''; + }); in { default = pkgs.mkShell { inputsFrom = [ packages'.prismlauncher-unwrapped ]; - nativeBuildInputs = with pkgs; [ + packages = with pkgs; [ ccache llvm.clang-tools ]; @@ -105,6 +127,9 @@ ]; shellHook = '' + echo "Sourcing ${qt-wrapper-env}" + source ${qt-wrapper-env} + if [ ! -f compile_commands.json ]; then cmake $cmakeFlags -D CMAKE_BUILD_TYPE=Debug ln -s {build/,}compile_commands.json