Easy program alias pattern


I am looking for an easy way of aliasing certain programs, say in a shell.nix I have a hook to launch an emacs server, and want emacs to actually mean emacsclient -s ${toString ./.}/emacs -c. Currently I have

{ pkgs ? ... } # pinned pkgs
with pkgs;
stdenv.mkDerivation {
  name = "foo";

  buildInputs = [
    (writeShellScriptBin "emacs" ''
      emacsclient -s ${toString ./.}/emacs -c
    (emacsWithPackages (p: with p; [

as the resulting PATH seems to be based on the order of the buildInputs, so this works – but I didn’t find any documentation that this is always the case, so it is a hack depending on implementation details.

I guess I could have the emacsWithPackages part of the input for the shell script, which would avoid clashes but mean that the other things emacs installs are not in my PATH.

As a different example, I want the global vi to alias to nvim just so that when I log in on servers with a basic vi only, I don’t have to constantly do the cycle of nvim ..., nvim not found, ^nvim^vi.

1 Like