From b201d656b94571a31c862ac329b6c9c603a88adb Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Tue, 14 Dec 2021 20:07:46 +0100 Subject: [PATCH] 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. --- modules/environment/login/login-inner.nix | 2 +- modules/environment/shell.nix | 32 +++++++++++++++++++++++ modules/module-list.nix | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 modules/environment/shell.nix diff --git a/modules/environment/login/login-inner.nix b/modules/environment/login/login-inner.nix index 6e05cfa..2440a73 100644 --- a/modules/environment/login/login-inner.nix +++ b/modules/environment/login/login-inner.nix @@ -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!" diff --git a/modules/environment/shell.nix b/modules/environment/shell.nix new file mode 100644 index 0000000..d79c95c --- /dev/null +++ b/modules/environment/shell.nix @@ -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" + ''; + }; + + }; + +} diff --git a/modules/module-list.nix b/modules/module-list.nix index 768ad0a..bbd4269 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -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