libbase91: init at 0.3.3 #504524
PR title/description indicates init at 0.2.1, but the derivation sets version = "0.2.2". Please align the package version with the intended release (either update the PR metadata or change this version/tag).
This derivation hardcodes ELF-specific output (libbase91.so) and uses clang -shared, but meta.platforms = lib.platforms.unix includes Darwin where shared libraries are .dylib and -shared is not the right flag. Either restrict platforms to ELF targets (e.g., linux) or make the build/install name and linker flags conditional on stdenv.hostPlatform (Darwin/ELF/BSD).
libname=${if stdenv.hostPlatform.isDarwin then "libbase91.dylib" else "libbase91.so"}
clang -O2 -fPIC ${if stdenv.hostPlatform.isDarwin then "-dynamiclib" else "-shared"} -o "$libname" base91.c
clang -O2 -c base91.c -o base91.o
llvm-ar crs libbase91.a base91.o
'';
installPhase = ''
libname=${if stdenv.hostPlatform.isDarwin then "libbase91.dylib" else "libbase91.so"}
mkdir -p $out/lib $out/include
cp "$libname" libbase91.a $out/lib/
The build phase bypasses the toolchain provided by stdenv by calling clang/llvm-ar directly. This makes cross-compilation and toolchain overrides harder. Prefer using $CC and $AR (and any relevant NIX_ flags) and drop the explicit llvmPackages. inputs unless there is a specific need for clang/llvm-ar.
The PR description says man pages (basE91.3, basE91_encode.3, etc.) should be produced/installed, but the installPhase only installs the library and header. If the upstream release includes these manpages, please install them into $out/share/man/man3 (and add a man output if this repo uses split outputs). Otherwise, the PR description/test plan should be updated to match what the derivation actually installs.
Pull request overview
Adds a new Nix package definition for the libbase91 C library, intended to build/install shared + static libraries, headers, and (per PR description) manpage documentation.
Changes:
pkgs/by-name/li/libbase91/package.nix to fetch douzebis/base91 and build libbase91.so / libbase91.a.base91.h into $out/include and libraries into $out/lib.---
💡 <a href="/NixOS/nixpkgs/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Fixed: the derivation is already at version = "0.2.2". PR title and description updated to match.
Fixed: buildPhase and installPhase now use stdenv.hostPlatform.isDarwin to select -dynamiclib/.dylib on Darwin and -shared/.so on Linux.
Fixed: dropped llvmPackages.clang and llvmPackages.bintools from inputs; buildPhase now uses $CC and $AR from stdenv.
The upstream repo does not include man pages for the C library. PR description updated to remove the man page claim.
On Darwin, the produced libbase91.dylib is linked without setting an install_name (LC_ID_DYLIB). This commonly leads to consumers recording a non-store install name (often just libbase91.dylib), which can break runtime loading/linking in Nix environments. Please pass an explicit install name when building the dylib (e.g., via -Wl,-install_name,$out/lib/${sharedLib} or an @rpath-based install name consistent with the repo’s conventions).
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
---
💡 <a href="/NixOS/nixpkgs/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Fixed: added -Wl,-install_name,$out/lib/libbase91.dylib on Darwin and -Wl,-soname,libbase91.so on Linux.
Custom buildPhase does not call runHook preBuild/postBuild. Omitting these hooks can break stdenv features and user overrides (e.g., hardening or wrapper hooks) that rely on them. Please add the standard hooks around the manual compile commands (and similarly for install).
Custom installPhase does not call runHook preInstall/postInstall. Adding these hooks improves compatibility with stdenv and package overrides that extend install behavior. (Optional but recommended.)
''
runHook preInstall
mkdir -p $out/lib $out/include
cp ${sharedLib} libbase91.a $out/lib/
cp base91.h $out/include/
runHook postInstall
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
---
💡 <a href="/NixOS/nixpkgs/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Fixed: added runHook preBuild/runHook postBuild around the compile commands.
Fixed: added runHook preInstall/runHook postInstall around the install commands.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
---
💡 <a href="/NixOS/nixpkgs/new/master?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
Hi @douzebis apologies for late reply. I was on a trip. May I ask why you are requesting my review? I don't have write privileges to the nixpkgs project or have reviewed any packages within nixpkgs.
Hi @seanybaggins, I used the Reviewers "wheel" and clicked on a random name for a review. Apologies, I should probably have known better.
Most of this code is not needed: the stdenv generic builder does most of the work by calling make and make install. One thing that is missing is that make install does not install the header file. Ordinarily this would require a patch or a postInstall = ''cp ... ...'' type thing, but here, since you are also upstream, I can simply ask: can you make make install install the header file too? :)
__structuredAttrs = true;
strictDeps = true;
sourceRoot = "${finalAttrs.src.name}/src";
installFlags = [ "prefix=${placeholder "out"}" ];
Hi @mdaniels5757 , thank you very much for your review.
At very long last I reworked and hopefully fixed the PR.
Please would you like to give it another look.
douzebis
Follows the update of
base91to 0.3.3 (#583594): this package takesbase91's source and vendored crates.Add
libbase91, the C library of base91-rs (the Rust library behind thebase91command). base91 encodes binary data as printable ASCII with atmost 23% overhead (base64: 33%). The library offers two APIs, in
base91.h:struct basE91,basE91_init,basE91_encode,basE91_encode_end,basE91_decode,basE91_decode_end), binarycompatible with Joachim Henke's basE91 0.6.0: a program built against
his library runs unchanged with this one.
base91_encode,base91_decode,…), Henke's and a fixed-width SIMD variant that SSE4.1, AVX2 and NEON
encode and decode at several GiB/s; no allocation, sizes checked before
anything is written, errors as return codes with their offset.
Homepage: https://github.com/douzebis/base91
Changelog: https://github.com/douzebis/base91/blob/v0.3.3/CHANGELOG.md
Packaging:
rustPlatform.buildRustPackage; the library is therust/base91-capicrate (
cdylibandstaticlib) of the workspace inrust/(
cargoRoot,buildAndTestSubdir); its Rust tests run in the checkphase.
inherit (base91) version src cargoDeps: no second fetch or vendorhash; one
nix-update base91moves both packages.out(lib/libbase91.so.0, SONAMElibbase91.so.0, with thelibbase91.solink;lib/libbase91.a) anddev(include/base91.h,lib/pkgconfig/base91.pc, withLibs.privatefor the static library);meta.pkgConfigModules;fixDarwinDylibNameson Darwin.passthru.tests:pkg-config(testers.hasPkgConfigModules);c-api,a C program calling every function through
pkg-config, linkeddynamically and statically;
henke-compat, Henke's own basE91 0.6.0command-line tool built against this library, which must write exactly
what
base91writes, small buffers included (they overlap its input andoutput).
meta.license: MIT, and BSD-3-Clause for the header, which declaresHenke's API.
This PR previously proposed 0.2.2, built from Henke's C code with a
hand-written
buildPhase(mdaniels5757 suggested the generic builderwith
make install). The library is now built from the Rust code withcargo, so that suggestion no longer applies: the recipe has no build or
install phase of its own.
Things done
- [x] x86_64-linux
- [ ] aarch64-linux
- [ ] aarch64-darwin
- [ ] [NixOS tests] in [nixos/tests].
- [x] [Package tests] at
passthru.tests.- [ ] Tests in [lib/tests] or [pkgs/test] for functions and "core" functionality.
nixpkgs-reviewon this PR. See [nixpkgs-review usage].- (A new package with no dependents: built it and its
passthru.testsdirectly.)
./result/bin/.- (No binaries; the
passthru.testsexercise the library from C.)- [ ] Package update: when the change is major or breaking.
- [ ] Module addition: when adding a new NixOS module.
- [ ] Module update: when the change is significant.
AI disclosure
This package was prepared with Claude Code (Claude Opus 5.5): the
packaging, the commit message and this description were drafted with it
and reviewed by me, the maintainer, who is responsible for them. The
commit carries an
Assisted-by:trailer.[NixOS tests]: https://nixos.org/manual/nixos/unstable/index.html#sec-nixos-tests
[Package tests]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#package-tests
[nixpkgs-review usage]: https://github.com/Mic92/nixpkgs-review#usage
[CONTRIBUTING.md]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md
[automation/AI policy]: https://github.com/NixOS/nixpkgs/blob/master/CONTRIBUTING.md#automationai-policy
[lib/tests]: https://github.com/NixOS/nixpkgs/blob/master/lib/tests
[maintainers/README.md]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md
[nixos/tests]: https://github.com/NixOS/nixpkgs/blob/master/nixos/tests
[pkgs/README.md]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md
[pkgs/test]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/test
🤖 Generated with Claude Code