Skip to content

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

Merged
drupol merged 1 commit intotypst:mainfrom
haenoe:fix-other-platforms
Mar 11, 2026
Merged

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

Conversation

@haenoe
Copy link
Contributor

@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).
@drupol
Copy link
Collaborator

drupol commented Mar 11, 2026

Going to fix this today !

@haenoe
Copy link
Contributor Author

haenoe commented Mar 11, 2026

No stress, just wanted to link the PR ^^'
Thank you :D

@drupol drupol merged commit a9422ef into typst:main Mar 11, 2026
@drupol
Copy link
Collaborator

drupol commented Mar 11, 2026

Thank you for providing the fix!

@tommens
Copy link

tommens commented Mar 11, 2026

I just run the installation again locally on my MacBook Pro today, and it works correctly now. Thanks to all for the effort and speedy fix!

@haenoe
Copy link
Contributor Author

haenoe commented Mar 11, 2026

Happy Typsting! :D

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.

3 participants