diff options
author | Chuck Lantz <clantz@microsoft.com> | 2022-11-01 20:02:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 20:02:02 +0300 |
commit | 0752a52b0c8ac76448666822938dce8f4d55bb69 (patch) | |
tree | 39abf9124899027643a68e5d33afc78f92ecedd9 /src/nix/nix-entrypoint.sh | |
parent | 748be9320c99cbf6e6a2885d3b5dcc39e7ad3b78 (diff) |
Nix feature (#228)
Diffstat (limited to 'src/nix/nix-entrypoint.sh')
-rwxr-xr-x | src/nix/nix-entrypoint.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/nix/nix-entrypoint.sh b/src/nix/nix-entrypoint.sh new file mode 100755 index 0000000..cac3e63 --- /dev/null +++ b/src/nix/nix-entrypoint.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# Attempt to start daemon +set +e +if ! pidof nix-daemon > /dev/null 2>&1; then + start_ok=false + if [ "$(id -u)" = "0" ]; then + ( . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh; /nix/var/nix/profiles/default/bin/nix-daemon > /tmp/nix-daemon.log 2>&1 ) & + if [ "$?" = "0" ]; then + start_ok=true + fi + elif type sudo > /dev/null 2>&1; then + sudo -n sh -c '. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh; /nix/var/nix/profiles/default/bin/nix-daemon > /tmp/nix-daemon.log 2>&1' & + if [ "$?" = "0" ]; then + start_ok=true + fi + fi + if [ "${start_ok}" = "false" ]; then + echo -e 'Failed to start nix-daemon as root. Set multiUser to false in your feature configuraiton if you would\nprefer to run the container as a non-root. You may also start the daemon manually if you have sudo\ninstalled and configured for your user by running "sudo -c nix-daemon &"' + fi +fi +exec "$@" |