简体   繁体   English

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

[英]How do I override the libc in a Nix package to be musl?

I'm using Nix as a dependency manager for a Rust program. 我正在使用Nix作为Rust程序的依赖管理器。 I have the following default.nix (simplified, but working): 我有以下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
    '';
  };
}

I'm trying to override the libc for all dependencies (including the Rust compiler) to be pkg.musl, but I fail to do so. 我试图覆盖所有依赖项(包括Rust编译器)的libc为pkg.musl,但我没有这样做。 How can this be achieved? 怎么能实现这一目标?

Try the pkgsMusl convenience attribute (source) 试试pkgsMusl便利属性(来源)

rec {
  pkgs = (import <nixpkgs> {}).pkgsMusl;
  # ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM