Building on unsupported platform - arm64 - Intellij Idea

I’m trying to build a Intellij Idea CE locally, because there is no pre-built package available for aarch64.
Machine Apple Silicon M1 running QEMU VM with Ubuntu aarch64 guest.
How difficult would it be to tweak the package definition to make the build on arm64 platform?

user1@mac:~$ nix-build '<nixpkgs>' -A jetbrains.idea-community --show-trace
error: while evaluating the attribute 'installPhase' of the derivation 'idea-community-2021.1' at /nix/store/vcb3crx4l2vmwq5gvkphilks1mphqwk2-nixpkgs-21.05pre285923.ae96c292c0e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'home' at /nix/store/vcb3crx4l2vmwq5gvkphilks1mphqwk2-nixpkgs-21.05pre285923.ae96c292c0e/nixpkgs/pkgs/development/compilers/jetbrains-jdk/default.nix:32:5:
while evaluating the attribute 'configureFlags' of the derivation 'jetbrains-jdk-11.0.10-b1427' at /nix/store/vcb3crx4l2vmwq5gvkphilks1mphqwk2-nixpkgs-21.05pre285923.ae96c292c0e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'preBuild' of the derivation 'openjfx-modular-sdk-11.0.3-1' at /nix/store/vcb3crx4l2vmwq5gvkphilks1mphqwk2-nixpkgs-21.05pre285923.ae96c292c0e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'outputHash' of the derivation 'openjfx-deps-11.0.3-1' at /nix/store/vcb3crx4l2vmwq5gvkphilks1mphqwk2-nixpkgs-21.05pre285923.ae96c292c0e/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:201:11:
Unsupported platform

This depends on what the derivation looks like: when it’s building from source, you might have some chance (though it’d likely need some changes).

In this case, however, the derivation just downloads the pre-built package (nixpkgs/default.nix at 16093daaf21153d25d8e7f7f4605adb5d1c13f06 · NixOS/nixpkgs · GitHub). Making this work on a platform for which no pre-built package is available basically means starting over packaging it :wink:

Perhaps there are actually pre-built images, though, looking at https://youtrack.jetbrains.com/issue/JBR-2526 . I see they’re distributed as dmg rather than tar.gz, though, so that might still need some tweaks to the derivation - but at least perhaps not a rewrite.

1 Like

@raboof this is fantastic answer! Thank you for the references and explanation.
Do you know if there are any similar derivations that I can use as reference? (e.g. a Java app that is build from scratch using custom JDK etc.). I know, this is very vague, but any advice would help.
I am just starting out with Nix, so would appreciate any pointers.