1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-28 18:47:44 +00:00

nushell: fix global profile importing

This commit is contained in:
RGBCube 2025-07-19 19:48:54 +03:00
parent b5351ab1f9
commit cdf2edfa69
Signed by: RGBCube
SSH key fingerprint: SHA256:CzqbPcfwt+GxFYNnFVCqoN5Itn4YFrshg1TrnACpA5M

View file

@ -1,5 +1,5 @@
{ config, lib, pkgs, ... }: let { config, lib, pkgs, ... }: let
inherit (lib) attrValues const enabled getExe mapAttrs mkIf optionalAttrs readFile removeAttrs replaceString; inherit (lib) attrNames attrValues concatStringsSep const enabled flatten getExe listToAttrs mapAttrs mapAttrsToList mkIf optionalAttrs readFile removeAttrs replaceStrings;
in { in {
environment = optionalAttrs config.isLinux { environment = optionalAttrs config.isLinux {
sessionVariables.SHELLS = getExe pkgs.nushell; sessionVariables.SHELLS = getExe pkgs.nushell;
@ -60,9 +60,29 @@ in {
''; '';
environmentVariables = let environmentVariables = let
variablesMap = {
HOME = config'.home.homeDirectory;
USER = config'.home.username;
XDG_CACHE_HOME = config'.xdg.cacheHome;
XDG_CONFIG_HOME = config'.xdg.configHome;
XDG_DATA_HOME = config'.xdg.dataHome;
XDG_STATE_HOME = config'.xdg.stateHome;
}
|> mapAttrsToList (name: value: [
{ name = "\$${name}"; inherit value; }
{ name = "\${${name}}"; inherit value; }
])
|> flatten
|> listToAttrs;
environmentVariables = config.environment.variables; environmentVariables = config.environment.variables;
homeVariables = config'.home.sessionVariables; homeVariables = config'.home.sessionVariables;
homeSearchVariables = config'.home.sessionSearchVariables
|> mapAttrs (const <| concatStringsSep ":");
# homeVariablesExtra = pkgs.runCommand "home-variables-extra.env" {} '' # homeVariablesExtra = pkgs.runCommand "home-variables-extra.env" {} ''
# alias export=echo # alias export=echo
# # echo foo > $out # # echo foo > $out
@ -77,8 +97,11 @@ in {
# |> map (keyAndValue: nameValuePair (first keyAndValue) (last keyAndValue)) # |> map (keyAndValue: nameValuePair (first keyAndValue) (last keyAndValue))
# |> foldl' (x: y: x // y) {}; # |> foldl' (x: y: x // y) {};
homeVariablesExtra = {}; homeVariablesExtra = {};
in environmentVariables // homeVariables // homeVariablesExtra in environmentVariables
|> mapAttrs (const <| replaceString "$HOME" config'.home.homeDirectory); // homeVariables
// homeSearchVariables
// homeVariablesExtra
|> mapAttrs (const <| replaceStrings (attrNames variablesMap) (attrValues variablesMap));
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // { shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
cdtmp = "cd (mktemp --directory)"; cdtmp = "cd (mktemp --directory)";