Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6e4d0c4a8aee
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d4f2f4c79d45
Choose a head ref
  • 4 commits
  • 5 files changed
  • 2 contributors

Commits on Oct 13, 2018

  1. Copy the full SHA
    e4e160c View commit details
  2. Copy the full SHA
    3b5449b View commit details
  3. Copy the full SHA
    c941577 View commit details
  4. Merge pull request #44441 from mnacamura/shell-aliases

    environment.shellAliases: change default behavior
    infinisil authored Oct 13, 2018
    Copy the full SHA
    d4f2f4c View commit details
12 changes: 9 additions & 3 deletions nixos/modules/config/shells-environment.nix
Original file line number Diff line number Diff line change
@@ -108,14 +108,14 @@ in
};

environment.shellAliases = mkOption {
default = {};
example = { ll = "ls -l"; };
example = { l = null; ll = "ls -l"; };
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.
Aliases mapped to <code>null</code> are ignored.
'';
type = types.attrs; # types.attrsOf types.stringOrPath;
type = with types; attrsOf (nullOr (either str path));
};

environment.binsh = mkOption {
@@ -157,6 +157,12 @@ in
# terminal instead of logging out of X11).
environment.variables = config.environment.sessionVariables;

environment.shellAliases = mapAttrs (name: mkDefault) {
ls = "ls --color=tty";
ll = "ls -l";
l = "ls -alh";
};

environment.etc."shells".text =
''
${concatStringsSep "\n" (map utils.toShellPath cfg.shells)}
13 changes: 8 additions & 5 deletions nixos/modules/programs/bash/bash.nix
Original file line number Diff line number Diff line change
@@ -33,7 +33,8 @@ let
'';

bashAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
(filterAttrs (k: v: !isNull v) cfg.shellAliases)
);

in
@@ -59,12 +60,12 @@ in
*/

shellAliases = mkOption {
default = config.environment.shellAliases;
default = {};
description = ''
Set of aliases for bash shell. See <option>environment.shellAliases</option>
for an option format description.
Set of aliases for bash shell, which overrides <option>environment.shellAliases</option>.
See <option>environment.shellAliases</option> for an option format description.
'';
type = types.attrs; # types.attrsOf types.stringOrPath;
type = with types; attrsOf (nullOr (either str path));
};

shellInit = mkOption {
@@ -125,6 +126,8 @@ in

programs.bash = {

shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;

shellInit = ''
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
. ${config.system.build.setEnvironment}
13 changes: 8 additions & 5 deletions nixos/modules/programs/fish.nix
Original file line number Diff line number Diff line change
@@ -9,7 +9,8 @@ let
cfg = config.programs.fish;

fishAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") cfg.shellAliases
mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
(filterAttrs (k: v: !isNull v) cfg.shellAliases)
);

in
@@ -53,12 +54,12 @@ in
};

shellAliases = mkOption {
default = config.environment.shellAliases;
default = {};
description = ''
Set of aliases for fish shell. See <option>environment.shellAliases</option>
for an option format description.
Set of aliases for fish shell, which overrides <option>environment.shellAliases</option>.
See <option>environment.shellAliases</option> for an option format description.
'';
type = types.attrs;
type = with types; attrsOf (nullOr (either str path));
};

shellInit = mkOption {
@@ -99,6 +100,8 @@ in

config = mkIf cfg.enable {

programs.fish.shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;

environment.etc."fish/foreign-env/shellInit".text = cfge.shellInit;
environment.etc."fish/foreign-env/loginShellInit".text = cfge.loginShellInit;
environment.etc."fish/foreign-env/interactiveShellInit".text = cfge.interactiveShellInit;
6 changes: 0 additions & 6 deletions nixos/modules/programs/shell.nix
Original file line number Diff line number Diff line change
@@ -8,12 +8,6 @@ with lib;

config = {

environment.shellAliases =
{ ls = "ls --color=tty";
ll = "ls -l";
l = "ls -alh";
};

environment.shellInit =
''
# Set up the per-user profile.
12 changes: 7 additions & 5 deletions nixos/modules/programs/zsh/zsh.nix
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ let
cfg = config.programs.zsh;

zshAliases = concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}") cfg.shellAliases
mapAttrsFlatten (k: v: "alias ${k}=${escapeShellArg v}")
(filterAttrs (k: v: !isNull v) cfg.shellAliases)
);

in
@@ -34,13 +35,12 @@ in
};

shellAliases = mkOption {
default = config.environment.shellAliases;
default = {};
description = ''
Set of aliases for zsh shell. Overrides the default value taken from
<option>environment.shellAliases</option>.
Set of aliases for zsh shell, which overrides <option>environment.shellAliases</option>.
See <option>environment.shellAliases</option> for an option format description.
'';
type = types.attrs; # types.attrsOf types.stringOrPath;
type = with types; attrsOf (nullOr (either str path));
};

shellInit = mkOption {
@@ -106,6 +106,8 @@ in

config = mkIf cfg.enable {

programs.zsh.shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;

environment.etc."zshenv".text =
''
# /etc/zshenv: DO NOT EDIT -- this file has been generated automatically.