Skip to content

xmonad: fix xmonad --recompile when cross-compiled#397767

Open
sorki wants to merge 1 commit intoNixOS:masterfrom
sorki:srk/crossXmonad
Open

xmonad: fix xmonad --recompile when cross-compiled#397767
sorki wants to merge 1 commit intoNixOS:masterfrom
sorki:srk/crossXmonad

Conversation

@sorki
Copy link
Member

@sorki sorki commented Apr 10, 2025

by using targetPrefix in front of ghc binary.

The contents of the bin directory look like this

armv7l-unknown-linux-gnueabihf-ghc            armv7l-unknown-linux-gnueabihf-hp2ps
armv7l-unknown-linux-gnueabihf-ghc-9.6.6      armv7l-unknown-linux-gnueabihf-hp2ps-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghci           armv7l-unknown-linux-gnueabihf-hsc2hs
armv7l-unknown-linux-gnueabihf-ghci-9.6.6     armv7l-unknown-linux-gnueabihf-hsc2hs-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghc-pkg        hsc2hs-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghc-pkg-9.6.6  xmonad

and before this patch XMONAD_GHC points to just .../bin/ghc.

This is also propagates targetPrefix via ghcWithPackages.passthru set, to make it consistent with
(pkgs.haskellPackages.ghcWithPackages (ps: [])).passthru.targetPrefix
which is equal to pkgs.haskellPackages.ghc.passthru.targetPrefix, but missing when any package is added to the list.

Things done

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

by using `targetPrefix` in front of `ghc` binary.

The contents of the `bin` directory look like this
```shell
armv7l-unknown-linux-gnueabihf-ghc            armv7l-unknown-linux-gnueabihf-hp2ps
armv7l-unknown-linux-gnueabihf-ghc-9.6.6      armv7l-unknown-linux-gnueabihf-hp2ps-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghci           armv7l-unknown-linux-gnueabihf-hsc2hs
armv7l-unknown-linux-gnueabihf-ghci-9.6.6     armv7l-unknown-linux-gnueabihf-hsc2hs-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghc-pkg        hsc2hs-ghc-9.6.6
armv7l-unknown-linux-gnueabihf-ghc-pkg-9.6.6  xmonad
```
and before this patch XMONAD_GHC points to just `.../bin/ghc`.

This is also propagates `targetPrefix` via `ghcWithPackages.passthru` set, to make it
consistent with
 `(pkgs.haskellPackages.ghcWithPackages (ps: [])).passthru.targetPrefix`
which is equal to `pkgs.haskellPackages.ghc.passthru.targetPrefix`, but
missing when any package is added to the list.
@ofborg ofborg bot added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Apr 10, 2025
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: haskell General-purpose, statically typed, purely functional programming language 8.has: module (update) This PR changes an existing module in `nixos/` labels Apr 10, 2025
@nix-owners nix-owners bot requested review from maralorn and sternenseemann April 10, 2025 18:09
@sorki
Copy link
Member Author

sorki commented Apr 10, 2025

cc @sternenseemann

@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 10, 2025
@sternenseemann
Copy link
Member

Note that this is, I guess, less wrong than before, but still incorrect. The cross compiler that would end up being used can't be executed on the platform that xmonad would run on. Therefore xmonad --recompile would fail due to an exec format error.

In principle, you'd need to pick out a cross compiled ghc, however, this is only possible for GHC < 9.6 at the moment…

@sorki
Copy link
Member Author

sorki commented Apr 10, 2025

Yeah you're right, it points to x86 GHC targeting arm (which is executed by arm xmonad --recompile via binfmt hehe).

$ /nix/store/n4nwg1z8n02alsdmppl7kvqzgcrg9hlh-armv7l-unknown-linux-gnueabihf-ghc-9.6.6/bin/armv7l-unknown-linux-gnueabihf-ghc --print-host-platform 
x86_64-unknown-linux

$ /nix/store/n4nwg1z8n02alsdmppl7kvqzgcrg9hlh-armv7l-unknown-linux-gnueabihf-ghc-9.6.6/bin/armv7l-unknown-linux-gnueabihf-ghc --print-target-platform
arm-unknown-linux

@wegank wegank added 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. 12.approvals: 1 This PR was reviewed and approved by one person. labels Apr 12, 2025
@nixpkgs-ci nixpkgs-ci bot removed the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Jun 25, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 13, 2025
@nixpkgs-ci nixpkgs-ci bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: cross-compilation Building packages on a different platform than they will be used on 6.topic: haskell General-purpose, statically typed, purely functional programming language 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 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants