From 8c731978f0916b9a904d67a0e53744ceff47882c Mon Sep 17 00:00:00 2001 From: Yt Date: Wed, 2 Aug 2023 01:27:30 +0800 Subject: [PATCH] nushell: deprecation of let-env (#4292) --- modules/programs/direnv.nix | 8 ++++---- modules/programs/nushell.nix | 5 ++--- tests/modules/programs/nushell/env-expected.nu | 4 ++-- tests/modules/programs/nushell/example-settings.nix | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix index 89ba2bf9..23636644 100644 --- a/modules/programs/direnv.nix +++ b/modules/programs/direnv.nix @@ -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 { {} } diff --git a/modules/programs/nushell.nix b/modules/programs/nushell.nix index 58b549a5..51419971 100644 --- a/modules/programs/nushell.nix +++ b/modules/programs/nushell.nix @@ -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) diff --git a/tests/modules/programs/nushell/env-expected.nu b/tests/modules/programs/nushell/env-expected.nu index 3d818c42..07105fc5 100644 --- a/tests/modules/programs/nushell/env-expected.nu +++ b/tests/modules/programs/nushell/env-expected.nu @@ -1,4 +1,4 @@ -let-env FOO = 'BAR' +$env.FOO = 'BAR' -let-env BAR = $'(echo BAZ)' \ No newline at end of file +$env.BAR = $'(echo BAZ)' \ No newline at end of file diff --git a/tests/modules/programs/nushell/example-settings.nix b/tests/modules/programs/nushell/example-settings.nix index 7259db6d..73038584 100644 --- a/tests/modules/programs/nushell/example-settings.nix +++ b/tests/modules/programs/nushell/example-settings.nix @@ -13,7 +13,7 @@ ''; envFile.text = '' - let-env FOO = 'BAR' + $env.FOO = 'BAR' ''; loginFile.text = ''