1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 19:49:45 +01:00

home: shell agnostic aliases (#2347)

This commit is contained in:
oberblastmeister 2021-11-06 12:10:15 -04:00 committed by GitHub
parent 70c5b268e1
commit f6f013f764
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,6 +233,26 @@ in
''; '';
}; };
home.shellAliases = mkOption {
type = with types; attrsOf str;
default = { };
example = literalExample ''
{
g = "git";
"..." = "cd ../..";
}
'';
description = ''
An attribute set that maps aliases (the top level attribute names
in this option) to command strings or directly to build outputs.
</para><para>
This option should only be used to manage simple aliases that are
compatible across all shells. If you need to use a shell specific
feature then make sure to use a shell specific option, for example
<xref linkend="opt-programs.bash.shellAliases"/> for Bash.
'';
};
home.sessionVariables = mkOption { home.sessionVariables = mkOption {
default = {}; default = {};
type = types.attrs; type = types.attrs;
@ -483,6 +503,10 @@ in
then "/etc/profiles/per-user/${cfg.username}" then "/etc/profiles/per-user/${cfg.username}"
else cfg.homeDirectory + "/.nix-profile"; else cfg.homeDirectory + "/.nix-profile";
programs.bash.shellAliases = cfg.shellAliases;
programs.zsh.shellAliases = cfg.shellAliases;
programs.fish.shellAliases = cfg.shellAliases;
home.sessionVariables = home.sessionVariables =
let let
maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; }; maybeSet = n: v: optionalAttrs (v != null) { ${n} = v; };