From 7f81e61d477828bc45adf151cb59982b34402da1 Mon Sep 17 00:00:00 2001 From: MERCIER Michael Date: Wed, 7 Nov 2018 09:29:47 +0100 Subject: [PATCH 1/2] Make the base image compatible with common network services My use case here to make cachix (https://cachix.org/) works out of the box. I've done small changes to make complexe network services works: - Add in /etc the iana files services + protocoles - Add in /etc the the ssl directory from cacert - Set the USER variable to ROOT - Make bash available at standard locations (/bin,/usr/bin) --- default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 2eebd0b..12bf3d8 100644 --- a/default.nix +++ b/default.nix @@ -2,7 +2,7 @@ let inherit (pkgs) dockerTools stdenv buildEnv writeText; - inherit (pkgs) bashInteractive coreutils cacert nix openssh shadow; + inherit (pkgs) bashInteractive coreutils cacert nix openssh shadow iana-etc; inherit (native.lib) concatStringsSep genList; @@ -36,7 +36,7 @@ let phases = [ "installPhase" "fixupPhase" ]; exportReferencesGraph = - map (drv: [("closure-" + baseNameOf drv) drv]) [ path cacert unstable ]; + map (drv: [("closure-" + baseNameOf drv) drv]) [ path cacert iana-etc unstable ]; installPhase = '' mkdir -p $out/run/current-system $out/var @@ -46,11 +46,16 @@ let mkdir -p $out/bin $out/usr/bin $out/sbin ln -s ${stdenv.shell} $out/bin/sh ln -s ${coreutils}/bin/env $out/usr/bin/env + ln -s ${bashInteractive} $out/bin/bash + ln -s ${bashInteractive} $out/usr/bin/bash mkdir -p $out/etc echo '${passwd}' > $out/etc/passwd echo '${group}' > $out/etc/group echo '${nsswitch}' > $out/etc/nsswitch.conf + ln -s ${iana-etc}/etc/protocols $out/etc/ + ln -s ${iana-etc}/etc/services $out/etc/ + ln -s ${cacert}/etc/ssl $out/etc/ printRegistration=1 ${pkgs.perl}/bin/perl ${pkgs.pathsFromGraph} closure-* > $out/.reginfo ''; @@ -69,6 +74,7 @@ let "NIX_PATH=nixpkgs=${unstable}" "GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt" "SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt" + "USER=root" ]; }; From b04efaf71562adca3f4a2ff4d85ef8ad05216a23 Mon Sep 17 00:00:00 2001 From: MERCIER Michael Date: Wed, 7 Nov 2018 11:20:19 +0100 Subject: [PATCH 2/2] fix bash links --- default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default.nix b/default.nix index 12bf3d8..d0370b8 100644 --- a/default.nix +++ b/default.nix @@ -46,8 +46,8 @@ let mkdir -p $out/bin $out/usr/bin $out/sbin ln -s ${stdenv.shell} $out/bin/sh ln -s ${coreutils}/bin/env $out/usr/bin/env - ln -s ${bashInteractive} $out/bin/bash - ln -s ${bashInteractive} $out/usr/bin/bash + ln -s ${bashInteractive}/bin/bash $out/bin/bash + ln -s ${bashInteractive}/bin/bash $out/usr/bin/bash mkdir -p $out/etc echo '${passwd}' > $out/etc/passwd