diff --git a/common/users/homeModules/dev/rust.nix b/common/users/homeModules/dev/rust.nix index c6872ac..0a3af26 100644 --- a/common/users/homeModules/dev/rust.nix +++ b/common/users/homeModules/dev/rust.nix @@ -1,7 +1,22 @@ -{pkgs, ...}: { - home = { - packages = with pkgs; [ - rustup - ]; +{ pkgs, ... }: +{ + home = { + packages = with pkgs; [ + rustup + ]; + }; + programs = { + zsh = { + # Few horror things here + # 1. rustup's completion is broken for zsh. See: https://github.com/rust-lang/rustup/issues/2268 + # 2. patch cant read the source file from stdin, so tmpfiles have to be used + initExtra = '' + TMP_RUSTUP_FILE=$(mktemp) + ${pkgs.rustup}/bin/rustup completions zsh > "$TMP_RUSTUP_FILE" + eval "$(patch -s -o - -i ${./rustupCompPatch.diff} $TMP_RUSTUP_FILE)" + rm $TMP_RUSTUP_FILE + unset TMP_RUSTUP_FILE + ''; }; -} \ No newline at end of file + }; +} diff --git a/common/users/homeModules/dev/rustupCompPatch.diff b/common/users/homeModules/dev/rustupCompPatch.diff new file mode 100644 index 0000000..93b5b87 --- /dev/null +++ b/common/users/homeModules/dev/rustupCompPatch.diff @@ -0,0 +1,17 @@ +26c26,28 +< '::+toolchain -- release channel (e.g. +stable) or custom toolchain to set override:' \ +--- +> '(+beta +nightly)+stable[use the stable toolchain]' \ +> '(+stable +nightly)+beta[use the beta toolchain]' \ +> '(+stable +beta)+nightly[use the nightly toolchain]' \ +32c34 +< words=($line[2] "${words[@]}") +--- +> words=($line[1] "${words[@]}") +34,35c36,37 +< curcontext="${curcontext%:*:*}:rustup-command-$line[2]:" +< case $line[2] in +--- +> curcontext="${curcontext%:*:*}:rustup-command-$line[1]:" +> case $line[1] in +