!ayCRiZriCVtuCUpeLp:nixos.org

Nix Cross Compiling

581 Members
128 Servers

Load older messages


SenderMessageTime
10 Feb 2025
@rhelmot:matrix.orgrhelmotas far as I can tell it pulls stuff out of drv.__spliced.pkgsSomethingSomething which is provided by splice.nix but __spliced isn't present in nix repl04:00:41
@artturin:matrix.orgArtturincallPackage gets packaged from __splicedPackages04:01:05
@artturin:matrix.orgArtturin* callPackage gets packages from __splicedPackages04:01:21
@artturin:matrix.orgArtturin* callPackage gets attrs from __splicedPackages04:01:28
@artturin:matrix.orgArtturinpkgsCross.X.__splicedPackages to access them04:01:55
@rhelmot:matrix.orgrhelmothm04:02:24
@rhelmot:matrix.orgrhelmotwhat's special about pkgsCross that causes __splicedPackages to contain the __spliced attribute but not the toplevel04:03:03
@artturin:matrix.orgArtturinhttps://github.com/NixOS/nixpkgs/blob/f202c36babad2412fc20a061d56c1f378efa806d/pkgs/top-level/splice.nix#L18104:03:36
@artturin:matrix.orgArtturin
In reply to @rhelmot:matrix.org
what's special about pkgsCross that causes __splicedPackages to contain the __spliced attribute but not the toplevel
toplevel is just normal pkgs
04:04:06
@rhelmot:matrix.orgrhelmothmmk... so actuallySplice is adjacentPackages != null04:05:05
@rhelmot:matrix.orgrhelmothere's what I'm trying to do: I want to instantiate nixpkgs with localSystem = A and crossSystem = B, do some builds, transfer the closure onto a B machine, then do the same instantiation so that B doesn't have to do any heavy building of its own... but then import pkgs/build-support/trivial-builders/default.nix with a new stdenv which has both build and host as B so that B can do things like build config files. the problem I'm foreseeing is that it will try to splice its dependencies and end up with stuff that can only run on A. I've been struggling to construct a spliced package set that, well, effectively lies about what e.g. bash.__spliced.buildHost is and actually gives hostHost.05:14:25
@rhelmot:matrix.orgrhelmotthe reason for this task: being able to build nixbsd installer images. A here is Linux and B here is e.g. OpenBSD which doesn't have a real stdenv and can't build anything natively05:16:16
@trofi:matrix.orgtrofi loongarch64's libgcc is broken: https://github.com/NixOS/nixpkgs/pull/381016 23:18:42
12 Feb 2025
@kira:jakira.spaceKira changed their display name from kira to Kira.19:59:44
14 Feb 2025
@bitestring:matrix.orgbitestring

Hi, can anyone please help me how to get started on cross-compilation. Documentation is very confusing and scattered across multiple places. I want to get GHC compiler than can compile my Haskell code to both ARM64 Linux and ARM64 Android. However I do not know where to get started. I tried the following flake.nix

{
  description = "Haskell Playground";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
      let
        pkgsBuildSystem = import nixpkgs {
          localSystem = "x86_64-linux"; # buildPlatform
          config = {
            android_sdk.accept_license = true;
            allowUnfree = true;
          };
        };
        pkgs = pkgsBuildSystem.pkgsCross.aarch64-android-prebuilt;
        hs = pkgs.haskell.packages."ghc966"; # need to match Stackage LTS version from stack.yaml resolver
        ghc = hs.ghc.override {
          enableRelocatedStaticLibs = true;
          enableShared = true;
        };
        buildDependencies = with pkgs; [
          # --- System ---
          zlib

          # Haskell deps
          stack
          ghc # GHC compiler in the desired version (will be available on PATH)
        ];
      in
      {
        formatter = pkgs.nixfmt-rfc-style;
        packages.aarch64-android.default = pkgs.mkShell {
          buildInputs = [ ];
          nativeBuildInputs = buildDependencies;
          LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildDependencies;
        };
      };
}

However nix develop fails with

./zconf.h:446:14: fatal error: 'sys/types.h' file not found
13:14:55
@bitestring:matrix.orgbitestring *

Hi, can anyone please help me how to get started on cross-compilation. Documentation is very confusing and scattered across multiple places. I want to get GHC compiler than can compile my Haskell code to both ARM64 Linux and ARM64 Android. However I do not know where to get started. I tried the following flake.nix

{
  description = "Haskell Playground";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  };

  outputs =
    {
      self,
      nixpkgs,
    }:
      let
        pkgsBuildSystem = import nixpkgs {
          localSystem = "x86_64-linux"; # buildPlatform
          config = {
            android_sdk.accept_license = true;
            allowUnfree = true;
          };
        };
        pkgs = pkgsBuildSystem.pkgsCross.aarch64-android-prebuilt;
        hs = pkgs.haskell.packages."ghc966"; # need to match Stackage LTS version from stack.yaml resolver
        ghc = hs.ghc.override {
          enableRelocatedStaticLibs = true;
          enableShared = true;
        };
        buildDependencies = with pkgs; [
          zlib
          stack
          ghc # GHC compiler in the desired version (will be available on PATH)
        ];
      in
      {
        formatter = pkgs.nixfmt-rfc-style;
        packages.aarch64-android.default = pkgs.mkShell {
          buildInputs = [ ];
          nativeBuildInputs = buildDependencies;
          LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildDependencies;
        };
      };
}

However nix develop fails with

./zconf.h:446:14: fatal error: 'sys/types.h' file not found
13:16:14
@alexfmpe:matrix.orgalexfmpeYeah, android has regressed quite a bit 16:17:18
@alexfmpe:matrix.orgalexfmpeIt worked a few years back, not sure to which extent16:17:27
@alexfmpe:matrix.orgalexfmpeFor haskell I mean16:17:43
@emilazy:matrix.orgemilynobody really puts effort into maintaining Android and iOS upstream in Nixpkgs so they don't really work16:17:53
@alexfmpe:matrix.orgalexfmpeA few months ago I found some low hanging fruit and managed to build non TH libs16:18:04
@alexfmpe:matrix.orgalexfmpehttps://github.com/NixOS/nixpkgs/pull/35554316:18:06
@alexfmpe:matrix.orgalexfmpeBut rebasing this on recent nixpkgs yielded the same results you're seeing16:18:24
@alexfmpe:matrix.orgalexfmpeYou might want to try haskell.nix in the meantime16:19:00
@reckenrode:matrix.orgRandy EckenrodeI don’t even know what iOS support would look like in nixpkgs. Pretty much everything assumes Darwin = macOS.16:19:30
@reckenrode:matrix.orgRandy Eckenrode(I know there is/was some support, but it’s been broken for a while.)16:19:45
@reckenrode:matrix.orgRandy EckenrodeIt’s also such a bad idea due to App Store rules. You’re better off using xcodenv.16:20:01
@alexfmpe:matrix.orgalexfmpe
In reply to @alexfmpe:matrix.org
You might want to try haskell.nix in the meantime
Loathe as I am of perpetuating critical mass for company managed turfs
16:20:22
@alexfmpe:matrix.orgalexfmpe
In reply to @reckenrode:matrix.org
It’s also such a bad idea due to App Store rules. You’re better off using xcodenv.
I remember this debate happening a couple times but I don't think I'll be able to get acquainted enough to have an opinion on mobile until at least 8.10 ghcjs is dead
16:23:09
@alexfmpe:matrix.orgalexfmpeAt any rate the original question was for android, which seems more amenable and where there's more current progress16:24:04

Show newer messages


Back to Room ListRoom Version: 6