get it building again & set up nixos vscode environment

This commit is contained in:
vivlim 2022-12-21 02:16:44 -08:00
parent ebec2b8711
commit 0c2f912793
6 changed files with 275 additions and 980 deletions

10
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
/*"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix", /* using flake directly segfaults on nixos with vscode-fsh ... */
/*"terminal.integrated.env.linux": {
"LD_LIBRARY_PATH": ""
},
"rust-analyzer.cargo.extraEnv": {
"LD_LIBRARY_PATH": ""
},*/
}

1131
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ block-mesh = "0.2.0"
bevy_egui = "0.15.1"
egui = "0.18"
egui_extras = "0.18"
smooth-bevy-cameras = "0.6.0"
smooth-bevy-cameras = "0.5.0"
itertools = "0.10"
rfd = "0.8"
async-channel = "1.6.1"

View File

@ -1,9 +1,6 @@
use std::collections::VecDeque;
use bevy::prelude::Resource;
/// Command queue which allows both synchronous and asynchronous queuing.
#[derive(Resource)]
pub struct CommandQueue<T> {
sync_commands: VecDeque<T>,
async_sender: async_channel::Sender<T>,

View File

@ -1,4 +1,4 @@
use bevy::prelude::{Commands, Component, Entity, Mesh, Query, ResMut};
use bevy::prelude::{Commands, Component, Entity, Mesh, Query, ResMut, Handle, Assets};
use block_mesh::Voxel;
use common::space::three_dimensional::traits::DefaultVoxel;

107
flake.nix
View File

@ -14,13 +14,12 @@
inherit system;
overlays = [ (import nixpkgs-mozilla) nixGL.overlay ];
config.allowUnfree = true;
};
toolchain = (pkgs.rustChannelOf {
# sadly, https://github.com/mozilla/nixpkgs-mozilla/issues/287
date = "2022-08-07";
channel = "nightly";
sha256 = "sha256-cXABXvQuh4dXNLtFMvRuB7YBi9LXRerA0u/u/TUm4rQ=";
toolchain = [((pkgs.rustChannelOf {
rustToolchain = ./rust-toolchain.toml;
sha256 = "sha256-S7epLlflwt0d1GZP44u5Xosgf6dRrmr8xxC+Ml2Pq7c=";
}).rust.override {
extensions = [
"rust-src"
@ -29,71 +28,47 @@
"rustfmt-preview"
];
targets = [ "x86_64-unknown-linux-gnu" "wasm32-unknown-unknown" ];
};
})];
nixGlWrappedMgbaQt = pkgs.writeShellScriptBin "mgba-qt" ''
# call mgba-qt with nixGL
exec ${pkgs.nixgl.nixGLIntel}/bin/nixGLIntel ${pkgs.mgba}/bin/mgba-qt $@
'';
# this doesn't seem to work
softwareVulkan = pkgs.writeShellScriptBin "hell" ''
export LIBGL_ALWAYS_SOFTWARE=1
export __GLX_VENDOR_LIBRARY_NAME=mesa
export VK_ICD_FILENAMES=${pkgs.mesa.drivers}/share/vulkan/icd.d/lvp_icd.x86_64.json
exec ${pkgs.nixgl.nixVulkanIntel}/bin/nixVulkanIntel $@
'';
baseBuildInputs = [ toolchain pkgs.gcc-arm-embedded ];
levelEditorDeps = with pkgs; {
# thanks, https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#nixos !
nativeBuildInputs = [ pkgconfig llvmPackages.bintools vulkan-loader nixgl.nixVulkanIntel vulkan-tools
openssl # deps for building wasm. we have to cargo install -f wasm-bindgen-cli, the nixpkg is out of sync
];
buildInputs = [ # wip and not minimal. was trying to get stuff working on my desktop and didn't finish
udev alsaLib
xlibsWrapper xorg.libXcursor xorg.libXrandr xorg.libXi # To use x11 feature
libxkbcommon wayland # To use wayland feature
gdk-pixbuf atk pango cairo gtk3-x11 # additional dependencies for voxel-level-editor
];
hook = ''
export PATH=$PATH:$HOME/.cargo/bin
'';
};
ensureSubmodules = ''
# quick check of whether submodules are initialized, if the working directory is the root of the repo
if [[ -f "flake.nix" && -f "Cargo.toml" && ! -f "external/agb/README.md" ]]; then
echo "fetching submodules"
git submodule init
git submodule update
fi
'';
# thanks, https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#nixos !
nativeBuildInputs = ps: with ps; [ pkgconfig llvmPackages.bintools
openssl # deps for building wasm. we have to cargo install -f wasm-bindgen-cli, the nixpkg is out of sync
];
buildInputs = ps: with ps; [ # wip and not minimal. was trying to get stuff working on my desktop and didn't finish
udev alsaLib vulkan-loader
xlibsWrapper xorg.libXcursor xorg.libXrandr xorg.libXi # To use x11 feature
libxkbcommon wayland # To use wayland feature
gdk-pixbuf atk pango cairo gtk3-x11 # additional dependencies for voxel-level-editor
];
in {
devShell = with pkgs;
mkShell {
nativeBuildInputs = baseBuildInputs ++ [ nixGlWrappedMgbaQt ];
shellHook = ''
'' + ensureSubmodules;
devShell =
pkgs.mkShell {
nativeBuildInputs = toolchain ++ (nativeBuildInputs pkgs);
buildInputs = (buildInputs pkgs);
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (buildInputs pkgs);
};
devShells.level-editor = with pkgs; # wip use at your own peril
mkShell rec {
nativeBuildInputs = baseBuildInputs ++ levelEditorDeps.nativeBuildInputs ++ [ nixGlWrappedMgbaQt softwareVulkan ];
buildInputs = levelEditorDeps.buildInputs;
shellHook = ''
'' + ensureSubmodules;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
};
devShells.wsl-vcxsrv = with pkgs;
mkShell {
nativeBuildInputs = baseBuildInputs ++ [ nixGlWrappedMgbaQt ];
shellHook = ''
export HOST_IP="$(ip route |awk '/^default/{print $3}')"
export DISPLAY=$HOST_IP:0 # use vcxsrv
export PULSE_SERVER="tcp:$HOST_IP"
'' + ensureSubmodules;
devShells.vscode =
pkgs.mkShell {
nativeBuildInputs = toolchain ++ (nativeBuildInputs pkgs);
buildInputs = (buildInputs pkgs) ++ #[ (pkgs.vscode.fhsWithPackages (ps: (buildInputs ps) ++ (nativeBuildInputs ps))) ];
[ (pkgs.vscode-with-extensions.override {
vscodeExtensions = with pkgs.vscode-extensions; [
matklad.rust-analyzer
vscodevim.vim
eamodio.gitlens
mhutchie.git-graph
bungcip.better-toml
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "witch-hazel";
publisher = "TheaFlowers";
version = "2021.10.16";
sha256 = "sha256-SMHLg2h51aRvOyqLd4JILYzsBY5HkMXm28iVSTdX43U=";
}
];
})];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (buildInputs pkgs);
};
});
}