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

- 2,833
- 2
- 28
- 36

- 4,770
- 2
- 38
- 54
-
One buildEnv is mentioned in the nixpkgs manual chapter "2.7. Declarative Package Management": https://nixos.org/manual/nixpkgs/stable/#sec-declarative-package-management The chapter is hard to understand without an understanding what this buildEnv function does and what its arguments are. – Thomas Koch Mar 09 '23 at 17:47
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"; } ]

- 1,113
- 12
- 13
-
3
-
2The nixpkgs buildEnv is used quite a lot to compose environments together. Often to create really simple proxy environments that wrap an existing package in some sort of configuration. For example by adding an option or flag to an existing package's binary. – CMCDragonkai Jul 03 '18 at 13:11
-
2Shouldn't `buildEnv` be documented in Nixpkgs manual under [Chapter 7. Functions reference](https://nixos.org/nixpkgs/manual/#chap-functions)? It seems that most of the sections there describe packages in `nixpkgs/pkgs/build-support/` (where `buildEnv` resides as well). – toraritte Apr 25 '19 at 22:47