Nix Cross Compiling | 577 Members | |
| 127 Servers |
| Sender | Message | Time |
|---|---|---|
| 31 Dec 2024 | ||
| Hi, Happy New Year! Using pkgs.pkgsCross, I can compile a package from nixpkgs for another platform. For example:
I have a local repository with a package. For example, let’s say it’s a simple hello world. default.nix:
However, I can't build it the same way:
I can change pkgs.callPackage in default.nix to pkgs.pkgsCross.aarch64-multiplatform.callPackage. Then the package builds:
How can I properly test cross-compilation without adding the repository via a channel or flake? | 09:05:36 | |
| * Hi, Happy New Year! Using
I have a local repository with a package. For example, let’s say it’s a simple hello world. default.nix:
However, I can't build it the same way:
I can change
How can I properly test cross-compilation without adding the repository via a channel or flake? | 09:06:44 | |
You can do something like nix-build --expr "(import <nixpkgs> {}).pkgsCross.aarch64-multiplatform.callPackage ./pkgs/myhello {}" | 09:06:47 | |
| Thank you very much! But what is the difference between a local file and nixpkgs? How does nix know that a package with a prefix should be cross-compiled? I looked in the nixpkgs repository, but I didn't understand how pkgsCross works, since the packages are declared in one place. Apparently, it's not just the package name, but something generated automatically. | 09:14:43 | |
pkgsCross is basically another instance of nixpkgs | 09:15:32 | |
| Created with the right configuration to be cross-compiled | 09:15:44 | |
| The difference between a local file and nixpkgs is that pkgsCross knows nothing about your local file | 09:16:08 | |
| And neither does nixpkgs for that matter | 09:16:14 | |
| Nix itself knows absolutely nothing about any of it | 09:17:22 | |
| Nixpkgs is just one big attrset that it pulls from without understanding its structure in any real way | 09:17:41 | |
| If pkgsCross is another instance of nixpkgs, I tried passing it as an explicit parameter, and it worked.
| 09:33:26 | |
| 12:38:42 | ||
| 14:51:15 | ||
| 1 Jan 2025 | ||
| 14:26:28 | ||
| 20:00:23 | ||
| 23:29:54 | ||
| 2 Jan 2025 | ||
| alright chat I think we are almost out of dogshit edge cases before I can resume reviews on the rustc stuff | 09:09:31 | |
| this last case comes from being on freebsd and compiling... get ready for it... | 09:09:45 | |
| pkgsCross.aarch64-multiplatform.pkgsLLVM.buildPackages.rustc | 09:09:59 | |
| One day we'll get to Qt6 cross | 09:10:15 | |
| And then to KF6 | 09:10:17 | |
| And then we'll have to figure out corrosion on cross | 09:10:23 | |
| And I am not looking forward to that day | 09:10:28 | |
the problem for the thing I posted seems to be related to clang being multi-target now. we tell rustc configureFlags that --set=target.aarch64-unknown-linux-gnu.linker=/nix/store/6bjs7ai2ai14fdx6kvrfgdfhc16a19md-aarch64-unknown-linux-gnu-clang-wrapper-19.1.6/bin/aarch64-unknown-linux-gnu-clang which is correct but it doesn't pass any flags indicating what linker to use, so it just uses un-prefixed ld which is NOT multi-target and so the compile fails | 09:13:52 | |
| ld is gnu binutils here | 09:14:44 | |
| is this even a legal configuration? | 09:14:52 | |
| I can't remember why I set up the freebsd stdenv to be clang + gnu binutils but it's been working until now... | 09:16:15 | |
| 3 Jan 2025 | ||
| 10:28:12 | ||
| 15:05:59 | ||
| 15:25:00 | ||