Add option for specifying shell aliases, environment.shellAliases.

This commit is contained in:
Rickard Nilsson 2012-07-25 16:53:46 +02:00
parent 3dda354610
commit a22c362155
4 changed files with 42 additions and 10 deletions

View File

@ -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

View File

@ -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" ]

View File

@ -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"

View 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 = {
};
}