From 76d05dfa62d4b3b4db3be3a800d18bee858d1c60 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Thu, 24 Mar 2022 18:47:30 +0100 Subject: [PATCH] fakeNss: move to toplevel Make this reachable from pkgs.fakeNss. This is useful outside docker contexts, too. https://github.com/NixOS/nixpkgs/pull/164943#discussion_r833220769 --- pkgs/build-support/docker/default.nix | 21 ++------------------- pkgs/build-support/fake-nss/default.nix | 24 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 3 +++ 3 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 pkgs/build-support/fake-nss/default.nix diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 5718cadd4ffa..96ea363c811e 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -6,6 +6,7 @@ , coreutils , e2fsprogs , fakechroot +, fakeNss , fakeroot , findutils , go @@ -747,25 +748,7 @@ rec { # 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. - fakeNss = 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 - '') - (writeTextDir "etc/group" '' - root:x:0: - nobody:x:65534: - '') - (writeTextDir "etc/nsswitch.conf" '' - hosts: files dns - '') - (runCommand "var-empty" { } '' - mkdir -p $out/var/empty - '') - ]; - }; + inherit fakeNss; # alias # This provides a /usr/bin/env, for shell scripts using the # "#!/usr/bin/env executable" shebang. diff --git a/pkgs/build-support/fake-nss/default.nix b/pkgs/build-support/fake-nss/default.nix new file mode 100644 index 000000000000..9e0b60133e00 --- /dev/null +++ b/pkgs/build-support/fake-nss/default.nix @@ -0,0 +1,24 @@ +# Provide a /etc/passwd and /etc/group that contain root and nobody. +# 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 }: +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 + '') + (writeTextDir "etc/group" '' + root:x:0: + nobody:x:65534: + '') + (writeTextDir "etc/nsswitch.conf" '' + hosts: files dns + '') + (runCommand "var-empty" { } '' + mkdir -p $out/var/empty + '') + ]; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 011cd9b0b527..7b013701d97f 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -436,6 +436,9 @@ with pkgs; dockerTools = callPackage ../build-support/docker { writePython3 = buildPackages.writers.writePython3; }; + + fakeNss = callPackage ../build-support/fake-nss { }; + tarsum = callPackage ../build-support/docker/tarsum.nix { }; snapTools = callPackage ../build-support/snap { };