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

oh-my-zsh: undefine functions that don't work on Nix #92950

Merged
merged 1 commit into from Jul 13, 2020

Conversation

samuelgrf
Copy link
Member

@samuelgrf samuelgrf commented Jul 11, 2020

Both functions expect oh-my-zsh to be in ~/.oh-my-zsh and try to
modify the directory. This doesn't work, since it is in the
Nix store.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • 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 nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@samuelgrf samuelgrf force-pushed the fix/oh-my-zsh-functions branch 2 times, most recently from 001043b to baa4cae Compare July 11, 2020 18:13
chmod -R +w lib

# Remove functions that don't work on Nix
sed -i -e "/uninstall_oh_my_zsh()/,/}/ d" \
Copy link
Member

Choose a reason for hiding this comment

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

This will probably break as soon as this function has a } (in a future version) leaving a broken file in $out. I'd really prefer to apply a patch here.

Copy link
Member Author

Choose a reason for hiding this comment

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

It might be better to add

  unfunction uninstall_oh_my_zsh
  unfunction upgrade_oh_my_zsh

to $template, that way we wouldn't need to update a patch file after changes to the function are made and it is a simpler addition than adding a patch file.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably the best way to go about it, since patching the sources is inherently fragile. You should be able to add those two lines just after cat >> $template <<- EOF.

I didn't know unfunction even existed, that's a cool name 🙂

Both functions expect oh-my-zsh to be in ~/.oh-my-zsh and try to
modify the directory. This doesn't work, since it is in the
Nix store.
@samuelgrf samuelgrf changed the title oh-my-zsh: patch out functions that don't work on Nix oh-my-zsh: undefine functions that don't work on Nix Jul 13, 2020
@samuelgrf
Copy link
Member Author

samuelgrf commented Jul 13, 2020

Instead of appending the commands to $template, this updated commit appends them to oh-my-zsh.sh, because:

  1. This way it would also affect users who didn't copy the template file to their home directory.
  2. Users who have copied it to their home directory previously won't need to update the file.

@samuelgrf samuelgrf requested a review from Ma27 July 13, 2020 08:25
@scolobb
Copy link
Contributor

scolobb commented Jul 13, 2020

@samuelgrf I don't know any more what the various files in Oh My Zsh do, but your approach looks good.

@Ma27 Ma27 merged commit 4c9d74d into NixOS:master Jul 13, 2020
@samuelgrf samuelgrf deleted the fix/oh-my-zsh-functions branch March 5, 2022 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants