nushell: deprecation of let-env (#4292)

This commit is contained in:
Yt 2023-08-02 01:27:30 +08:00 committed by GitHub
parent 4542db6056
commit 8c731978f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 10 deletions

View file

@ -128,10 +128,10 @@ in {
# Using mkAfter to make it more likely to appear after other
# manipulations of the prompt.
mkAfter ''
let-env config = ($env | default {} config).config
let-env config = ($env.config | default {} hooks)
let-env config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
let-env config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append {
$env.config = ($env | default {} config).config
$env.config = ($env.config | default {} hooks)
$env.config = ($env.config | update hooks ($env.config.hooks | default [] pre_prompt))
$env.config = ($env.config | update hooks.pre_prompt ($env.config.hooks.pre_prompt | append {
code: "
let direnv = (${pkgs.direnv}/bin/direnv export json | from json)
let direnv = if ($direnv | length) == 1 { $direnv } else { {} }

View file

@ -85,7 +85,7 @@ in {
type = types.nullOr (linesOrSource "env.nu");
default = null;
example = ''
let-env FOO = 'BAR'
$env.FOO = 'BAR'
'';
description = ''
The environment variables file to be used for nushell.
@ -174,8 +174,7 @@ in {
(let
envVarsStr = concatStringsSep "\n"
(mapAttrsToList (k: v: "let-env ${k} = ${v}")
cfg.environmentVariables);
(mapAttrsToList (k: v: "$env.${k} = ${v}") cfg.environmentVariables);
in mkIf (cfg.envFile != null || cfg.extraEnv != "" || envVarsStr != "") {
"${configDir}/env.nu".text = mkMerge [
(mkIf (cfg.envFile != null) cfg.envFile.text)

View file

@ -1,4 +1,4 @@
let-env FOO = 'BAR'
$env.FOO = 'BAR'
let-env BAR = $'(echo BAZ)'
$env.BAR = $'(echo BAZ)'

View file

@ -13,7 +13,7 @@
'';
envFile.text = ''
let-env FOO = 'BAR'
$env.FOO = 'BAR'
'';
loginFile.text = ''