fake-nss: Add support for extra passwd and group lines

This commit is contained in:
Silvan Mosberger 2022-05-13 16:59:22 +02:00
parent 052662fab4
commit 79ae4eb997

View file

@ -2,17 +2,17 @@
# Useful when packaging binaries that insist on using nss to look up
# username/groups (like nginx).
# /bin/sh is fine to not exist, and provided by another shim.
{ symlinkJoin, writeTextDir, runCommand }:
{ lib, symlinkJoin, writeTextDir, runCommand, extraPasswdLines ? [], extraGroupLines ? [] }:
symlinkJoin {
name = "fake-nss";
paths = [
(writeTextDir "etc/passwd" ''
root:x:0:0:root user:/var/empty:/bin/sh
nobody:x:65534:65534:nobody:/var/empty:/bin/sh
${lib.concatStrings (map (line: line + "\n") extraPasswdLines)}nobody:x:65534:65534:nobody:/var/empty:/bin/sh
'')
(writeTextDir "etc/group" ''
root:x:0:
nobody:x:65534:
${lib.concatStrings (map (line: line + "\n") extraGroupLines)}nobody:x:65534:
'')
(writeTextDir "etc/nsswitch.conf" ''
hosts: files dns