!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

695 Members
Rust155 Servers

Load older messages


SenderMessageTime
7 Jan 2026
@accelbread:matrix.orgaccelbread yeah, those are binary builds though. And I don't want another flake dependency.
I built it with nix rustc with RUSTC_BOOTSTRAP=1, to enable unstable features
22:09:12
8 Jan 2026
@epiceric:nixos.devEpic EricDoes anybody by some chance have a dev environment for working with godot-rust?00:23:31
@epiceric:nixos.devEpic Eric

Far from the best but at least I managed to do what I wanted to do with this dirty shell

let
  sources = import ./npins;
  pkgs = import sources.nixpkgs {
    overlays = [ (import sources.rust-overlay) ];
  };

  pkgs-cross-mingw = import pkgs.path {
    crossSystem = {
      config = "x86_64-w64-mingw32";
    };
  };

  mingw_w64_cc = pkgs-cross-mingw.stdenv.cc;
  mingw_w64 = pkgs-cross-mingw.windows.mingw_w64;
  mingw_w64_pthreads_w_static = pkgs-cross-mingw.windows.pthreads.overrideAttrs (oldAttrs: {
    configureFlags = (oldAttrs.configureFlags or [ ]) ++ [
      "--enable-static"
    ];
  });
in
pkgs.mkShell {
  packages = [
    pkgs.bacon
    pkgs.godot_4_5
    pkgs.godot_4_5-export-templates-bin
    mingw_w64_cc
    (pkgs.rust-bin.stable.latest.default.override {
      targets = [ "x86_64-pc-windows-gnu" ];
    })
    pkgs.wineWowPackages.stable
  ];

  WINDOWS_RUSTFLAGS = (
    map (a: ''-L ${a}/lib'') [
      mingw_w64
      mingw_w64_pthreads_w_static
    ]
  );
}
02:00:01
@yawd:matrix.orgDiego Reis joined the room.02:58:44
@epiceric:nixos.devEpic Eric

For the record, this is my (somewhat) cleaner build derivation (still need to add Linux building and separate the build phase into two)

let
  sources = import ./npins;
  pkgs = import sources.nixpkgs {
    overlays = [ (import sources.rust-overlay) ];
  };

  inherit (pkgs) lib stdenv;

  pkgs-cross-mingw = import pkgs.path {
    crossSystem = {
      config = "x86_64-w64-mingw32";
    };
  };

  mingw_w64_cc = pkgs-cross-mingw.stdenv.cc;
  mingw_w64 = pkgs-cross-mingw.windows.mingw_w64;
  mingw_w64_pthreads_w_static = pkgs-cross-mingw.windows.pthreads.overrideAttrs (oldAttrs: {
    configureFlags = (oldAttrs.configureFlags or [ ]) ++ [
      "--enable-static"
    ];
  });

  rust = pkgs.rust-bin.stable.latest.default;

  rustCc = pkgs.rust-bin.stable.latest.default.override {
    targets = [ "x86_64-pc-windows-gnu" ];
  };

  src = lib.fileset.toSource {
    root = ./.;
    fileset = lib.fileset.unions [
      ./godot
      ./rust
    ];
  };

  commonArgs = {
    version = "0";
    inherit src;
    cargoDeps = pkgs.rustPlatform.fetchCargoVendor {
      inherit src;
      sourceRoot = "${src.name}/rust";
      hash = "sha256-kRZdndknulrZFeb7EDwNrpctjaT/UreFwZREOxv7e08=";
    };
    cargoRoot = "rust";
    postPatch = ''
      export HOME=$(mktemp -d)
      mkdir -p ~/.local/share/godot
      ln -s ${pkgs.godot_4_5-export-templates-bin}/share/godot/export_templates ~/.local/share/godot/export_templates
    '';
  };

  commonArgsWin = commonArgs // {
    RUSTFLAGS = (
      map (a: ''-L ${a}/lib'') [
        mingw_w64
        mingw_w64_pthreads_w_static
      ]
    );
    buildInputs = [
      pkgs.rustPlatform.cargoSetupHook
      mingw_w64_cc
      rustCc
    ];
  };
in
{
  windows-release = stdenv.mkDerivation (
    commonArgsWin
    // {
      pname = "crane-game-windows-release";
      buildPhase = ''
        ${rustCc}/bin/cargo build --target x86_64-pc-windows-gnu --release --manifest-path ./rust/Cargo.toml
        mkdir ./export_windows
        ${pkgs.godot_4_5}/bin/godot --headless --path ./godot --export-release "Windows Desktop" ../export_windows/CraneGame_win.exe
      '';

      installPhase = ''
        mkdir $out
        cp ./export_windows/* $out
      '';
    }
  );
}
12:43:23
@drupol:matrix.orgPolI always forgot about the Nix Rust room! 13:08:59
@drupol:matrix.orgPolI posted this (https://gist.github.com/drupol/41bef4037d1d4c116f5ffa6df6493e28) in the main Nix room, but I guess I should have posted it here.13:09:20
@drupol:matrix.orgPol I'm trying to understand why overriding oldAttr.cargoDeps does not work. Can you help ? 13:09:45
@wilhelmines:matrix.orgwilhelmines joined the room.16:55:35
@pltrz_:matrix.orgpltrz set a profile picture.23:50:14
9 Jan 2026
@pltrz_:matrix.orgpltrz changed their profile picture.00:00:45
@theo-paris:matrix.orgTheo ParisI am trying to test the compilation of the Redox OS libc package (https://gist.github.com/theoparis/bbee869f1647e5c14a614d73ba9e6fd0) and I ran into an infinite recursion error that seems to be coming from inside of buildRustPackage. I guess no one has tried packaging a libc with it before... Is this something that I'm doing wrong or would it need to be fixed inside of the nixpkgs rust handling code?07:07:48
@theo-paris:matrix.orgTheo Paris* I am trying to test the cross compilation of the Redox OS libc package (https://gist.github.com/theoparis/bbee869f1647e5c14a614d73ba9e6fd0) and I ran into an infinite recursion error that seems to be coming from inside of buildRustPackage. I guess no one has tried packaging a libc with it before... Is this something that I'm doing wrong or would it need to be fixed inside of the nixpkgs rust handling code?07:07:56
@theo-paris:matrix.orgTheo Paris* I am trying to test the cross compilation of the Redox OS libc package (https://gist.github.com/theoparis/bbee869f1647e5c14a614d73ba9e6fd0) and I ran into an infinite recursion error that seems to be coming from inside of buildRustPackage. I guess no one has tried packaging a libc with it before... Is this something that I'm doing wrong or would it need to be fixed inside of the nixpkgs rust handling code somehow?07:08:21
@eveeifyeve:matrix.orgeveeifyeve joined the room.08:16:38
@magnetophon:matrix.orgmagnetophon

I'm trying to package https://github.com/zbanks/radiance

{
  lib,
  rustPlatform,
  fetchFromGitHub,
  pkg-config,
  # autoPatchelfHook,
  libxkbcommon,
  mpv-unwrapped,
  vulkan-loader,
  stdenv,
  darwin,
  alsa-lib,
  wayland,
  xorg,
  yt-dlp,
}:

rustPlatform.buildRustPackage rec {
  pname = "radiance";
  version = "0.7.0";

  src = fetchFromGitHub {
    owner = "zbanks";
    repo = "radiance";
    rev = version;
    hash = "sha256-itBBUKwJAWfLPXZaJ65UbabDoZUUZtZm8bGAU0joVsQ=";
  };

  cargoLock.lockFile = ./Cargo.lock;

  postPatch = ''
    ln -s ${./Cargo.lock} Cargo.lock
  '';

  nativeBuildInputs = [
    pkg-config
    # autoPatchelfHook
  ];

  buildInputs =
    [
      mpv-unwrapped
      vulkan-loader
      libxkbcommon
    ]
    ++ lib.optionals stdenv.isLinux [
      alsa-lib
      wayland

      # X11 / XCB stack (required by winit + xkbcommon-dl)
      xorg.libX11
      xorg.libXcursor
      xorg.libXi
      xorg.libXrandr
      xorg.libXinerama
      xorg.libXpresent
      xorg.libXfixes
      xorg.libXext
      # xorg.libXss
      xorg.libxcb
      # xorg.libX11-xcb
    ]
    ++ lib.optionals stdenv.isDarwin [
      darwin.apple_sdk.frameworks.AppKit
      darwin.apple_sdk.frameworks.CoreGraphics
      darwin.apple_sdk.frameworks.CoreServices
      darwin.apple_sdk.frameworks.Foundation
      darwin.apple_sdk.frameworks.Metal
      darwin.apple_sdk.frameworks.QuartzCore
    ];

  propagatedUserEnvPkgs = [
    yt-dlp
  ];

  # Floating-point exact-equality bugs upstream
  doCheck = false;

  meta = {
    description = "Video art software for VJs";
    homepage = "https://github.com/zbanks/radiance";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ magnetophon ];
    mainProgram = "radiance";
  };
}

When I run it, I get:

❯ radiance

thread 'main' (1930947) panicked at /build/cargo-vendor-dir/xkbcommon-dl-0.4.2/src/x11.rs:59:28:
Library libxkbcommon-x11.so could not be loaded.
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: xkbcommon_dl::x11::xkbcommon_x11_handle
   4: std::sync::poison::once::Once::call_once_force::{{closure}}
   5: std::sys::sync::once::futex::Once::call
   6: std::sync::once_lock::OnceLock<T>::initialize
   7: winit::platform_impl::linux::common::xkb::Context::from_x11_xkb
   8: winit::platform_impl::linux::EventLoop<T>::new
   9: radiance::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Any ideas on how to fix that?

15:36:38
@epiceric:nixos.devEpic EricI think you need to put libxkbcommon as a nativeBuildInput so it's available as a runtime dep15:38:49
@k900:0upti.meK900That's not what nativeBuildInputs do15:39:14
@k900:0upti.meK900And you probably need to add it to rpath15:39:18
@epiceric:nixos.devEpic EricOops15:39:22
@magnetophon:matrix.orgmagnetophon

Thanks.
Like this?

  preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
    patchelf \
      --set-rpath "${lib.makeLibraryPath buildInputs}:$out/lib" \
      $out/bin/radiance
  '';

15:43:40
@k900:0upti.meK900 buildInputs is suboptimal 15:44:01
@k900:0upti.meK900You probably want only the things it dlopens15:44:08
@magnetophon:matrix.orgmagnetophonok, thanks. I'll see if it runs with this (already building), and then minimize it.15:44:54
@magnetophon:matrix.orgmagnetophon

I still get:

❯ radiance

thread 'main' (2015441) panicked at /build/cargo-vendor-dir/xkbcommon-dl-0.4.2/src/x11.rs:59:28:
Library libxkbcommon-x11.so could not be loaded.
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::option::expect_failed
   3: xkbcommon_dl::x11::xkbcommon_x11_handle
   4: std::sync::poison::once::Once::call_once_force::{{closure}}
   5: std::sys::sync::once::futex::Once::call
   6: std::sync::once_lock::OnceLock<T>::initialize
   7: winit::platform_impl::linux::common::xkb::Context::from_x11_xkb
   8: winit::platform_impl::linux::EventLoop<T>::new
   9: radiance::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Any ideas?

15:49:40
@k900:0upti.meK900 And libxkbcommon is in your buildInputs? 15:50:24
@magnetophon:matrix.orgmagnetophonThis is with this snippet, so AFAIK all my buildInputs are in the rpath now.15:52:16
@k900:0upti.meK900 But what is in your buildInputs? 15:53:02
@magnetophon:matrix.orgmagnetophon
  buildInputs =
    [
      mpv-unwrapped
      vulkan-loader
      libxkbcommon
    ]
    ++ lib.optionals stdenv.isLinux [
      alsa-lib
      wayland

      # X11 / XCB stack (required by winit + xkbcommon-dl)
      xorg.libX11
      xorg.libXcursor
      xorg.libXi
      xorg.libXrandr
      xorg.libXinerama
      xorg.libXpresent
      xorg.libXfixes
      xorg.libXext
      # xorg.libXss
      xorg.libxcb
      # xorg.libX11-xcb
    ]
    ++ lib.optionals stdenv.isDarwin [
      darwin.apple_sdk.frameworks.AppKit
      darwin.apple_sdk.frameworks.CoreGraphics
      darwin.apple_sdk.frameworks.CoreServices
      darwin.apple_sdk.frameworks.Foundation
      darwin.apple_sdk.frameworks.Metal
      darwin.apple_sdk.frameworks.QuartzCore
    ];
15:53:35
@k900:0upti.meK900Hmm weird15:54:29

Show newer messages


Back to Room ListRoom Version: 6