!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

687 Members
Rust155 Servers

Load older messages


SenderMessageTime
27 Apr 2025
@k900:0upti.meK900Post your shell.nix17:35:52
@k900:0upti.meK900Or whatever environment you're using17:36:07
@adam_neverwas:matrix.orgAdam Neverwas

{
description = "Rust development environment with latest Bevy";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};

    rustToolchain = pkgs.rust-bin.stable.latest.default.override {
      extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
      targets = [ "wasm32-unknown-unknown" ];
    };

    graphicsLibs = with pkgs; [
      vulkan-loader
      xorg.libX11
      xorg.libXcursor
      xorg.libXrandr
      xorg.libXi
      libxkbcommon
      wayland
      libGL
      libGLU
      xorg.libXext
    ];
    audioLibs = with pkgs; [
      alsa-lib
      libjack2
      libpulseaudio
    ];
    systemLibs = with pkgs; [
      udev
      systemd
      openssl
      pkg-config
    ];
    buildLibs = with pkgs; [
      cmake
      clang
      gcc
      binutils
      lld
    ];
    devTools = with pkgs; [
      rustToolchain
      rustup
      cargo-watch
      cargo-expand
      cargo-audit
      cargo-outdated
      cargo-geiger
      wasm-pack
    ];

    allLibs = graphicsLibs ++ audioLibs ++ systemLibs;

    wrapperScript = pkgs.writeScriptBin "create-wrappers" (builtins.readFile ./wrapper/generate_wrappers.sh);

    devEnv = pkgs.mkShell {
      buildInputs = devTools ++ buildLibs ++ allLibs ++ [ wrapperScript ];
      shellHook = ''
        echo "🦀 Rust + Bevy dev environment loading..."

         # Find libudev.pc file in the Nix store
          LIBUDEV_PC=$(find /nix/store -path "*/lib/pkgconfig/libudev.pc" | head -n 1)
          
          if [ ! -z "$LIBUDEV_PC" ]; then
            echo "✅ Found libudev.pc at: $LIBUDEV_PC"
            export PKG_CONFIG_PATH=$(dirname "$LIBUDEV_PC"):$PKG_CONFIG_PATH
          else
            echo "❌ Could not find libudev.pc in Nix store"
          fi

        export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath allLibs}:$LD_LIBRARY_PATH
        export PKG_CONFIG_PATH=$(IFS=:; echo ${pkgs.lib.concatStringsSep ":" (builtins.map (pkg: "${pkg}/lib/pkgconfig") allLibs)}):$PKG_CONFIG_PATH
        
        # Ensure Rust can find the standard library
        export RUST_SRC_PATH=${rustToolchain}/lib/rustlib/src/rust/library
        
        export RUSTFLAGS="-C link-arg=-fuse-ld=lld"
        export BEVY_ASSET_ROOT="$(pwd)/assets"
        export CC=gcc
        export CXX=g++
        create-wrappers

        PATH="$(echo "$PATH" | sed -e "s#:$HOME/.local/bin##g" -e "s#$HOME/.local/bin:##g" -e "s#$HOME/.local/bin##g")"

        # LAST ROW
        export PATH="$HOME/.local/bin:$PATH"
        
        echo "✅ Rust + Bevy development environment ready!"
      '';
    };
  in
  {
    devShells.default = devEnv;
  }
);

}

17:37:11
@k900:0upti.meK900What the fuck are you doing17:38:07
@k900:0upti.meK900Literally what is all of this17:38:15
@adam_neverwas:matrix.orgAdam Neverwas flayyk 17:38:16
@k900:0upti.meK900 Why are you setting PKG_CONFIG_PATH manually 17:38:27
@k900:0upti.meK900 Why are you setting LIBUDEV_PC at all 17:38:35
@curid:matrix.org@curid:matrix.orgchatgpt creation17:38:40
@k900:0upti.meK900 Why are you messing with CC or CXX 17:38:45
@adam_neverwas:matrix.orgAdam Neverwas IYeh 17:38:46
@adam_neverwas:matrix.orgAdam Neverwas I tried everything 17:38:54
@k900:0upti.meK900OK we're done then17:39:00
@k900:0upti.meK900You need to understand what you're doing17:39:07
@k900:0upti.meK900Not copy/paste the word vomit machine output17:39:12
@adam_neverwas:matrix.orgAdam Neverwas This is a several time modified version 17:39:45
@k900:0upti.meK900Do you understand every line of it?17:40:26
@k900:0upti.meK900(no, you don't)17:40:31
@adam_neverwas:matrix.orgAdam Neverwas not every 17:40:38
@k900:0upti.meK900Then start with something you actually understand17:40:56
@adam_neverwas:matrix.orgAdam Neverwas Okay, but an empty project with bevy 0.16 producing my problem, what without it doesnt happen 17:41:48
@k900:0upti.meK900The problem isn't bevy, it's your shell17:42:27
@k900:0upti.meK900And I am not wading through two screens of LLM gunk to figure out why17:42:39
@awwpotato:envs.net@awwpotato:envs.netalso bevy has an example shell.nix that you can use https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md#nix17:46:25
@adam_neverwas:matrix.orgAdam Neverwas thnak :V 17:53:45
@adam_neverwas:matrix.orgAdam Neverwas So the problem of the rust-analyzer running in vscodium solvable in flake? 18:08:30
@k900:0upti.meK900Yes18:08:43
@k900:0upti.meK900Please try it with the example bevy shell18:08:51
@k900:0upti.meK900And make sure you're running vscode from the shell18:08:57
@k900:0upti.meK900Or using the direnv/nix-shell plugins to load the environment into your vscode18:09:10

Show newer messages


Back to Room ListRoom Version: 6