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

+3 -3
+3 -3
pkgs/build-support/fake-nss/default.nix
··· 2 2 # Useful when packaging binaries that insist on using nss to look up 3 3 # username/groups (like nginx). 4 4 # /bin/sh is fine to not exist, and provided by another shim. 5 - { symlinkJoin, writeTextDir, runCommand }: 5 + { lib, symlinkJoin, writeTextDir, runCommand, extraPasswdLines ? [], extraGroupLines ? [] }: 6 6 symlinkJoin { 7 7 name = "fake-nss"; 8 8 paths = [ 9 9 (writeTextDir "etc/passwd" '' 10 10 root:x:0:0:root user:/var/empty:/bin/sh 11 - nobody:x:65534:65534:nobody:/var/empty:/bin/sh 11 + ${lib.concatStrings (map (line: line + "\n") extraPasswdLines)}nobody:x:65534:65534:nobody:/var/empty:/bin/sh 12 12 '') 13 13 (writeTextDir "etc/group" '' 14 14 root:x:0: 15 - nobody:x:65534: 15 + ${lib.concatStrings (map (line: line + "\n") extraGroupLines)}nobody:x:65534: 16 16 '') 17 17 (writeTextDir "etc/nsswitch.conf" '' 18 18 hosts: files dns