mirror of
https://github.com/thegeneralist01/config.git
synced 2026-05-30 08:37:01 +02:00
95 lines
2.2 KiB
Nix
95 lines
2.2 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib)
|
|
attrsToList
|
|
catAttrs
|
|
const
|
|
flatten
|
|
getAttr
|
|
mapAttrsToList
|
|
mkOption
|
|
sortOn
|
|
toInt
|
|
unique
|
|
;
|
|
|
|
mkConst =
|
|
value:
|
|
mkOption {
|
|
default = value;
|
|
readOnly = true;
|
|
};
|
|
|
|
mkValue =
|
|
default:
|
|
mkOption {
|
|
inherit default;
|
|
};
|
|
in
|
|
{
|
|
environment.shells =
|
|
config.home-manager.users
|
|
|> mapAttrsToList (const <| getAttr "shellsByPriority")
|
|
|> flatten
|
|
|> unique;
|
|
|
|
home-manager.sharedModules = [
|
|
|
|
(
|
|
homeArgs:
|
|
let
|
|
config' = homeArgs.config;
|
|
in
|
|
{
|
|
options.shells = mkValue { };
|
|
|
|
options.shellsByPriority = mkConst (
|
|
config'.shells |> attrsToList |> sortOn ({ name, ... }: toInt name) |> catAttrs "value"
|
|
);
|
|
|
|
options.variablesMap = mkConst {
|
|
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;
|
|
};
|
|
}
|
|
)
|
|
|
|
(
|
|
homeArgs:
|
|
let
|
|
config' = homeArgs.config;
|
|
nuExecCondition =
|
|
if config.isDarwin then
|
|
''
|
|
[[ $- == *i* ]] && [ -z "$skip" ] && [ -t 1 ]
|
|
''
|
|
else
|
|
''[ -z "$INTELLIJ_ENVIRONMENT_READER" ] && [ -z "$skip" ] && [ -z "$SSH_TTY" ]'';
|
|
in
|
|
{
|
|
home.file.".zshrc".text = # zsh
|
|
''
|
|
export PATH="$HOME/.local/bin:/run/wrappers/bin:/run/current-system/sw/bin:/nix/var/nix/profiles/default/bin:/etc/profiles/per-user/$USER/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin''${PATH:+:}''${PATH}"
|
|
source ${config'.home.sessionVariablesPackage}/etc/profile.d/hm-session-vars.sh
|
|
|
|
if ${nuExecCondition}; then
|
|
parent_cmd="$(ps -o command= -p "$PPID" 2>/dev/null || true)"
|
|
case "$parent_cmd" in
|
|
*"/Applications/Zed.app/Contents/MacOS/zed --printenv"*) return ;;
|
|
esac
|
|
SHELL='${lib.getExe <| lib.head config'.shellsByPriority}' exec "$SHELL"
|
|
fi
|
|
'';
|
|
}
|
|
)
|
|
];
|
|
}
|