Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

programs.thefuck: support shells that don't use /etc/profile #27578

Merged
merged 1 commit into from Jul 30, 2017
Merged

programs.thefuck: support shells that don't use /etc/profile #27578

merged 1 commit into from Jul 30, 2017

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Jul 23, 2017

Motivation for this change

The alias for thefuck is placed in /etc/profile. However shell emulators like zsh or fish don't use these scripts due to known incompatibilities with bash.

Therefore an optional expression which detects which shells are enable in NixOS is needed which configures the alias in all needed shell envs.

I confirmed the change using an expression like this:

{
  zsh = { pkgs, lib, ... }: with lib; {
    programs.zsh.enable = true;
    programs.thefuck.enable = true;
    users.extraUsers.vm = {
      extraGroups = [ "wheel" ];
      password = "vm";
      isNormalUser = true;
      shell = "/run/current-system/sw/bin/zsh";
    };
  };
}

When booting into this generated VM (built with nixos-build-vms) zsh works fine when running fuck on the CLI without complaining about missing aliases.

After that I confirmed that the alias is only in the env scripts for bash and zsh (/etc/static/zshenv) by running grep -R 'fuck' /etc.

Things done

Please check what applies. Note that these are not hard requirements but mereley serve as information for reviewers.

  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@Ma27
Copy link
Member Author

Ma27 commented Jul 23, 2017

the XCode build says line 34: local: -n: invalid option.
This seems to be a stdenv-related issue not related to this change (I've seen this in some others of my repos that use a nix image in travis-ci builds)

environment.shellInit = initScript;

programs.zsh.shellInit = mkIf prg.zsh.enable initScript;
programs.fish.shellInit = mkIf prg.fish.enable initScript;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this with fish?
The syntax looks differently here: https://github.com/nvbn/thefuck/wiki/Shell-aliases#fish

@Ma27
Copy link
Member Author

Ma27 commented Jul 23, 2017

argh, good catch, thanks!

@Ma27
Copy link
Member Author

Ma27 commented Jul 23, 2017

@Mic92 anythign else? :)

@Ma27
Copy link
Member Author

Ma27 commented Jul 27, 2017

@Mic92 I rebased onto the latest master, however the XCode build is still failing as Nix 1.11.13 can't be downloaded (the other builds are still green :-))

@Ma27
Copy link
Member Author

Ma27 commented Jul 30, 2017

seems as rebasing onto the latest master has fixed the build, is there anything else TBD? :)

@Mic92 Mic92 merged commit 12e8bea into NixOS:master Jul 30, 2017
@Mic92
Copy link
Member

Mic92 commented Jul 30, 2017

I tested both zsh and fish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants