mirror of
https://github.com/nix-community/nix-on-droid.git
synced 2025-11-08 11:36:07 +01:00
session-init: only add to NIX_PATH if value is not present yet
This commit is contained in:
parent
dcd8c07cd8
commit
bb8470da1d
1 changed files with 9 additions and 4 deletions
|
|
@ -11,6 +11,12 @@ let
|
|||
|
||||
exportAll = vars: concatStringsSep "\n" (mapAttrsToList export vars);
|
||||
|
||||
addToNixPath = nixPathEntry: ''
|
||||
if [[ ":$NIX_PATH:" != *":${nixPathEntry}:"* ]]; then
|
||||
export NIX_PATH="${nixPathEntry}''${NIX_PATH:+:}$NIX_PATH"
|
||||
fi
|
||||
'';
|
||||
|
||||
sessionInit = pkgs.writeTextFile {
|
||||
name = "nix-on-droid-session-init.sh";
|
||||
destination = "/etc/profile.d/nix-on-droid-session-init.sh";
|
||||
|
|
@ -22,7 +28,9 @@ let
|
|||
. $HOME/.nix-profile/etc/profile.d/nix.sh
|
||||
|
||||
# workaround for nix 2.4, see https://github.com/NixOS/nixpkgs/issues/149791
|
||||
export NIX_PATH=$HOME/.nix-defexpr/channels''${NIX_PATH:+:}$NIX_PATH
|
||||
${addToNixPath "${config.user.home}/.nix-defexpr/channels"}
|
||||
# Workaround for https://github.com/NixOS/nix/issues/1865
|
||||
${addToNixPath "nixpkgs=${config.user.home}/.nix-defexpr/channels/nixpkgs/"}
|
||||
|
||||
${optionalString (config.home-manager.config != null) ''
|
||||
if [ -e "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh" ]; then
|
||||
|
|
@ -30,9 +38,6 @@ let
|
|||
fi
|
||||
''}
|
||||
|
||||
# Workaround for https://github.com/NixOS/nix/issues/1865
|
||||
export NIX_PATH=nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs/:$NIX_PATH
|
||||
|
||||
${exportAll cfg.sessionVariables}
|
||||
'';
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue