I'm using Nix as a dependency manager for a Rust program. I have the following default.nix (simplified, but working):
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. How can this be achieved?
Overview of Nixpkgs. The Nix Packages collection (Nixpkgs) is a set of thousands of packages for the Nix package manager, released under a permissive MIT/X11 license. Packages are available for several platforms, and can be used with the Nix package manager on most GNU/Linux distributions as well as NixOS.
Nix store. Packages built by Nix are placed in the read-only Nix store, normally found in /nix/store . Each package is given a unique address specified by a cryptographic hash followed by the package name and version, for example /nix/store/nawl092prjblbhvv16kxxbk6j9gkgcqm-git-2.14.
Derivations are the building blocks of a Nix system, from a file system view point. The Nix language is used to describe such derivations.
nix . nix-build is essentially a wrapper around nix-instantiate (to translate a high-level Nix expression to a low-level store derivation) and nix-store --realise (to build the store derivation). The result of the build is automatically registered as a root of the Nix garbage collector.
Try the pkgsMusl
convenience attribute (source)
rec {
pkgs = (import <nixpkgs> {}).pkgsMusl;
# ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With