feat(*): conda -> micromamba

This commit is contained in:
Pavel Korytov 2023-06-18 15:12:25 +03:00
parent f588e1a9fa
commit 609fc84e43
11 changed files with 93 additions and 86 deletions

31
.bashrc
View file

@ -112,9 +112,9 @@ alias ls="exa --icons"
alias ll="exa -lah --icons" alias ll="exa -lah --icons"
alias q="exit" alias q="exit"
alias c="clear" alias c="clear"
alias ci="init_conda" alias ci="init_mamba"
alias ca="conda activate" alias ca="micromamba activate"
alias cii="export INIT_CONDA=true && init_conda" alias cii="export INIT_MAMBA=true && init_mamba"
# Aliases:1 ends here # Aliases:1 ends here
# [[file:Console.org::*Aliases][Aliases:2]] # [[file:Console.org::*Aliases][Aliases:2]]
@ -124,26 +124,27 @@ if [[ ! -z "$SIMPLE" ]]; then
fi fi
# Aliases:2 ends here # Aliases:2 ends here
# [[file:Console.org::*Anaconda][Anaconda:1]] # [[file:Console.org::*Micromamba][Micromamba:1]]
init_conda () { init_mamba () {
__conda_setup="$('/home/pavel/.guix-extra-profiles/dev/dev/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" export MAMBA_EXE="/gnu/store/w0rrglxs2247nr4wawrh5dylisjra1q4-micromamba-bin-1.4.4-0/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/pavel/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
eval "$__conda_setup" eval "$__mamba_setup"
else else
if [ -f "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" ]; then if [ -f "/home/pavel/micromamba/etc/profile.d/micromamba.sh" ]; then
. "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" . "/home/pavel/micromamba/etc/profile.d/micromamba.sh"
else else
# export PATH="/home/pavel/Programs/miniconda3/bin:$PATH" export PATH="/home/pavel/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
echo "what"
fi fi
fi fi
unset __conda_setup unset __mamba_setup
} }
if [[ ! -z "$INIT_CONDA" ]]; then if [[ ! -z "$INIT_MAMBA" ]]; then
init_conda init_mamba
fi fi
# Anaconda:1 ends here # Micromamba:1 ends here
# [[file:Console.org::*Starship][Starship:1]] # [[file:Console.org::*Starship][Starship:1]]
if [[ -z "$SIMPLE" && "$TERM" != "dumb" ]]; then if [[ -z "$SIMPLE" && "$TERM" != "dumb" ]]; then

View file

@ -34,13 +34,12 @@ colors:
Cyan: '#a3f7ff' Cyan: '#a3f7ff'
White: '#ffffff' White: '#ffffff'
background_opacity: 0.80
window: window:
padding: padding:
x: 0 x: 0
y: 0 y: 0
dynamic_padding: true dynamic_padding: true
opacity: 0.80
key_bindings: key_bindings:
- { key: Paste, action: Paste } - { key: Paste, action: Paste }

View file

@ -13,10 +13,9 @@ alias ls="exa --icons"
alias ll="exa -lah --icons" alias ll="exa -lah --icons"
alias q="exit" alias q="exit"
alias c="clear" alias c="clear"
alias ci="init_conda" alias ci="init_mamba"
alias ca="conda activate" alias ca="micromamba activate"
alias cii="export INIT_CONDA=true && init_conda" alias cii="export INIT_MAMBA=true && init_mamba"
alias cad="conda activate (basename (pwd))"
# Fish:2 ends here # Fish:2 ends here
# [[file:../../Console.org::*Fish][Fish:3]] # [[file:../../Console.org::*Fish][Fish:3]]
@ -29,21 +28,23 @@ end
set fish_greeting set fish_greeting
# Fish:4 ends here # Fish:4 ends here
# [[file:../../Console.org::*Anaconda][Anaconda:1]] # [[file:../../Console.org::*Micromamba][Micromamba:1]]
function init_conda function init_mamba
eval /home/pavel/.guix-extra-profiles/dev/dev/bin/conda "shell.fish" "hook" $argv | source set -gx MAMBA_EXE "/gnu/store/w0rrglxs2247nr4wawrh5dylisjra1q4-micromamba-bin-1.4.4-0/bin/micromamba"
set -gx MAMBA_ROOT_PREFIX "/home/pavel/micromamba"
$MAMBA_EXE shell hook --shell fish --prefix $MAMBA_ROOT_PREFIX | source
end end
if test -n "$INIT_CONDA"; if test -n "$INIT_MAMBA";
init_conda init_mamba
end end
# Anaconda:1 ends here # Micromamba:1 ends here
# [[file:../../Console.org::*Anaconda][Anaconda:2]] # [[file:../../Console.org::*Micromamba][Micromamba:2]]
if test -n "$EMACS_CONDA_ENV"; # if test -n "$EMACS_CONDA_ENV";
conda activate $EMACS_CONDA_ENV # conda activate $EMACS_CONDA_ENV
end # end
# Anaconda:2 ends here # Micromamba:2 ends here
# [[file:../../Console.org::*Colors][Colors:1]] # [[file:../../Console.org::*Colors][Colors:1]]
set fish_color_command cyan set fish_color_command cyan

View file

@ -2,7 +2,7 @@
(cons* (cons*
(channel (channel
(name 'channel-q) (name 'channel-q)
(url "file:///home/pavel/Code/channel-q")) (url "file:///home/pavel/_channel-q"))
(channel (channel
(name 'flat) (name 'flat)
(url "https://github.com/flatwhatson/guix-channel.git") (url "https://github.com/flatwhatson/guix-channel.git")

View file

@ -1,7 +1,8 @@
(specifications->manifest (specifications->manifest
'( '(
"ncdu"
"megacmd" "megacmd"
"jless" "jless-bin"
"direnv" "direnv"
"glibc-locales" "glibc-locales"
"git-lfs" "git-lfs"

View file

@ -21,4 +21,4 @@
"postgresql" "postgresql"
"docker-compose" "docker-compose"
"pandoc" "pandoc"
"conda")) "micromamba-bin"))

View file

@ -82,24 +82,11 @@
(lambda (data) (lambda (data)
(message "%f Gb" (/ (float data) 1024 1024))))) (message "%f Gb" (/ (float data) 1024 1024)))))
(use-package conda (use-package micromamba
:straight t :straight (:local-repo "~/10-19 Code/12 My Emacs Packages/12.12 micromamba.el")
:if (executable-find "conda") :if (executable-find "micromamba")
:config :config
(setq conda-anaconda-home (string-replace "/bin/conda" "" (executable-find "conda"))) (micromamba-activate "general"))
(setq conda-env-home-directory (expand-file-name "~/.conda/"))
(setq conda-env-subdirectory "envs")
(advice-add 'conda-env-activate :after
(lambda (&rest _)
(setenv "EMACS_CONDA_ENV" conda-env-current-name)
(setenv "INIT_CONDA" "true")))
(advice-add 'conda-env-deactivate :after
(lambda (&rest _)
(setenv "EMACS_CONDA_ENV" nil)
(setenv "INIT_CONDA" nil)))
(unless (getenv "CONDA_DEFAULT_ENV")
(conda-env-activate "general")))
(setq custom-file (concat user-emacs-directory "custom.el")) (setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror) (load custom-file 'noerror)
@ -6019,7 +6006,7 @@ base toot."
(defun my/ement-room-send-reaction (key position) (defun my/ement-room-send-reaction (key position)
(interactive (list (interactive (list
(completing-read "Add reaction: " telega-emoji-reaction-list) (completing-read "Add reaction: " (append telega-emoji-reaction-list '("👋")))
(point))) (point)))
(ement-room-send-reaction key position)) (ement-room-send-reaction key position))

View file

@ -374,9 +374,9 @@ alias ls="exa --icons"
alias ll="exa -lah --icons" alias ll="exa -lah --icons"
alias q="exit" alias q="exit"
alias c="clear" alias c="clear"
alias ci="init_conda" alias ci="init_mamba"
alias ca="conda activate" alias ca="micromamba activate"
alias cii="export INIT_CONDA=true && init_conda" alias cii="export INIT_MAMBA=true && init_mamba"
#+end_src #+end_src
#+begin_src bash #+begin_src bash
@ -385,32 +385,36 @@ if [[ ! -z "$SIMPLE" ]]; then
alias ll="ls -lah" alias ll="ls -lah"
fi fi
#+end_src #+end_src
*** Anaconda *** Micromamba
I've moved from conda to [[https://github.com/mamba-org/mamba][micromamba]] because it's faster.
#+begin_quote #+begin_quote
managed by 'conda init' !!! managed by 'mamba init' !!!
#+end_quote #+end_quote
Yeah, tell this to yourself Yeah, tell this to yourself
#+begin_src bash #+begin_src bash
init_conda () { init_mamba () {
__conda_setup="$('/home/pavel/.guix-extra-profiles/dev/dev/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" export MAMBA_EXE="/gnu/store/w0rrglxs2247nr4wawrh5dylisjra1q4-micromamba-bin-1.4.4-0/bin/micromamba";
export MAMBA_ROOT_PREFIX="/home/pavel/micromamba";
__mamba_setup="$("$MAMBA_EXE" shell hook --shell bash --prefix "$MAMBA_ROOT_PREFIX" 2> /dev/null)"
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
eval "$__conda_setup" eval "$__mamba_setup"
else else
if [ -f "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" ]; then if [ -f "/home/pavel/micromamba/etc/profile.d/micromamba.sh" ]; then
. "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" . "/home/pavel/micromamba/etc/profile.d/micromamba.sh"
else else
# export PATH="/home/pavel/Programs/miniconda3/bin:$PATH" export PATH="/home/pavel/micromamba/bin:$PATH" # extra space after export prevents interference from conda init
echo "what"
fi fi
fi fi
unset __conda_setup unset __mamba_setup
} }
if [[ ! -z "$INIT_CONDA" ]]; then if [[ ! -z "$INIT_MAMBA" ]]; then
init_conda init_mamba
fi fi
#+end_src #+end_src
*** Starship *** Starship
#+begin_src bash #+begin_src bash
if [[ -z "$SIMPLE" && "$TERM" != "dumb" ]]; then if [[ -z "$SIMPLE" && "$TERM" != "dumb" ]]; then
@ -450,7 +454,6 @@ Enable vi keybindings & aliases. The alias syntax is the same as in bash, so it'
fish_vi_key_bindings fish_vi_key_bindings
<<shell-aliases>> <<shell-aliases>>
alias cad="conda activate (basename (pwd))"
#+end_src #+end_src
@ -469,23 +472,25 @@ Suppress fish greeting
#+begin_src fish #+begin_src fish
set fish_greeting set fish_greeting
#+end_src #+end_src
** Anaconda ** Micromamba
First, a function to initialize anaconda. First, a function to initialize micromamba.
#+begin_src fish #+begin_src fish
function init_conda function init_mamba
eval /home/pavel/.guix-extra-profiles/dev/dev/bin/conda "shell.fish" "hook" $argv | source set -gx MAMBA_EXE "/gnu/store/w0rrglxs2247nr4wawrh5dylisjra1q4-micromamba-bin-1.4.4-0/bin/micromamba"
set -gx MAMBA_ROOT_PREFIX "/home/pavel/micromamba"
$MAMBA_EXE shell hook --shell fish --prefix $MAMBA_ROOT_PREFIX | source
end end
if test -n "$INIT_CONDA"; if test -n "$INIT_MAMBA";
init_conda init_mamba
end end
#+end_src #+end_src
Then, check if launched from Emacs with environment activated. Then, check if launched from Emacs with environment activated.
#+begin_src fish #+begin_src fish
if test -n "$EMACS_CONDA_ENV"; # if test -n "$EMACS_CONDA_ENV";
conda activate $EMACS_CONDA_ENV # conda activate $EMACS_CONDA_ENV
end # end
#+end_src #+end_src
** Colors ** Colors
Fish seems to have hardcoded colorcodes in some color settings. I set these to base16 colors, so they would match Xresources. Fish seems to have hardcoded colorcodes in some color settings. I set these to base16 colors, so they would match Xresources.
@ -776,13 +781,12 @@ colors:
Cyan: '<<get-xrdb(color="color14")>>' Cyan: '<<get-xrdb(color="color14")>>'
White: '<<get-xrdb(color="color15")>>' White: '<<get-xrdb(color="color15")>>'
background_opacity: 0.80
window: window:
padding: padding:
x: 0 x: 0
y: 0 y: 0
dynamic_padding: true dynamic_padding: true
opacity: 0.80
key_bindings: key_bindings:
- { key: Paste, action: Paste } - { key: Paste, action: Paste }
@ -831,8 +835,9 @@ key_bindings:
| git-lfs | | | git-lfs | |
| glibc-locales | | | glibc-locales | |
| direnv | | | direnv | |
| jless | JSON viewer | | jless-bin | JSON viewer |
| megacmd | mega.nz client | | megacmd | mega.nz client |
| ncdu | disk usage analyzer |
** ripgrep config ** ripgrep config
Occasionally I can't exclude certain files from ripgrep via the VCS settings, so here is a simple config to ignore certain files globally. Occasionally I can't exclude certain files from ripgrep via the VCS settings, so here is a simple config to ignore certain files globally.

View file

@ -3355,7 +3355,7 @@ This section generates manifests for various desktop software that I'm using.
** Dev ** Dev
| Category | Guix dependency | Disabled | | Category | Guix dependency | Disabled |
|----------+-------------------+----------| |----------+-------------------+----------|
| dev | conda | | | dev | micromamba-bin | |
| dev | pandoc | | | dev | pandoc | |
| dev | docker-compose | | | dev | docker-compose | |
| dev | postgresql | | | dev | postgresql | |

View file

@ -217,7 +217,7 @@ I have some concerns that =ps -o rss= may be unrepresentative because of [[https
(lambda (data) (lambda (data)
(message "%f Gb" (/ (float data) 1024 1024))))) (message "%f Gb" (/ (float data) 1024 1024)))))
#+end_src #+end_src
** Anaconda ** OFF Anaconda
[[https://www.anaconda.com/][Anaconda]] is a free package and environment manager. I currently use it to manage multiple versions of Python and Node.js. Take a look at [[file:Guix.org::*conda][the corresponding entry]] in the Guix config for details about using it on Guix. [[https://www.anaconda.com/][Anaconda]] is a free package and environment manager. I currently use it to manage multiple versions of Python and Node.js. Take a look at [[file:Guix.org::*conda][the corresponding entry]] in the Guix config for details about using it on Guix.
The following code uses the =conda= package to activate the base environment on startup if Emacs is launched outside the environment. The following code uses the =conda= package to activate the base environment on startup if Emacs is launched outside the environment.
@ -228,12 +228,13 @@ References:
- [[https://docs.anaconda.com/][Anaconda docs]] - [[https://docs.anaconda.com/][Anaconda docs]]
- [[https://github.com/necaris/conda.el][conda.el repo]] - [[https://github.com/necaris/conda.el][conda.el repo]]
#+begin_src emacs-lisp #+begin_src emacs-lisp :tangle no
(use-package conda (use-package conda
:straight t :straight t
:if (executable-find "conda") :if (executable-find "conda")
:config :config
(setq conda-anaconda-home (string-replace "/bin/conda" "" (executable-find "conda"))) (setq conda-anaconda-home (string-replace "/bin/conda" "" (executable-find "conda")))
(setq conda--executable-path (executable-find "micromamba"))
(setq conda-env-home-directory (expand-file-name "~/.conda/")) (setq conda-env-home-directory (expand-file-name "~/.conda/"))
(setq conda-env-subdirectory "envs") (setq conda-env-subdirectory "envs")
@ -248,6 +249,18 @@ References:
(unless (getenv "CONDA_DEFAULT_ENV") (unless (getenv "CONDA_DEFAULT_ENV")
(conda-env-activate "general"))) (conda-env-activate "general")))
#+end_src #+end_src
** Micromamba
[[https://github.com/mamba-org/mamba][mamba]] is a faster alternative to [[https://www.anaconda.com/][Anaconda]], a package and environment manager. =micromamba= is a tiny version that provides a subset of mamba commands.
=micromamba.el= is my package to interact with the latter.
#+begin_src emacs-lisp
(use-package micromamba
:straight (:local-repo "~/10-19 Code/12 My Emacs Packages/12.12 micromamba.el")
:if (executable-find "micromamba")
:config
(micromamba-activate "general"))
#+end_src
** Config files ** Config files
*** Custom file location *** Custom file location
By default, =custom= writes stuff to =init.el=, which is somewhat annoying. The following makes it write to a separate file =custom.el= By default, =custom= writes stuff to =init.el=, which is somewhat annoying. The following makes it write to a separate file =custom.el=
@ -1225,7 +1238,7 @@ Setting up quick access to various completions.
"" '(:which-key "various completions")' "" '(:which-key "various completions")'
;; "b" 'counsel-switch-buffer ;; "b" 'counsel-switch-buffer
"b" 'persp-ivy-switch-buffer "b" 'persp-ivy-switch-buffer
"e" 'conda-env-activate "e" 'micromamba-activate
"f" 'project-find-file "f" 'project-find-file
"c" 'counsel-yank-pop "c" 'counsel-yank-pop
"a" 'counsel-rg "a" 'counsel-rg

View file

@ -127,7 +127,7 @@ References:
(cons* (cons*
(channel (channel
(name 'channel-q) (name 'channel-q)
(url "file:///home/pavel/Code/channel-q")) (url "file:///home/pavel/_channel-q"))
(channel (channel
(name 'flat) (name 'flat)
(url "https://github.com/flatwhatson/guix-channel.git") (url "https://github.com/flatwhatson/guix-channel.git")