nixpkgs/doc/builders/packages/etc-files.section.md
Farid Zakaria 4687d7523b glibc: add dependency on netbase /etc/protocols
Add an explicit dependency on netbase for /etc/protocols

Certain functions in glibc look for files present in /etc such as getprotobyname which reads /etc/protocols.
If you are using Nix over a Linux installation, this file may not be present, and therefore it will cause errors.

- add netbase as a new package in nixpks
- add a dependency in glibc on it using postPatchPhase and substitute
the path

Fixes #124401
2021-09-19 19:37:56 -07:00

1.3 KiB
Raw Blame History

/etc files

Certain calls in glibc require access to runtime files found in /etc such as /etc/protocols or /etc/services -- getprotobyname is one such function.

On non-NixOS distributions these files are typically provided by packages (i.e. netbase) if not already pre-installed in your distribution. This can cause non-reproducibility for code if they rely on these files being present.

If iana-etc is part of your buildInputs then it will set the environment varaibles NIX_ETC_PROTOCOLS and NIX_ETC_SERVICES to the corresponding files in the package through a setup-hook.

 nix-shell -p iana-etc

[nix-shell:~]$ env | grep NIX_ETC
NIX_ETC_SERVICES=/nix/store/aj866hr8fad8flnggwdhrldm0g799ccz-iana-etc-20210225/etc/services
NIX_ETC_PROTOCOLS=/nix/store/aj866hr8fad8flnggwdhrldm0g799ccz-iana-etc-20210225/etc/protocols

Nixpkg's version of glibc has been patched to check for the existence of these environment variables. If the environment variable are not set, then it will attempt to find the files at the default location within /etc.