build(nix): properly wrap development shell

Allows actually running the executables built in the development shell

Signed-off-by: Seth Flynn <getchoo@tuta.io>
(cherry picked from commit 2d4bc09cb9bec621997e00c23acac0b7cf3e99d7)
This commit is contained in:
Seth Flynn 2025-03-30 18:41:06 -04:00
parent 5c4bd3db52
commit 760fbdf54f
No known key found for this signature in database
GPG Key ID: D31BD0D494BBEE86

View File

@ -88,13 +88,35 @@
llvm = pkgs.llvmPackages_19; llvm = pkgs.llvmPackages_19;
packages' = self.packages.${system}; 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 in
{ {
default = pkgs.mkShell { default = pkgs.mkShell {
inputsFrom = [ packages'.prismlauncher-unwrapped ]; inputsFrom = [ packages'.prismlauncher-unwrapped ];
nativeBuildInputs = with pkgs; [ packages = with pkgs; [
ccache ccache
llvm.clang-tools llvm.clang-tools
]; ];
@ -105,6 +127,9 @@
]; ];
shellHook = '' shellHook = ''
echo "Sourcing ${qt-wrapper-env}"
source ${qt-wrapper-env}
if [ ! -f compile_commands.json ]; then if [ ! -f compile_commands.json ]; then
cmake $cmakeFlags -D CMAKE_BUILD_TYPE=Debug cmake $cmakeFlags -D CMAKE_BUILD_TYPE=Debug
ln -s {build/,}compile_commands.json ln -s {build/,}compile_commands.json