!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

687 Members
Rust156 Servers

Load older messages


SenderMessageTime
25 Mar 2025
@damccull:matrix.orgdamccull

Hello. Trying to set up a new bevy project in a flake. Getting this error:

target/debug/bevy-tut: error while loading shared libraries: libudev.so.1: cannot open shared object file: No such file or directory

With this flake:

{
  inputs = {
    nixpkgs = {
      url = "github:nixos/nixpkgs/nixos-unstable";
    };
    flake-parts.url = "github:hercules-ci/flake-parts";
    rust-overlay.url = "github:oxalica/rust-overlay";
    surrealdb-gh.url = "github:surrealdb/surrealdb/v2.1.4";
  };
  outputs =
    inputs:
    inputs.flake-parts.lib.mkFlake { inherit inputs; } {
      systems = [ "x86_64-linux" ];
      perSystem =
        {
          config,
          self',
          pkgs,
          lib,
          system,
          ...
        }:
        let
          runtimeDeps = with pkgs; [
            alsa-lib
            libxkbcommon
            udev
            vulkan-loader
            wayland
            xorg.libX11
            xorg.libXcursor
            xorg.libXi
            xorg.libXrandr
          ];

          buildDeps = with pkgs; [
            clang
            lld
            lldb
            pkg-config
            rustPlatform.bindgenHook
            stdenv.cc.cc.lib
            # (wasm-bindgen-cli.overrideAttrs (oldAttrs: rec {
            #   version = "0.2.100";
            #   src = fetchCrate {
            #     pname = "wasm-bindgen-cli";
            #     version = version;
            #     hash = "sha256-3RJzK7mkYFrs7C/WkhW9Rr4LdP5ofb2FdYGz1P7Uxog=";
            #   };
            #
            #   cargoDeps = rustPlatform.fetchCargoVendor {
            #     inherit src;
            #     inherit (src) pname version;
            #     hash = "sha256-qsO12332HSjWCVKtf1cUePWWb9IdYUmT+8OPj/XP2WE=";
            #   };
            # }))
          ];

          devDeps =
            with pkgs;
            [
              # Libraries and programs needed for dev work; included in dev shell
              # NOT included in the nix build operation
              bacon
              bashInteractive
              bunyan-rs
              cargo-deny
              cargo-edit
              cargo-expand
              cargo-msrv
              cargo-nextest
              (cargo-whatfeatures.overrideAttrs (oldAttrs: rec {
                version = "0.9.13";
                src = fetchCrate {
                  pname = "cargo-whatfeatures";
                  version = "${version}";
                  hash = "sha256-Nbyr7u47c6nImzYJvPVLfbqgDvzyXqR1C1tOLximuHU=";
                };

                cargoDeps = rustPlatform.fetchCargoVendor {
                  inherit src;
                  inherit (src) pname version;
                  hash = "sha256-p95aYXsZM9xwP/OHEFwq4vRiXoO1n1M0X3TNbleH+Zw=";
                };
              }))
              gdb
              just
              nushell
              panamax
              zellij
            ]
            ++ [
              inputs.surrealdb-gh.packages.${system}.default
            ];

          cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
          msrv = cargoToml.package.rust-version;

          rustPackage =
            features:
            (pkgs.makeRustPlatform {
              cargo = pkgs.rust-bin.stable.latest.minimal;
              rustc = pkgs.rust-bin.stable.latest.minimal;
            }).buildRustPackage
              {
                inherit (cargoToml.package) name version;
                src = ./.;
                cargoLock.lockFile = ./Cargo.lock;
                buildFeatures = features;
                buildInputs = runtimeDeps;
                nativeBuildInputs = buildDeps;
                # Uncomment if your cargo tests require networking or otherwise
                # don't play nicely with the nix build sandbox:
                # doCheck = false;
              };

          ldpath = with pkgs; [
            stdenv.cc.cc.lib
          ];

          mkDevShell =
            rustc:
            pkgs.mkShell {
              shellHook = ''
                # TODO: figure out if it's possible to remove this or allow a user's preferred shell
                exec env SHELL=${pkgs.bashInteractive}/bin/bash zellij --layout ./zellij_layout.kdl
              '';
              LD_LIBRARY_PATH = lib.makeLibraryPath ldpath;

              GIO_MODULE_DIR = "${pkgs.glib-networking}/lib/gio/modules/";

              RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
              buildInputs = runtimeDeps;
              nativeBuildInputs = buildDeps ++ devDeps ++ [ rustc ];
            };

          rustTargets = [
            "x86_64-unknown-linux-gnu"
            "x86_64-linux-android"
            "aarch64-linux-android"
            "wasm32-unknown-unknown"
          ];

          rustExtensions = [
            "rust-analyzer"
            "rust-src"
          ];
        in
        {

          _module.args.pkgs = import inputs.nixpkgs {
            inherit system;
            overlays = [ (import inputs.rust-overlay) ];
            config = {
              allowUnfreePredicate =
                pkg:
                builtins.elem (lib.getName pkg) ([
                  "surrealdb"
                ]);
              android_sdk.accept_license = true;
            };
          };

          packages.default = self'.packages.base;
          devShells.default = self'.devShells.stable;

          packages.base = (rustPackage "");
          packages.bunyan = (rustPackage "bunyan");
          packages.tokio-console = (rustPackage "tokio-console");

          devShells.nightly = (
            mkDevShell (
              pkgs.rust-bin.selectLatestNightlyWith (
                toolchain:
                toolchain.default.override {
                  extensions = rustExtensions;
                  targets = rustTargets;
                }
              )
            )
          );
          devShells.stable = (
            mkDevShell (
              pkgs.rust-bin.stable.latest.default.override {
                extensions = rustExtensions;
                targets = rustTargets;
              }
            )
          );
          devShells.msrv = (
            mkDevShell (
              pkgs.rust-bin.stable.${msrv}.default.override {
                extensions = rustExtensions;
                targets = rustTargets;
              }
            )
          );
        };
    };
}

Really not sure why since I have udev in the place it's supposed to be according to bevy docs, and I've tried it in all the places I can think of anyways. Suggestions?

00:49:39
@damccull:matrix.orgdamccullAh, nevermind. It was an LD_PATH issue.01:23:03
@damccull:matrix.orgdamccull* Ah, nevermind. It was an LD_LIBRARY_PATH issue.01:23:16
@ralith:ralith.comRalithsounds like they're using dlopen when they should be linking02:45:09
@tomasajt:matrix.orgTomaThere are a few packages (around 3) still using the first cargo lockfile format in-tree, so I made this https://github.com/NixOS/nixpkgs/pull/39301612:41:11
@k900:0upti.meK900Can we just delete them instead lol 12:42:00
@emilazy:matrix.orgemilywe already removed tons of packages for that12:43:10
@emilazy:matrix.orgemilyare the remaining ones that important?12:43:20
@emilazy:matrix.orgemilykubernix looks like something that probably won't even work any more and that is likely using ancient/insecure versions if it does12:44:25
@tomasajt:matrix.orgTomaokay, I don't really care if it doesn't get merged, the main thing is that the PR exists so in case someone really wants it they can take the changes12:46:13
@k900:0upti.meK900What's the packages?12:46:44
@k900:0upti.meK900Do we have a list?12:46:52
@tomasajt:matrix.orgTomasee the linked issue12:46:51
@k900:0upti.meK900https://github.com/yxdunc/lipl has a v3 lockfile in master and hasn't been touched in 3 years otherwise12:47:56
@k900:0upti.meK900kubernix author is also its maintainer in nixpkgs12:48:40
@k900:0upti.meK900We can probably ask for a tag?12:48:43
@k900:0upti.meK900system-syzygy has a 1.0.2 tag with a v3 lockfile12:49:29
@k900:0upti.meK900I feel like we can just bump the two and ask the author about the third one 12:50:53
@k900:0upti.meK900And never have this problem again 12:51:01
@tomasajt:matrix.orgToma I guess
also, since importCargoLock supports v1 anyways, weird old software can fall back to that
12:51:50
@k900:0upti.meK900Oh let's rip that out too lol12:52:12
@tomasajt:matrix.orgTomaI don't really agree: it's very simple to support because importCargoLock is written in nix and can use laziness12:54:33
@k900:0upti.meK900I'm not thinking about it in terms of difficulty to support tbh 12:55:04
@k900:0upti.meK900I'm thinking about it in terms of policy 12:55:11
@k900:0upti.meK900Any software that still has a pre-v3 lockfile hasn't been touched since what, 2020?12:55:33
@k900:0upti.meK900We probably don't want to be shipping that12:55:44
@k900:0upti.meK900 Even if we technically can + 12:55:51
@k900:0upti.meK900* Even if we technically can12:56:01
@emilazy:matrix.orgemilyAlyssa removed like 50 packages for having old lock file versions13:16:42
@emilazy:matrix.orgemilyso it seems a bit late to start caring about :P13:16:47

Show newer messages


Back to Room ListRoom Version: 6