Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/fontsdir: fix cross #371049

Closed

Conversation

RossComputerGuy
Copy link
Member

Things done

Fixes cross which @jmbaur tried fixing but it's a problem again.

/build/.attr-0l2nkwhif96f51f4amnlf414lhl4rv9vh8iffyp431v6s28gsr90: line 7: /nix/store/dibi6jg43m0aalml2d76lb8f5i0y67mk-mkfontscale-riscv64-unknown-linux-gnu-1.2.3/bin/mkfontscale: cannot execute binary file: Exec format error
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jan 5, 2025
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Jan 5, 2025
@jmbaur
Copy link
Contributor

jmbaur commented Jan 5, 2025

I don't see how this is possible. I've tried to reproduce this issue where you've got an aarch64-linux buildPlatform and a riscv64-linux hostPlatform below:

let
  someRevOnMaster = "742e83951eefc0a0a74dd95a6523300dacfb4238";
  inherit
    (import (builtins.getFlake "github:nixos/nixpkgs/${someRevOnMaster}") {
      system = "aarch64-linux";
    })
    pkgsCross
    ;
in
builtins.head (
  builtins.filter (drv: drv.name == "X11-fonts")
    (pkgsCross.riscv64.nixos {
      fonts.fontDir.enable = true;
      boot.isContainer = true;
    }).config.environment.systemPackages
)

This results in the following:

$ nix eval --impure --file /tmp/test.nix
evaluation warning: system.stateVersion is not set, defaulting to 25.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.sta
teVersion.
«derivation /nix/store/0gp81b50wg2bf2dbqswkbhvy21i8x552-X11-fonts.drv»

And that drv has the following properties

{
  "/nix/store/0gp81b50wg2bf2dbqswkbhvy21i8x552-X11-fonts.drv": {
    "args": [
      "-e",
      "/nix/store/v6x3cs394jgqfbi0a42pam708flxaphh-default-builder.sh"
    ],
    "builder": "/nix/store/rm5cm7wk2a6y17gz52ymh39d5fzai2lv-bash-5.2p37/bin/bash",
    "env": {
      "__structuredAttrs": "",
      "buildCommand": "mkdir -p \"$out/share/X11/fonts\"\nfont_regexp='.*\\.\\(ttf\\|ttc\\|otb\\|otf\\|pcf\\|pfa\\|pfb\\|bdf\\)\\(\\.gz\\)?'\nfind  -regex \"$font_
regexp\" \\\n  -exec ln -sf -t \"$out/share/X11/fonts\" '{}' \\;\ncd \"$out/share/X11/fonts\"\n\nmkfontscale\nmkfontdir\ncat $(find /nix/store/vji0ax6kvdm8sxbf7b8m
m1rbwj2ns271-font-alias-riscv64-unknown-linux-gnu-1.0.5/ -name fonts.alias) >fonts.alias\n",
      "buildInputs": "",
      "builder": "/nix/store/rm5cm7wk2a6y17gz52ymh39d5fzai2lv-bash-5.2p37/bin/bash",
      "cmakeFlags": "-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=riscv64 -DCMAKE_HOST_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_PROCESSOR=aarch64",
      "configureFlags": "--build=aarch64-unknown-linux-gnu --host=riscv64-unknown-linux-gnu",
      "depsBuildBuild": "",
      "depsBuildBuildPropagated": "",
      "depsBuildTarget": "",
      "depsBuildTargetPropagated": "",
      "depsHostHost": "",
      "depsHostHostPropagated": "",
      "depsTargetTarget": "",
      "depsTargetTargetPropagated": "",
      "doCheck": "",
      "doInstallCheck": "",
      "enableParallelBuilding": "1",
      "enableParallelChecking": "1",
      "enableParallelInstalling": "1",
      "mesonFlags": "--cross-file=/nix/store/75gpq48zk7xppjl5hpxrwrqkv68hpwd5-cross-file.conf",
      "name": "X11-fonts",
      "nativeBuildInputs": "/nix/store/fl5mjwwd1ibphb011kmwqsl697n2abhr-gzip-1.13 /nix/store/qzwh2ml21iw67ln2qr2l9r17a2jmh6a8-mkfontscale-1.2.3 /nix/store/qzwh2ml2
1iw67ln2qr2l9r17a2jmh6a8-mkfontscale-1.2.3",
      "out": "/nix/store/dlrbwcc2i14a2c8yhlylxwnw268ss6pf-X11-fonts",
      "outputs": "out",
      "passAsFile": "buildCommand",
      "patches": "",
      "preferLocalBuild": "1",
      "propagatedBuildInputs": "",
      "propagatedNativeBuildInputs": "",
      "stdenv": "/nix/store/1vf838bcfr4hdi1pvy0wvhsm16gl8y98-stdenv-linux",
      "strictDeps": "1",
      "system": "aarch64-linux"
    },
    "inputDrvs": {
      "/nix/store/1fyz1cf9m2yvxjyq3gx4zqnrmxl9i7lp-font-alias-riscv64-unknown-linux-gnu-1.0.5.drv": {
        "dynamicOutputs": {},
        "outputs": [
          "out"
        ]
      },
      "/nix/store/9g3kgj711gg4pvfnl5aad1rghzw81sr8-gzip-1.13.drv": {
        "dynamicOutputs": {},
        "outputs": [
          "out"
        ]
      },
      "/nix/store/cggy6p43sd1qcil8h56cp3gxdx3q7dy3-mkfontscale-1.2.3.drv": {
        "dynamicOutputs": {},
        "outputs": [
          "out"
        ]
      },
      "/nix/store/dmvym833yfmarj3ybjknd50h6wq8vs26-stdenv-linux.drv": {
        "dynamicOutputs": {},
        "outputs": [
          "out"
        ]
      },
      "/nix/store/lczmm84pj8qgp3kpkwrg1lqy0bji53gh-bash-5.2p37.drv": {
        "dynamicOutputs": {},
        "outputs": [
          "out"
        ]
      }
    },
    "inputSrcs": [
      "/nix/store/75gpq48zk7xppjl5hpxrwrqkv68hpwd5-cross-file.conf",
      "/nix/store/v6x3cs394jgqfbi0a42pam708flxaphh-default-builder.sh"
    ],
    "name": "X11-fonts",
    "outputs": {
      "out": {
        "path": "/nix/store/dlrbwcc2i14a2c8yhlylxwnw268ss6pf-X11-fonts"
      }
    },
    "system": "aarch64-linux"
  }
}

As can be seen, mkfontscale is coming from /nix/store/qzwh2ml21iw67ln2qr2l9r17a2jmh6a8-mkfontscale-1.2.3, which is not cross compiled as in your error output.

@jmbaur jmbaur self-requested a review January 5, 2025 07:53
@RossComputerGuy
Copy link
Member Author

That's strange, I'm just using the local and cross system config under the nixpkgs option in NixOS but I don't know how that could cause this.

@jmbaur
Copy link
Contributor

jmbaur commented Jan 5, 2025

That's strange, I'm just using the local and cross system config under the nixpkgs option in NixOS but I don't know how that could cause this.

Can you paste a minimal reproducer here?

callPackage is supposed to choose the package-set for us, so I wouldn't expect this extra fix to be needed.

@RossComputerGuy
Copy link
Member Author

let
  nixpkgs = builtins.getFlake "github:nixos/nixpkgs/d29ab98cd4a70a387b8ceea3e930b3340d41ac5a";
in
builtins.head (
  builtins.filter (drv: drv.name == "X11-fonts")
    (import "${nixpkgs}/nixos/lib/eval-config.nix" {
      modules = [
        {
          fonts.fontDir.enable = true;
          boot.isContainer = true;
          nixpkgs.crossSystem = { system = "riscv64-linux"; };
          nixpkgs.localSystem = { system = "aarch64-linux"; };
        }
      ];
    }).config.environment.systemPackages
)

I made a reproducer based on what you had and it does produce the same error.

@RossComputerGuy
Copy link
Member Author

Interesting, your reproducer works. It seems the culprit is something with passing through pkgs vs the nixpkgs options is changing the behavior.

@RossComputerGuy
Copy link
Member Author

Artturin and I chased where this was going wrong, the problem is #366959 didn't get into 24.11.

@RossComputerGuy RossComputerGuy deleted the fix/cross-os/fonts branch January 6, 2025 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants