login: source session init in shell configs

If a shell is not started via login-inner (e.g. via ssh) it will not
source the sessionInit script. The solution is to source this file in
the respective config files for bash and zsh (more shell support can be
easily added).

The -u option is not necessary for the few lines in login-inner and
should not be activated after sourcing sessionInit in bash or zsh setup.
This commit is contained in:
Tobias Happ 2021-12-14 20:07:46 +01:00
parent b4b228eb27
commit b201d656b9
3 changed files with 34 additions and 1 deletions

View file

@ -9,7 +9,7 @@ in
writeText "login-inner" ''
# This file is generated by nix-on-droid. DO NOT EDIT.
set -eu -o pipefail
set -eo pipefail
if [ "$#" -eq 0 ]; then # if script is called from within nix-on-droid app
echo "Welcome to Nix-on-Droid!"

View file

@ -0,0 +1,32 @@
# Copyright (c) 2019-2021, see AUTHORS. Licensed under MIT License, see LICENSE.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
};
###### implementation
config = {
environment.etc = {
"profile".text = ''
. "${config.build.sessionInit}/etc/profile.d/nix-on-droid-session-init.sh"
'';
"zshenv".text = ''
. "${config.build.sessionInit}/etc/profile.d/nix-on-droid-session-init.sh"
'';
};
};
}

View file

@ -13,6 +13,7 @@
./environment/nix.nix
./environment/path.nix
./environment/session-init.nix
./environment/shell.nix
./home-manager.nix
./nixpkgs/options.nix
./time.nix