Skip to content

fix: error on target platform != x86_64-unknown-linux-gnu#9

Open
haenoe wants to merge 1 commit intotypst:mainfrom
haenoe:fix-other-platforms
Open

fix: error on target platform != x86_64-unknown-linux-gnu#9
haenoe wants to merge 1 commit intotypst:mainfrom
haenoe:fix-other-platforms

Conversation

@haenoe
Copy link

@haenoe haenoe commented Mar 2, 2026

Hey there, thanks a lot for maintaining this! Hope you don't mind me skipping the issue step.

When trying to use this flake on Darwin, I ran into the following error:

❯ nix run github:typst/typst-flake
error:
       … while evaluating the attribute 'value'
         at /nix/store/2f0w7jys97fs8sld7qqg1ck7h2j3asjg-source/lib/modules.nix:1118:7:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |       ^
         1119|       inherit (res.defsFinal') highestPrio;

       … while calling the 'addErrorContext' builtin
         at /nix/store/2f0w7jys97fs8sld7qqg1ck7h2j3asjg-source/lib/modules.nix:1118:15:
         1117|     // {
         1118|       value = addErrorContext "while evaluating the option `${showOption loc}':" value;
             |               ^
         1119|       inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: The `env` attribute set can only contain derivation, string, boolean or integer attributes. The `RUSTFLAGS` attribute is of type null.

This is due the fact that RUSTFLAGS is set to null, when target != x86_64-unknown-linux-gnu see here

rustflags =
            if pkgs.stdenv.hostPlatform.rust.rustcTargetSpec == "x86_64-unknown-linux-gnu" then
              # Upstream defaults to lld on x86_64-unknown-linux-gnu, we need to use the system linker
              "-Clinker-features=-lld -Clink-self-contained=-linker"
            else
              null;

Relevant check in nixpkgs

        mapAttrs (
          n: v:
          assert assertMsg (isString v || isBool v || isInt v || isDerivation v)
            "The `env` attribute set can only contain derivation, string, boolean or integer attributes. The `${n}` attribute is of type ${builtins.typeOf v}.";
          v
        ) env';

Minor note: as per https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags an empty RUSTFLAGS still overrides user configuration (e.g. in cargo config); see this

Ensure `RUSTFLAGS` is not `null`, when target platform is not x86_64-unknown-linux-gnu but rather `""`.
Note that as per https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags an empty RUSTFLAGS still overrides user configuration (e.g. in cargo config).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant