You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[flakes] Where do cross compiled packages go? #5157
Is your feature request related to a problem? Please describe.
It's unclear where cross compiled packages should go.
The docs talk about system as if there is only one. With cross we have two or three.
Describe the solution you'd like Describe alternatives you've considered
I don't care much about the convention chosen. Pretending that cross compiled packages have one system seems like a bad idea.
flake system == build system: packages can't be used properly as a dependency. Who knows what kind of binaries are in there.
flake system == host system: packages can't be filtered by build system without evaluating them to some degree
The latter seems like the lesser evil, but it's still awful. I think this should be done differently altogether. This would all be much more natural if flakes were functions from system and optional buildSystem to outputs. I know that this doesn't work with the current caching approach, which is too tightly coupled to the current flakes design. Did you consider an builtins.importApplyCached : path -> json -> value? It'd behave like f: a: import f a but with a persistent evaluation cache. It seems that current flakes design can be cached with it (and some Nixlang glue), but also allow dynamic uses where not all arguments are statically known and enumerated as attrs.
Reacted by Dennis Gosnell, Philipp Adolf, Michele Guerini Rocco, Michael Hueschen, Alex Shpilkin, Ivan Trubach, Robin Stumm, Alex Martens, Product Engineer, Erik Nygren and 31 more
I wonder if there is any progresses on this, such as workaround or alternative ways to do cross compiling on a X86 host platform? I know that we can use binfmt and run the compiler as userland emulation, but QEMU is still notoriously slow for this. I would argue the lack of cross compilation support is one of the reason why nix (and nix flakes) are not popular despite it should be one of the killer features that nix should have had long implemented
@stevefan1999-personal To be clear, Nix (the build system / package manager) does not care if you’re cross-compiling any more than make does, and Nixpkgs (the package repository built on top of that) is actually surprisingly good at cross-compilation, substantially better than you get in the build systems of most Linux package managers. It’s when you get into Nix Flakes that the cross-compilation support falls apart, because apparently(?) that wasn’t considered important despite all the cross-compilation work in Nixpkgs, and a fair number of people are annoyed at losing it.
Reacted by name_snrl and Linus Warnatz
Reacted by Kira, Henry Hiles, Clint Harrison, Juan Hernandez and Linus Warnatz
Activity
nixos-discourse commentedon Aug 21, 2021
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/how-do-i-cross-compile-a-flake/12062/5
nixos-discourse commentedon Oct 23, 2021
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
https://discourse.nixos.org/t/flakes-nix3-0-issues/15626/10
roberth commentedon Mar 31, 2022
It seems that the
${system}attributes are usually about the runtime system.NixOS/nixpkgs#160061 makes the Nixpkgs configurable for cross and other configs (and needs review).
stevefan1999-personal commentedon Jan 9, 2025
I wonder if there is any progresses on this, such as workaround or alternative ways to do cross compiling on a X86 host platform? I know that we can use binfmt and run the compiler as userland emulation, but QEMU is still notoriously slow for this. I would argue the lack of cross compilation support is one of the reason why nix (and nix flakes) are not popular despite it should be one of the killer features that nix should have had long implemented
alexshpilkin commentedon Jan 9, 2025
@stevefan1999-personal To be clear, Nix (the build system / package manager) does not care if you’re cross-compiling any more than make does, and Nixpkgs (the package repository built on top of that) is actually surprisingly good at cross-compilation, substantially better than you get in the build systems of most Linux package managers. It’s when you get into Nix Flakes that the cross-compilation support falls apart, because apparently(?) that wasn’t considered important despite all the cross-compilation work in Nixpkgs, and a fair number of people are annoyed at losing it.