From 17d69e51e6bfb9d41a2a12396d8671c5e63f52c4 Mon Sep 17 00:00:00 2001 From: alexion Date: Wed, 2 Sep 2026 08:38:56 -0400 Subject: [PATCH] fix(fish): export Rust toolchain root --- configs/nixos/modules/shell/fish/default.nix | 9 ++++++++- configs/nixos/modules/shell/rust.nix | 4 ++-- configs/nixos/registry/env-var.nix | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 configs/nixos/registry/env-var.nix diff --git a/configs/nixos/modules/shell/fish/default.nix b/configs/nixos/modules/shell/fish/default.nix index c5063b4..4ee0279 100644 --- a/configs/nixos/modules/shell/fish/default.nix +++ b/configs/nixos/modules/shell/fish/default.nix @@ -9,7 +9,11 @@ let cfg = config.modules.shell.fish; user = config.user.name; shortcuts = config.registry.shell-shortcut.${config.networking.hostName}; + envVars = config.registry.env-var.${config.networking.hostName}; commandsOf = shortcuts: lib.mapAttrs (_name: shortcut: shortcut.command) shortcuts; + exportEnvVar = name: value: '' + set -gx ${name} ${lib.escapeShellArg value} + ''; in { options.modules.shell.fish = { @@ -99,7 +103,10 @@ in }; # Rendered by home-manager into ~/.config/fish/config.fish. - interactiveShellInit = builtins.readFile ./config.fish; + interactiveShellInit = lib.concatStringsSep "\n" ( + (lib.mapAttrsToList exportEnvVar envVars) + ++ [ (builtins.readFile ./config.fish) ] + ); }; }; }; diff --git a/configs/nixos/modules/shell/rust.nix b/configs/nixos/modules/shell/rust.nix index 050b508..36c9c8d 100644 --- a/configs/nixos/modules/shell/rust.nix +++ b/configs/nixos/modules/shell/rust.nix @@ -23,13 +23,13 @@ in options.modules.shell.rust.enable = lib.mkEnableOption "Rust tools for the primary user's shell environment"; config = lib.mkIf cfg.enable { + registry.env-var.${config.networking.hostName}.RUST_TOOLCHAIN_ROOT = "${toolchain}"; + home-manager.users.${user} = { home.packages = [ toolchain pkgs.rust-analyzer ]; - - home.sessionVariables.RUST_TOOLCHAIN_ROOT = "${toolchain}"; }; }; } diff --git a/configs/nixos/registry/env-var.nix b/configs/nixos/registry/env-var.nix new file mode 100644 index 0000000..8a6fd91 --- /dev/null +++ b/configs/nixos/registry/env-var.nix @@ -0,0 +1,4 @@ +{ lib, ... }: +{ + type = lib.types.str; +}