mirror of
https://github.com/thegeneralist01/config.git
synced 2026-03-07 10:59:55 +01:00
config: command-line revamp
This commit is contained in:
parent
802a38f61b
commit
3f34891413
28 changed files with 1141 additions and 335 deletions
86
modules/common/shell/default.nix
Normal file
86
modules/common/shell/default.nix
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
attrsToList
|
||||
catAttrs
|
||||
const
|
||||
flatten
|
||||
getAttr
|
||||
mapAttrsToList
|
||||
mkIf
|
||||
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;
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
(mkIf config.isDarwin (
|
||||
homeArgs:
|
||||
let
|
||||
config' = homeArgs.config;
|
||||
in
|
||||
{
|
||||
home.file.".zshrc".text = # zsh
|
||||
''
|
||||
export PATH="/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 [ -z "$INTELLIJ_ENVIRONMENT_READER" ]; then
|
||||
SHELL='${lib.getExe <| lib.head config'.shellsByPriority}' exec "$SHELL"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
))
|
||||
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue