mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 21:33:03 +03:00
Add option for specifying shell aliases, environment.shellAliases.
This commit is contained in:
parent
3dda354610
commit
a22c362155
@ -39,6 +39,7 @@
|
|||||||
./programs/blcr.nix
|
./programs/blcr.nix
|
||||||
./programs/info.nix
|
./programs/info.nix
|
||||||
./programs/shadow.nix
|
./programs/shadow.nix
|
||||||
|
./programs/shell.nix
|
||||||
./programs/ssh.nix
|
./programs/ssh.nix
|
||||||
./programs/ssmtp.nix
|
./programs/ssmtp.nix
|
||||||
./programs/wvdial.nix
|
./programs/wvdial.nix
|
||||||
|
@ -25,6 +25,9 @@ let
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
shellAliases = concatStringsSep "\n" (
|
||||||
|
mapAttrsFlatten (k: v: "alias ${k}='${v}'") config.environment.shellAliases
|
||||||
|
);
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
@ -63,11 +66,11 @@ in
|
|||||||
{ # /etc/bashrc: executed every time a bash starts. Sources
|
{ # /etc/bashrc: executed every time a bash starts. Sources
|
||||||
# /etc/profile to ensure that the system environment is
|
# /etc/profile to ensure that the system environment is
|
||||||
# configured properly.
|
# configured properly.
|
||||||
source = pkgs.substituteAll {
|
source = pkgs.substituteAll {
|
||||||
src = ./bashrc.sh;
|
src = ./bashrc.sh;
|
||||||
inherit initBashCompletion;
|
inherit initBashCompletion shellAliases;
|
||||||
};
|
};
|
||||||
target = "bashrc";
|
target = "bashrc";
|
||||||
}
|
}
|
||||||
|
|
||||||
{ # Configuration for readline in bash.
|
{ # Configuration for readline in bash.
|
||||||
@ -76,6 +79,13 @@ in
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
environment.shellAliases = {
|
||||||
|
ls = "ls --color=tty";
|
||||||
|
ll = "ls -l";
|
||||||
|
l = "ls -alh";
|
||||||
|
which = "type -P";
|
||||||
|
};
|
||||||
|
|
||||||
system.build.binsh = pkgs.bashInteractive;
|
system.build.binsh = pkgs.bashInteractive;
|
||||||
|
|
||||||
system.activationScripts.binsh = stringAfter [ "stdio" ]
|
system.activationScripts.binsh = stringAfter [ "stdio" ]
|
||||||
|
@ -29,8 +29,4 @@ fi
|
|||||||
|
|
||||||
@initBashCompletion@
|
@initBashCompletion@
|
||||||
|
|
||||||
# Some aliases.
|
@shellAliases@
|
||||||
alias ls="ls --color=tty"
|
|
||||||
alias ll="ls -l"
|
|
||||||
alias l="ls -alh"
|
|
||||||
alias which="type -P"
|
|
||||||
|
25
modules/programs/shell.nix
Normal file
25
modules/programs/shell.nix
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# This module defines global configuration for the shells.
|
||||||
|
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
with pkgs.lib;
|
||||||
|
|
||||||
|
{
|
||||||
|
options = {
|
||||||
|
environment.shellAliases = mkOption {
|
||||||
|
type = types.attrs; # types.attrsOf types.stringOrPath;
|
||||||
|
default = {};
|
||||||
|
example = {
|
||||||
|
ll = "ls -lh";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
An attribute set that maps aliases (the top level attribute names in
|
||||||
|
this option) to command strings or directly to build outputs. The
|
||||||
|
aliases are added to all users' shells.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user