1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 13:41:26 +00:00

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/info.nix
./programs/shadow.nix
./programs/shell.nix
./programs/ssh.nix
./programs/ssmtp.nix
./programs/wvdial.nix

View file

@ -25,6 +25,9 @@ let
fi
'';
shellAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}='${v}'") config.environment.shellAliases
);
options = {
@ -63,11 +66,11 @@ in
{ # /etc/bashrc: executed every time a bash starts. Sources
# /etc/profile to ensure that the system environment is
# configured properly.
source = pkgs.substituteAll {
src = ./bashrc.sh;
inherit initBashCompletion;
};
target = "bashrc";
source = pkgs.substituteAll {
src = ./bashrc.sh;
inherit initBashCompletion shellAliases;
};
target = "bashrc";
}
{ # 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.activationScripts.binsh = stringAfter [ "stdio" ]

View file

@ -29,8 +29,4 @@ fi
@initBashCompletion@
# Some aliases.
alias ls="ls --color=tty"
alias ll="ls -l"
alias l="ls -alh"
alias which="type -P"
@shellAliases@

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