Nixpkgs includes packages compiled for musl under the pkgsMusl
prefix. For example, pkgs.pkgsMusl.hello
. IIUC these only exist on a Linux system.
Maybe you can use those packages for everything by setting pkgsMusl
as your package set. For example if you are using Home Manager with a flake config you normally have a line like,
let pkgs = nixpkgs.legacyPackages.${system};
Maybe you could change that to
let pkgs = nixpkgs.legacyPackages.${system}.pkgsMusl;