mirror of
https://github.com/RGBCube/ncc
synced 2025-07-27 18:17:44 +00:00
nushell: cleanup
This commit is contained in:
parent
b12e780bb1
commit
6f368a10c3
1 changed files with 50 additions and 50 deletions
|
@ -1,5 +1,5 @@
|
|||
{ config, lib, pkgs, ... }: let
|
||||
inherit (lib) attrNames attrValues concatStringsSep const enabled filter flatten foldl' head last listToAttrs mapAttrs mapAttrsToList match nameValuePair readFile removeAttrs replaceStrings splitString;
|
||||
inherit (lib) attrNames attrValues concatStringsSep const enabled filter filterAttrs flatten foldl' head last listToAttrs mapAttrs mapAttrsToList match nameValuePair readFile replaceStrings splitString;
|
||||
|
||||
package = pkgs.nushell;
|
||||
in {
|
||||
|
@ -7,61 +7,61 @@ in {
|
|||
|
||||
home-manager.sharedModules = [(homeArgs: let
|
||||
config' = homeArgs.config;
|
||||
|
||||
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;
|
||||
|
||||
homeVariables = config'.home.sessionVariables;
|
||||
|
||||
homeVariablesExtra = pkgs.runCommand "home-variables-extra.env" {} ''
|
||||
bash -ic '
|
||||
${variablesMap
|
||||
|> mapAttrsToList (name: value: "export ${name}='${value}'")
|
||||
|> concatStringsSep "\n"}
|
||||
|
||||
alias export=echo
|
||||
source ${config'.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh
|
||||
' > $out
|
||||
''
|
||||
|> readFile
|
||||
|> splitString "\n"
|
||||
|> filter (s: s != "")
|
||||
|> map (match "([^=]+)=(.*)")
|
||||
|> map (keyAndValue: nameValuePair (head keyAndValue) (last keyAndValue))
|
||||
|> foldl' (x: y: x // y) {};
|
||||
|
||||
homeSearchVariables = config'.home.sessionSearchVariables
|
||||
|> mapAttrs (const <| concatStringsSep ":");
|
||||
in environmentVariables
|
||||
// homeVariables
|
||||
// homeVariablesExtra
|
||||
// homeSearchVariables
|
||||
|> mapAttrs (const <| replaceStrings (attrNames variablesMap) (attrValues variablesMap))
|
||||
|> filterAttrs (name: const <| name != "TERM");
|
||||
in {
|
||||
programs.nushell = enabled {
|
||||
inherit package;
|
||||
|
||||
configFile.text = readFile ./config.nu;
|
||||
|
||||
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;
|
||||
|
||||
homeVariables = config'.home.sessionVariables;
|
||||
|
||||
homeSearchVariables = config'.home.sessionSearchVariables
|
||||
|> mapAttrs (const <| concatStringsSep ":");
|
||||
|
||||
homeVariablesExtra = pkgs.runCommand "home-variables-extra.env" {} ''
|
||||
bash -ic '
|
||||
${variablesMap
|
||||
|> mapAttrsToList (name: value: "export ${name}='${value}'")
|
||||
|> concatStringsSep "\n"}
|
||||
|
||||
alias export=echo
|
||||
source ${config'.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh
|
||||
' > $out
|
||||
''
|
||||
|> readFile
|
||||
|> splitString "\n"
|
||||
|> filter (s: s != "")
|
||||
|> map (match "([^=]+)=(.*)")
|
||||
|> map (keyAndValue: nameValuePair (head keyAndValue) (last keyAndValue))
|
||||
|> foldl' (x: y: x // y) {};
|
||||
in environmentVariables
|
||||
// homeVariables
|
||||
// homeSearchVariables
|
||||
// homeVariablesExtra
|
||||
|> mapAttrs (const <| replaceStrings (attrNames variablesMap) (attrValues variablesMap));
|
||||
|
||||
shellAliases = removeAttrs config.environment.shellAliases [ "ls" "l" ] // {
|
||||
cdtmp = "cd (mktemp --directory)";
|
||||
};
|
||||
inherit (config.environment) shellAliases;
|
||||
inherit environmentVariables;
|
||||
};
|
||||
})];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue