!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

577 Members
129 Servers

Load older messages


SenderMessageTime
30 Dec 2024
@emilazy:matrix.orgemily(btw, still happy to test anything on Darwin you need testing, though I'm sure you could also get an account on the community builder)16:36:59
@rhelmot:matrix.orgrhelmotquick question: what on earth is happening here?17:27:37
@rhelmot:matrix.orgrhelmotnix-repl> builtins.currentSystem "x86_64-linux" nix-repl> pkgsCross.x86_64-freebsd.pkgsTargetTarget { __raw = true; recurseForDerivations = false; stdenv = { ... }; } nix-repl> pkgsCross.x86_64-freebsd.pkgsTargetTarget.stdenv { cc = «derivation /nix/store/nhj8bgij919zkfb9f5z3h11gh3gc3r1f-x86_64-unknown-freebsd-clang-wrapper-19.1.6.drv»; } 17:27:38
@emilazy:matrix.orgemilyhm, what's weird there?17:29:03
@emilazy:matrix.orgemily oh, pkgsTargetTarget being almost empty? 17:29:09
@rhelmot:matrix.orgrhelmotyeah17:29:20
@emilazy:matrix.orgemily does pkgsCross.x86_64-freebsd.callPackage ({ pkgsTargetTarget }: pkgsTargetTarget) behave the same I wonder 17:30:00
@rhelmot:matrix.orgrhelmotyes17:30:29
@rhelmot:matrix.orgrhelmotI found this because I was trying to use pkgsTargetTarget in a derivation and it blew up when I tried to do feature detection on it17:30:54
@rhelmot:matrix.orgrhelmotthis seems to be a known quantity in nixpkgs - every usage of pkgsTargetTarget I've seen seems to not assume it's populated... but why???17:32:25
@emilazy:matrix.orgemily probably because pkgsTargetTarget is weird :) 17:33:14
@emilazy:matrix.orgemily but I defer to Artturin's wisdom here 17:33:58
@lily:lily.flowersLily Foster
In reply to @rhelmot:matrix.org
nix-repl> builtins.currentSystem
"x86_64-linux"

nix-repl> pkgsCross.x86_64-freebsd.pkgsTargetTarget
{
__raw = true;
recurseForDerivations = false;
stdenv = { ... };
}

nix-repl> pkgsCross.x86_64-freebsd.pkgsTargetTarget.stdenv
{
cc = «derivation /nix/store/nhj8bgij919zkfb9f5z3h11gh3gc3r1f-x86_64-unknown-freebsd-clang-wrapper-19.1.6.drv»;
}
yeah from what i understand you can't pkgsTargetTarget from a cross set, it just isn't supported/implemented. what you're seeing seems to be just this "fake" set after bootstrap stages used for a compiler hack, defined here: https://github.com/NixOS/nixpkgs/blob/cd0883f61c95f321983c0d18f53040b8c76fc263/pkgs/stdenv/booter.nix#L142-L163
18:25:55
@rhelmot:matrix.orgrhelmot🥲18:26:29
@lily:lily.flowersLily Foster
In reply to @lily:lily.flowers
yeah from what i understand you can't pkgsTargetTarget from a cross set, it just isn't supported/implemented. what you're seeing seems to be just this "fake" set after bootstrap stages used for a compiler hack, defined here: https://github.com/NixOS/nixpkgs/blob/cd0883f61c95f321983c0d18f53040b8c76fc263/pkgs/stdenv/booter.nix#L142-L163
(idk more precise details of what that hack is for other than the comment right above it)
18:26:46
@rhelmot:matrix.orgrhelmotnixpkgs is a well-documented piece of software that is normal and fun to reverse engineer18:27:19
@lily:lily.flowersLily Fosterjust curious, what is your motivation for using pkgsTargetTarget?18:28:21
@rhelmot:matrix.orgrhelmotwas trying to obtain the c++ stdlib and unwind lib implementations for the rustc wrapper to link against18:30:51
31 Dec 2024
@hsngrmpf:matrix.orgDavHauCould someone merge this fix for cross builds of python packages using maturin: https://github.com/NixOS/nixpkgs/pull/36554007:00:28
@fshp:matrix.orgMaxim Moseychuk joined the room.08:03:50
@fshp:matrix.orgMaxim Moseychuk

Hi, Happy New Year!

Using pkgs.pkgsCross, I can compile a package from nixpkgs for another platform. For example:

# nix-build '<nixpkgs>' -A pkgs.pkgsCross.aarch64-multiplatform.hello

I have a local repository with a package. For example, let’s say it’s a simple hello world.

default.nix:

{ pkgs ? import <nixpkgs> { } }:

{
    myhello = pkgs.callPackage ./pkgs/myhello { };
}

However, I can't build it the same way:

# nix-build -A pkgs.pkgsCross.aarch64-multiplatform.myhello          
error: attribute 'pkgs' in selection path 'pkgs.pkgsCross.aarch64-multiplatform.myhello' not found

I can change pkgs.callPackage in default.nix to pkgs.pkgsCross.aarch64-multiplatform.callPackage. Then the package builds:

# nix-build -A myhello
this derivation will be built:
  /nix/store/3mbcklrdg4dc90qg47fvakv6zv9gwqm2-myhello-1.0-aarch64-unknown-linux-gnu.drv
...

How can I properly test cross-compilation without adding the repository via a channel or flake?
I’d like to test building for different platforms without modifying nix files, as if the package were part of nixpkgs.

09:05:36
@fshp:matrix.orgMaxim Moseychuk *

Hi, Happy New Year!

Using pkgs.pkgsCross, I can compile a package from nixpkgs for another platform. For example:

# nix-build '<nixpkgs>' -A pkgs.pkgsCross.aarch64-multiplatform.hello

I have a local repository with a package. For example, let’s say it’s a simple hello world.

default.nix:

{ pkgs ? import <nixpkgs> { } }:

{
    myhello = pkgs.callPackage ./pkgs/myhello { };
}

However, I can't build it the same way:

# nix-build -A pkgs.pkgsCross.aarch64-multiplatform.myhello          
error: attribute 'pkgs' in selection path 'pkgs.pkgsCross.aarch64-multiplatform.myhello' not found

I can change pkgs.callPackage in default.nix to pkgs.pkgsCross.aarch64-multiplatform.callPackage. Then the package builds:

# nix-build -A myhello
this derivation will be built:
  /nix/store/3mbcklrdg4dc90qg47fvakv6zv9gwqm2-myhello-1.0-aarch64-unknown-linux-gnu.drv
...

How can I properly test cross-compilation without adding the repository via a channel or flake?
I’d like to test building for different platforms without modifying nix files, as if the package were part of nixpkgs.

09:06:44
@k900:0upti.meK900 You can do something like nix-build --expr "(import <nixpkgs> {}).pkgsCross.aarch64-multiplatform.callPackage ./pkgs/myhello {}" 09:06:47
@fshp:matrix.orgMaxim MoseychukThank 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
@k900:0upti.meK900 pkgsCross is basically another instance of nixpkgs 09:15:32
@k900:0upti.meK900Created with the right configuration to be cross-compiled09:15:44
@k900:0upti.meK900The difference between a local file and nixpkgs is that pkgsCross knows nothing about your local file 09:16:08
@k900:0upti.meK900And neither does nixpkgs for that matter 09:16:14
@k900:0upti.meK900Nix itself knows absolutely nothing about any of it09:17:22
@k900:0upti.meK900Nixpkgs is just one big attrset that it pulls from without understanding its structure in any real way 09:17:41

Show newer messages


Back to Room ListRoom Version: 6