Skip to content

[flakes] Where do cross compiled packages go? #5157

Open

Description

@roberth

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.

Activity

  1. nixos-discourse commented on Aug 21, 2021

    @nixos-discourse

    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

  2. nixos-discourse commented on Oct 23, 2021

    @nixos-discourse

    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

  3. roberth commented on Mar 31, 2022

    @roberth
    MemberAuthor

    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).

  4. stevefan1999-personal commented on Jan 9, 2025

    @stevefan1999-personal

    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

  5. alexshpilkin commented on Jan 9, 2025

    @alexshpilkin
    Member

    @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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions