!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

555 Members
119 Servers

Load older messages


SenderMessageTime
30 Sep 2025
@17lifers:mikuplushfarm.ovh17lifers (at mikuplushfarm) joined the room.16:05:09
@17lifers:mikuplushfarm.ovh17lifers (at mikuplushfarm) 16:06:50
@17lifers:mikuplushfarm.ovh17lifers (at mikuplushfarm) left the room.18:24:05
1 Oct 2025
@qyriad:katesiria.orgQyriad left the room.12:22:18
@truelle_trash_queen:matrix.orgTheodora The Absurdist Schizotisticoball joined the room.13:48:42
2 Oct 2025
@spikespaz:envs.netspikespaz are there any good examples of cross compiling a windows dylib using rust-overlay, but no naersk, no crane, and no fenix? I could read through their source to see how they work, but that's a lot of effort. I tried writing the derivation as trivially as possible, but pkgs.pkgsCross.mingw32.callPackage'd it, and it didn't work. Then I tried setting environment variables, also doesn't work. I think I need to be more granular choosing dependencies from buildPackages, but I'm not sure what that looks like. Any vetted resources appreciated. 21:05:53
@rosssmyth:matrix.orgrosssmythWhat is your "trival" derivation? I cross to mingw at work for one project. I'd recommend crossing to mingwW64 is you are targeting x86_64 fwiw21:17:46
@spikespaz:envs.netspikespazit's a 32 bit dylib for a game.21:18:20
@rosssmyth:matrix.orgrosssmythHere's an example that is pretty close to what I do: https://github.com/RossSmyth/rustNixExample/blob/rustTemplate/flake.nix21:18:47
@spikespaz:envs.netspikespaz

I'll look at that. As for the prototype, I've tried a bunch of things, but here's where I left off yesterday.

{ sourceRoot, lib, pkgsCross, makeRustPlatform }:

pkgsCross.mingw32.callPackage
({ rustPlatform, buildPackages, pkg-config, cmake, wine }:
  buildPackages.rustPlatform.buildRustPackage (finalAttrs:
    let
      inherit (finalAttrs) src pname version meta buildInputs;
      manifest = lib.importTOML "${src}/ewext/Cargo.toml";
    in {
      pname = "ewext";
      inherit (manifest.package) version;

      src = sourceRoot;
      sourceRoot = "source/ewext";

      cargoLock.lockFile = "${src}/ewext/Cargo.lock";

      # cargoBuildTarget = "i686-pc-windows-gnu";

      strictDeps = true;
      nativeBuildInputs = [ pkg-config cmake ];

      nativeCheckInputs = [ wine ];
      doCheck = false;
      # buildInputs = with pkgsCross.mingw32; [ openssl ];

      env = { CARGO_TARGET_I686_PC_WINDOWS_GNU_RUNNER = "wine"; };

      # env = {
      #   # CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER = "${mingw32.stdenv.cc.targetPrefix}gcc";
      #   OPENSSL_DIR = "${lib.getDev pkgsCross.mingw32.openssl}";
      #   OPENSSL_LIB_DIR = "${lib.getLib pkgsCross.mingw32.openssl}/lib";
      #   OPENSSL_NO_VENDOR = 1;
      # };

      meta = { };
    })) { }

21:19:52
@rosssmyth:matrix.orgrosssmyth why are you using the buildPackages pkgset? That will for sure do the wrong thing. 21:20:43
@rosssmyth:matrix.orgrosssmyth Just use the rustPlatform that you get from callPackage 21:21:40
@rosssmyth:matrix.orgrosssmythOr no, sorry I confused it with pkgsBuildBuild. But still it is strange to do21:22:47
@spikespaz:envs.netspikespaz Because if you override the rustPlatform from outside, that technically belongs in buildPackages anyway, since it's build->target not host->target. So I got rustPlatform from buildPackages to avoid building i686-pc-windows-gnu-rustc 21:24:03
@rosssmyth:matrix.orgrosssmyth There is no target here, you are not building a compiler. You need a rustc that is build->host, so it must come from pkgsBuildHost, which buildPackages is an alias for. 21:26:44
@rosssmyth:matrix.orgrosssmythSo yes it must be in pkgsBuildHost, but it will be regardless21:27:11
@rosssmyth:matrix.orgrosssmythAs that is what the rustPlatform pkgset does21:27:26
@rosssmyth:matrix.orgrosssmythAnyways, you don't show how you build the rustPlatform 21:28:06
@spikespaz:envs.netspikespaz so if I use rustPlatform from the package input, it starts to compile i686-pc-windows-gnu-rustc and friends, I don't think that's what we want. 21:29:31
@rosssmyth:matrix.orgrosssmythThat is exactly what you want21:29:51
@rosssmyth:matrix.orgrosssmythUnless you use rustc from rust-overlay21:30:07
@rosssmyth:matrix.orgrosssmythIn which case you can just tell it to do the right thing21:30:42
@spikespaz:envs.netspikespazDoesn't that require a binfmt translator to run the windows-native rustc?21:31:09
@rosssmyth:matrix.orgrosssmythThat is not what it is compiling. 21:31:28
@rosssmyth:matrix.orgrosssmythIt is basically compiling rustc that can target x8621:31:38
@rosssmyth:matrix.orgrosssmythBut because of limitation of the rustc derivation it must rebuild all of rustc21:31:51
@spikespaz:envs.netspikespaz How does this look to you? This is very much in flux, and the outer rustPlatform from rust-overlay is unused at the moment. That is on purpose; I'd like to get it working with nixpkgs#rustPlatform.
https://github.com/spikespaz-contrib/noita-entangled-worlds/blob/u/jacob/nix-package-ewext/nix/packages/ewext.nix
21:32:15
@rosssmyth:matrix.orgrosssmythIt is target-prefixed like gcc21:32:05
@rosssmyth:matrix.orgrosssmythtargets is a list 21:32:51
@spikespaz:envs.netspikespazit's not being used anyway at the moment.21:33:15

Show newer messages


Back to Room ListRoom Version: 6