-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
When the Nix src is patched with appendPatches, a patch count is added to the version string in the form of x.y.z+n where n is the number of patches. It is introduced here:
Lines 109 to 115 in e6f0dd8
| src = finalScope.patchedSrc; | |
| version = | |
| let | |
| n = lib.length finalScope.patches; | |
| in | |
| if n == 0 then prevAttrs.version else prevAttrs.version + "+${toString n}"; | |
However, this doesn't work on macos: build would fail with the linker error:
ld: malformed 32-bit x.y.z version number: 2.32.1+1
I think this is a well-known restriction with the macos linker.
Steps To Reproduce
An example:
nixVersions.latest.appendPatches [
(fetchpatch2 {
name = "fix-zsh-completions.patch";
url = "https://github.com/bryango/nix/commit/956fffdd6f196fc5b61057e19d43a8b275369649.patch";
hash = "sha256-u8OqATgFJO5zrDQx/v7hRRyk+W5QBWOH5QF1fV6/xTg=";
})
])This will fail to build on macos with the above error. A hackaround for this is:
(nixVersions.latest.appendPatches [
(fetchpatch2 {
name = "fix-zsh-completions.patch";
url = "https://github.com/bryango/nix/commit/956fffdd6f196fc5b61057e19d43a8b275369649.patch";
hash = "sha256-u8OqATgFJO5zrDQx/v7hRRyk+W5QBWOH5QF1fV6/xTg=";
})
]).overrideAllMesonComponents (_finalScope: _prevScope@ { version, ... }: {
version = lib.head (lib.splitString "+" version);
});Expected behavior
.appendPatches should just work on macos without hacking the version number.
Metadata
$ nix-env --version
evaluating file '«nix-internal»/derivation-internal.nix'
nix-env (Nix) 2.32.1
System type: aarch64-darwin
Additional system types: x86_64-darwin
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /Users/bryan/.config/nix/nix.conf:/Users/bryan/.nix-profile/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/a6kvb67js25771dmvwpckdr4xxr0y5b9-nix-store-2.32.1/share
Additional context
cc @roberth for comments. The easiest way to fix this is to simply add an isDarwin check when modifying the version string, but I'm unsure if this would be desirable.
A similar phenomenon is observed in #13995 (comment) but the cause is different.
Checklist
- checked latest Nix manual (source)
- checked open bug issues and pull requests for possible duplicates
Add 👍 to issues you find important.