Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How buildEnv builtin function works?

Tags:

nix

How buildEnv works? Why its builtin? How can I use it? What does manifest argument? Where is the documentation about buildEnv?

like image 372
srghma Avatar asked Mar 31 '18 17:03

srghma


People also ask

What is Buildenv?

A tool for generating environment exports from a YAML file.

Where is Nixpkgs located?

Nix stores all packages into a common place called the Nix store, usually located at /nix/store . Each package is stored in a unique subdirectory in the store, and each package has its own tree structure. For example, a SimGrid package might be stored in /nix/store/l5rah62vpsr3ap63xmk197y0s1l6g2zx-simgrid-3.22.

What is Nixpkg?

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.


1 Answers

Are looking the actual buildenv.nix or the buildEnv function?

Because buildenv.nix is an internal mechanism of the Nix package manager not of much interest for non developer of Nix itself.

If you're interested in the buildEnv function is part of NixPkgs package collection, this function is implemented here: https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/buildenv/default.nix

Even if the code give some hints, I didn't found any real documentation, but you can find some examples in the manual: https://nixos.org/nixpkgs/manual/#sec-building-environment

If I understand correctly, the manifest is also internal to Nix: It is a Nix file that contains a list of derivation that correspond to a given environment. You can have a look at one on a machine with nix in /nix/var/nix/profiles/per-user/root/channels/manifest.nix for example.

It is not very readable, it looks like this:

[ { meta = { }; name = "nixos-18.09pre143771.a8c71037e04"; out = { outPath = "/nix/store/yqxc408mhbcksnaqndkpdkg8ylcj2xhg-nixos-18.09pre143771.a8c71037e04"; }; outPath = "/nix/store/yqxc408mhbcksnaqndkpdkg8ylcj2xhg-nixos-18.09pre143771.a8c71037e04"; outputs = [ "out" ]; system = "x86_64-linux"; type = "derivation"; } { meta = { }; name = "nixos-1803-18.03.132768.94d80eb7247"; out = { outPath = "/nix/store/ih8bhvgmp47rs3acchkc9ch7f8760rpz-nixos-1803-18.03.132768.94d80eb7247"; }; outPath = "/nix/store/ih8bhvgmp47rs3acchkc9ch7f8760rpz-nixos-1803-18.03.132768.94d80eb7247"; outputs = [ "out" ]; system = "x86_64-linux"; type = "derivation"; } ]

like image 172
mickours Avatar answered Sep 28 '22 10:09

mickours