Skip to content

Sometimes build nix-manual when cross compiling#13557

Merged
xokdvium merged 1 commit intoNixOS:masterfrom
Jayman2000:sometimes-build-manual-when-cross-compiling
Jul 26, 2025
Merged

Sometimes build nix-manual when cross compiling#13557
xokdvium merged 1 commit intoNixOS:masterfrom
Jayman2000:sometimes-build-manual-when-cross-compiling

Conversation

@Jayman2000
Copy link
Contributor

@Jayman2000 Jayman2000 commented Jul 26, 2025

Motivation

At the moment, the nix-manual Meson subproject won’t be built if you’re cross compiling. This pull request makes it so that the nix-manual Meson subproject will be built if you’re cross compiling Nix and the build system is capable of executing host system binaries. (See the commit message for additional details).

Context

The main motivation behind this change is to deal with this Nixpkgs issue. Building pkgs.nixStatic counts as cross compiling Nix, and pkgs.nixStatic is supposed to produce a man output. Building pkgs.nixStatic currently fails because it isn’t actually producing a man output. That issue will go away once this pull request gets backported to Nix 2.28.x.

You can verify that this pull request fixes that Nixpkgs issue by doing the following:

  1. Create a file named nix-static.nix that contains this Nix expression:

    # This file is dedicated to the public domain using 🅭🄍1.0:
    # <https://creativecommons.org/publicdomain/zero/1.0>.
    let
      nixpkgsCommit = "17f6bd177404d6d43017595c5264756764444ab8";
      nixpkgsTarball = builtins.fetchTarball {
        url = "https://github.com/NixOS/nixpkgs/archive/${nixpkgsCommit}.tar.gz";
        sha256 = "1nwqbj0bmhdqf34d0y6qbpnwqa9bkhlqd03ffv60yami7fppnyb6";
      };
      pkgs = import nixpkgsTarball { };
    in
    {
      upstreamVersion = pkgs.nixStatic;
      versionFromThisPR = pkgs.nixStatic.overrideAttrs (
        finalAttrs: previousAttrs: {
          src = pkgs.fetchFromGitHub {
            owner = "Jayman2000";
            repo = "nix-pr";
            rev = "5e407e6abb5738f72b8b5aeeaa003728fe584c2f";
            hash = "sha256-s9lK09RpKklka/xDwPhmmUge19oR/zYp9lfuJkb+XHo=";
          };
        }
      );
    }
  2. Build that expression by running this command:

    nix-build --keep-going <path to nix-static.nix>
  3. Make sure that the build fails with exactly one error. The upstreamVersion attribute should fail to build with an error about the builder not creating a man output. The versionFromThisPR attribute should build successfully.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

Before this change, if you were cross compiling Nix, then the nix-manual
subproject would never get built. In some situations, it makes sense to
not build the nix-manual subproject when cross compiling. For example,
if the build system is x86_64 and the host system is riscv64, then it
makes sense to not build the manual. Building the manual requires
executing certain build artifacts, and you can’t run x86_64 executables
on riscv64 systems.

That being said, there are some situations where it does make sense to
build the nix-manual subproject when cross compiling. For example, if
the build system is x86_64 and the host system is i686, then it doesn’t
make sense to not build the manual. You can run i686 executables on
x86_64 systems just fine.

This change makes it so that the nix-manual subproject will sometimes
get built when cross compiling. Specifically, the nix-manual subproject
will get built as long as the doc-gen option is enabled and the build
system is capable of running host binaries.

---

The main motivation behind this change is to fix this Nixpkgs issue [1].
Building pkgs.nixStatic counts as cross compiling Nix, and
pkgs.nixStatic is supposed to produce a man output. Building
pkgs.nixStatic currently fails because it isn’t actually producing a man
output. That issue will go away once this commit gets backported to Nix
2.28.x.

[1]: <NixOS/nixpkgs#426410>
@Jayman2000 Jayman2000 requested a review from edolstra as a code owner July 26, 2025 20:11
@Jayman2000 Jayman2000 changed the title Sometimes build nix-manual when cross compiling Sometimes build nix-manual when cross compiling Jul 26, 2025
@xokdvium
Copy link
Contributor

@Jayman2000, thanks! The fix makes sense. It's now clear why this affected only the monolithic build of 2.28 - the top-level meson file isn't used in componentized builds.

@xokdvium xokdvium added the backport 2.28-maintenance Automatically creates a PR against the branch label Jul 26, 2025
Copy link
Contributor

@xokdvium xokdvium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xokdvium xokdvium merged commit a2561b8 into NixOS:master Jul 26, 2025
16 checks passed
xokdvium added a commit that referenced this pull request Jul 26, 2025
…3557

Sometimes build `nix-manual` when cross compiling (backport #13557)
@Jayman2000 Jayman2000 deleted the sometimes-build-manual-when-cross-compiling branch July 27, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.28-maintenance Automatically creates a PR against the branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants