如何将 Nix 包中的 libc 覆盖为 musl?

Jul*_*ina 5 rust musl nix

我使用 Nix 作为 Rust 程序的依赖管理器。我有以下 default.nix (简化,但有效):

rec {
  pkgs = import <nixpkgs> {};

  hello = pkgs.stdenv.mkDerivation rec {
    name = "rust-hello";

    buildInputs = [
      pkgs.rustc
    ];

    src = ./source;

    buildPhase = "rustc main.rs -o rust-hello";
    installPhase = ''
      mkdir -p $out/bin
      install -s rust-hello $out/bin
    '';
  };
}
Run Code Online (Sandbox Code Playgroud)

我试图将所有依赖项(包括 Rust 编译器)的 libc 覆盖为 pkg.musl,但我没有这样做。如何才能实现这一目标?

Rob*_*ing 5

尝试pkgsMusl便利属性(来源)

rec {
  pkgs = (import <nixpkgs> {}).pkgsMusl;
  # ...
}
Run Code Online (Sandbox Code Playgroud)