mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
Check if the selected shell is a directory
This commit is contained in:
parent
248cc08061
commit
21629b43fd
1 changed files with 13 additions and 2 deletions
|
|
@ -6,6 +6,12 @@ let
|
||||||
inherit (initialPackageInfo) cacert nix;
|
inherit (initialPackageInfo) cacert nix;
|
||||||
|
|
||||||
nixCmd = "${nix}/bin/nix --extra-experimental-features 'flakes nix-command'";
|
nixCmd = "${nix}/bin/nix --extra-experimental-features 'flakes nix-command'";
|
||||||
|
userShell =
|
||||||
|
if config.user.shell.type or "not-found" == "derivation" then
|
||||||
|
if config.user.shell ? passthru.shellPath then
|
||||||
|
"${config.user.shell}${config.user.shell.passthru.shellPath}"
|
||||||
|
else builtins.abort "Derivation without shell path found at `user.shell`. Use the path to the exact binary."
|
||||||
|
else config.user.shell;
|
||||||
in
|
in
|
||||||
|
|
||||||
writeText "login-inner" ''
|
writeText "login-inner" ''
|
||||||
|
|
@ -141,13 +147,18 @@ writeText "login-inner" ''
|
||||||
exec /usr/bin/env bash # otherwise it'll be a limited bash that came with Nix
|
exec /usr/bin/env bash # otherwise it'll be a limited bash that came with Nix
|
||||||
''}
|
''}
|
||||||
|
|
||||||
usershell="${config.user.shell}"
|
usershell="${userShell}"
|
||||||
if [ "$#" -gt 0 ]; then # if script is not called from within Nix-on-Droid app
|
if [ "$#" -gt 0 ]; then # if script is not called from within Nix-on-Droid app
|
||||||
exec /usr/bin/env "$@"
|
exec /usr/bin/env "$@"
|
||||||
|
elif [ -d "$usershell" ]; then
|
||||||
|
echo "Cannot execute shell '${userShell}', it is a directory."
|
||||||
|
echo "You should point 'user.shell' to the exact binary."
|
||||||
|
echo "Falling back to bash."
|
||||||
|
exec -l bash
|
||||||
elif [ -x "$usershell" ]; then
|
elif [ -x "$usershell" ]; then
|
||||||
exec -a "-''${usershell##*/}" "$usershell"
|
exec -a "-''${usershell##*/}" "$usershell"
|
||||||
else
|
else
|
||||||
echo "Cannot execute shell '${config.user.shell}', falling back to bash"
|
echo "Cannot execute shell '${userShell}', falling back to bash"
|
||||||
exec -l bash
|
exec -l bash
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue