NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.08k forks source link

Build failure: Pyinstaller #342931

Closed Eveeifyeve closed 1 month ago

Eveeifyeve commented 1 month ago

Steps To Reproduce

Steps to reproduce the behaviour:

  1. build PyInstaller on Darwin

Build log

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:9:12:
            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/d9gbq853jvbccrz5g3y0irbwgc57w137-source/pkgs/stdenv/generic/make-derivation.nix:336:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/d9gbq853jvbccrz5g3y0irbwgc57w137-source/pkgs/stdenv/generic/make-derivation.nix:380:7:
          379|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          380|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          381|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

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

       error: Package ‘glibc-nolibgcc-2.39-52’ in /nix/store/d9gbq853jvbccrz5g3y0irbwgc57w137-source/pkgs/development/libraries/glibc/default.nix:183 is not available on the requested hostPlatform:
         hostPlatform.config = "aarch64-apple-darwin"
         package.meta.platforms = [
           "aarch64-linux"
           "armv5tel-linux"
           "armv6l-linux"
           "armv7a-linux"
           "armv7l-linux"
           "i686-linux"
           "loongarch64-linux"
           "m68k-linux"
           "microblaze-linux"
           "microblazeel-linux"
           "mips-linux"
           "mips64-linux"
           "mips64el-linux"
           "mipsel-linux"
           "powerpc64-linux"
           "powerpc64le-linux"
           "riscv32-linux"
           "riscv64-linux"
           "s390-linux"
           "s390x-linux"
           "x86_64-linux"
         ]
         package.meta.badPlatforms = [ ]
       , refusing to evaluate.

       a) To temporarily allow packages that are unsupported for this system, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowUnsupportedSystem = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowUnsupportedSystem = true; }
       to ~/.config/nixpkgs/config.nix.

Additional context

It fails to build at gcc as gcc is not avlible on macOS

Notify maintainers

CC @h7x4

Metadata

 - system: `"aarch64-darwin"`
 - host os: `Darwin 24.1.0, macOS 15.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.23.3`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`

Add a :+1: reaction to issues you find important.

Eveeifyeve commented 1 month ago

Is it possible that you can make gcc only in linux but clang if pyinstaller uses clang for darwin to use that?

Eveeifyeve commented 1 month ago

I got it working I am willing to contribute a fix to this.

Eveeifyeve commented 1 month ago

I will need to some how package macholib since pyinstaller requires it for macos systems.

Eveeifyeve commented 1 month ago

But first of all since gcc is required on linux is there a possible if linux include gcc instead of clang.

h7x4 commented 1 month ago

Based on https://github.com/pyinstaller/pyinstaller?tab=readme-ov-file#requirements-and-tested-platforms, it seems like ldd and the binutils stuff is only required on linux. Maybe we could just throw in a lib.optionals stdenv.isLinux here?

https://github.com/NixOS/nixpkgs/blob/99dc8785f6a0adac95f5e2ab05cc2e1bf666d172/pkgs/development/python-modules/pyinstaller/default.nix#L40-L42

Do you know if more needed to be done to fix the darwin build? Feel free to open a PR if you'd like.

Eveeifyeve commented 1 month ago

Based on https://github.com/pyinstaller/pyinstaller?tab=readme-ov-file#requirements-and-tested-platforms, it seems like ldd and the binutils stuff is only required on linux. Maybe we could just throw in a lib.optionals stdenv.isLinux here?

https://github.com/NixOS/nixpkgs/blob/99dc8785f6a0adac95f5e2ab05cc2e1bf666d172/pkgs/development/python-modules/pyinstaller/default.nix#L40-L42

Do you know if more needed to be done to fix the darwin build? Feel free to open a PR if you'd like.

You need macolib which I am looking to make a package for and I think clang I still have to test if you need clang. I am looking to make a pr in a couple of days to fix both pyinstaller and package macholib

Eveeifyeve commented 1 month ago

I think gcc can be replace with clang which is compatible with both linux and darwin.

Eveeifyeve commented 1 month ago

@h7x4 Macholib is now in a pr: https://github.com/NixOS/nixpkgs/pull/344926

Eveeifyeve commented 1 month ago

@h7x4 Macholib is now in a pr: #344926

Now I am looking to fix pyinstaller for darwin.