@@ -1,4 +1,5 @@
11{
2+ bashInteractive,
23 buildPackages,
34 cacert,
45 callPackage,
@@ -29,6 +30,7 @@
2930 writeReferencesToFile,
3031 writeScript,
3132 writeText,
33+ writeTextDir,
3234 writePython3,
3335 system, # Note: This is the cross system we're compiling for
3436}:
@@ -70,7 +72,7 @@ in
7072rec {
7173
7274 examples = callPackage ./examples.nix {
73− inherit buildImage pullImage shadowSetup buildImageWithNixDb;
75+ inherit buildImage buildLayeredImage fakeNss pullImage shadowSetup buildImageWithNixDb;
7476 };
7577
7678 pullImage = let
@@ -684,6 +686,33 @@ rec {
684686 in
685687 result;
686688
689+ # Provide a /etc/passwd and /etc/group that contain root and nobody.
690+ # Useful when packaging binaries that insist on using nss to look up
691+ # username/groups (like nginx).
692+ # /bin/sh is fine to not exist, and provided by another shim.
693+ fakeNss = symlinkJoin {
694+ name = "fake-nss";
695+ paths = [
696+ (writeTextDir "etc/passwd" ''
697+ root:x:0:0:root user:/var/empty:/bin/sh
698+ nobody:x:65534:65534:nobody:/var/empty:/bin/sh
699+ '')
700+ (writeTextDir "etc/group" ''
701+ root:x:0:
702+ nobody:x:65534:
703+ '')
704+ (runCommand "var-empty" {} ''
705+ mkdir -p $out/var/empty
706+ '')
707+ ];
708+ };
709+
710+ # This provides /bin/sh, pointing to bashInteractive.
711+ binSh = runCommand "bin-sh" {} ''
712+ mkdir -p $out/bin
713+ ln -s ${bashInteractive}/bin/bash $out/bin/sh
714+ '';
715+
687716 # Build an image and populate its nix database with the provided
688717 # contents. The main purpose is to be able to use nix commands in
689718 # the container.