Skip to content

Suggestion: allow mostly-static builds targeting Darwin #214611

@Thesola10

Description

@Thesola10

Describe the bug

I understand that purely static binaries are not supported under Darwin, due to the unstable system call ABI. My suggestion is that pkgsStatic, on Darwin or cross-compiling to Darwin, should produce static libraries, which would result in dynamic binaries which only depend on libSystem.dylib. This would be useful for single-file software for embedding, as well as simplifying distribution of Nix-built binaries on systems without Nix.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Build nixpkgs#legacyPackages.x86_64-darwin.pkgsStatic.nix
  2. Run llvm-otool -L result/bin/nix
  3. Resulting derivation is a dynamic executable with dependencies elsewhere in the Nix Store

Expected behavior

Resulting executable would only depend on /usr/lib/libSystem.B.dylib

Notify maintainers

@NixOS/darwin-maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin6.topic: staticStatic builds (e.g. pkgsStatic)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions