1 # Provide a /etc/passwd and /etc/group that contain root and nobody.
2 # Useful when packaging binaries that insist on using nss to look up
3 # username/groups (like nginx).
4 # /bin/sh is fine to not exist, and provided by another shim.
5 { lib, symlinkJoin, writeTextDir, runCommand, extraPasswdLines ? [], extraGroupLines ? [] }:
9 (writeTextDir "etc/passwd" ''
10 root:x:0:0:root user:/var/empty:/bin/sh
11 ${lib.concatStrings (map (line: line + "\n") extraPasswdLines)}nobody:x:65534:65534:nobody:/var/empty:/bin/sh
13 (writeTextDir "etc/group" ''
15 ${lib.concatStrings (map (line: line + "\n") extraGroupLines)}nobody:x:65534:
17 (writeTextDir "etc/nsswitch.conf" ''
20 (runCommand "var-empty" { } ''
21 mkdir -p $out/var/empty