feat(guix): conda

This commit is contained in:
Pavel Korytov 2021-06-18 21:36:50 +03:00
parent cd54e345e5
commit eec899a0b0
5 changed files with 73 additions and 64 deletions

18
.bashrc
View file

@ -102,6 +102,7 @@ alias ls="exa --icons"
alias ll="exa -lah --icons"
alias q="exit"
alias c="clear"
alias ic="init_conda"
# Aliases:1 ends here
# [[file:Console.org::*Aliases][Aliases:2]]
@ -111,6 +112,23 @@ if [[ ! -z "$SIMPLE" ]]; then
fi
# Aliases:2 ends here
# [[file:Console.org::*Anaconda][Anaconda:1]]
init_conda () {
__conda_setup="$('/home/pavel/.guix-extra-profiles/dev/dev/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" ]; then
. "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh"
else
# export PATH="/home/pavel/Programs/miniconda3/bin:$PATH"
echo "what"
fi
fi
unset __conda_setup
}
# Anaconda:1 ends here
# [[file:Console.org::*Starship prompt][Starship prompt:1]]
if [[ -z "$SIMPLE" ]]; then
eval "$(starship init bash)"

View file

@ -11,8 +11,15 @@ alias ls="exa --icons"
alias ll="exa -lah --icons"
alias q="exit"
alias c="clear"
alias ic="init_conda"
# Fish:2 ends here
# [[file:../../Console.org::*Fish][Fish:3]]
function init_conda
eval /home/pavel/.guix-extra-profiles/dev/dev/bin/conda "shell.fish" "hook" $argv | source
end
# Fish:3 ends here
# [[file:../../Console.org::*Fish][Fish:4]]
if ! test -n "$TMUX"; and ! test -n "$IS_EMACS";
colorscript random

View file

@ -296,6 +296,7 @@ alias ls="exa --icons"
alias ll="exa -lah --icons"
alias q="exit"
alias c="clear"
alias ic="init_conda"
#+end_src
#+begin_src bash
@ -304,27 +305,27 @@ if [[ ! -z "$SIMPLE" ]]; then
alias ll="ls -lah"
fi
#+end_src
*** OFF (OFF) Anaconda
*** Anaconda
#+begin_quote
managed by 'conda init' !!!
#+end_quote
Yeah, tell this to yourself
#+begin_src bash :tangle no
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/pavel/Programs/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/pavel/Programs/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/pavel/Programs/miniconda3/etc/profile.d/conda.sh"
#+begin_src bash
init_conda () {
__conda_setup="$('/home/pavel/.guix-extra-profiles/dev/dev/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
export PATH="/home/pavel/Programs/miniconda3/bin:$PATH"
if [ -f "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh" ]; then
. "/home/pavel/.guix-extra-profiles/dev/dev/etc/profile.d/conda.sh"
else
# export PATH="/home/pavel/Programs/miniconda3/bin:$PATH"
echo "what"
fi
fi
fi
unset __conda_setup
# <<< conda initialize <<<
unset __conda_setup
}
#+end_src
*** Starship prompt
#+begin_src bash
@ -356,11 +357,10 @@ fish_vi_key_bindings
#+end_src
Anaconda
#+begin_src fish :tangle no
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
eval /home/pavel/Programs/miniconda3/bin/conda "shell.fish" "hook" $argv | source
# <<< conda initialize <<<
#+begin_src fish
function init_conda
eval /home/pavel/.guix-extra-profiles/dev/dev/bin/conda "shell.fish" "hook" $argv | source
end
#+end_src
| Guix dependency |

View file

@ -2032,12 +2032,23 @@ This section generates manifests for various desktop software that I'm using.
| Category | Guix dependency |
|----------+-----------------|
| latex | texlive |
** Dev
| Category | Guix dependency |
|----------+-----------------|
| dev | conda |
** Manifests
#+NAME: packages
#+begin_src emacs-lisp :tangle no :var category=""
(my/format-guix-dependencies category)
#+end_src
Dev
#+begin_src scheme :tangle .config/guix/manifests/dev.scm :noweb yes
(specifications->manifest
'(
<<packages("dev")>>))
#+end_src
Browsers
#+begin_src scheme :tangle .config/guix/manifests/browsers.scm :noweb yes
(specifications->manifest

View file

@ -382,10 +382,10 @@ And activate the required profiles. Again, downloading & building Emacs, Starshi
Don't forget to install =JetBrainsMono Nerd Font=.
* Misc software
| Category | Guix dependency |
|----------+-------------------------|
| system | openvpn |
| system | python |
| Category | Guix dependency |
|----------+-----------------|
| system | openvpn |
| system | python |
* Notes on installing software
| Category | Guix dependency | Description |
|----------+-----------------+----------------------------------------------------|
@ -393,6 +393,20 @@ Don't forget to install =JetBrainsMono Nerd Font=.
| system | glibc | A lot of stuff, including ELF interpeter and ~ldd~ |
** flatpak
As for now, the easiest way to install most of proprietary software is via flatpak. See the relevant section in [[file:Desktop.org][Desktop.org]].
** conda
[[https://docs.conda.io/en/latest/][conda]] is a package manager, which I use for managing various versions of Python & Node.js.
It is packaged for GNU Guix, although the definition has its fair share of workarounds. It is almost surprising to see it work with all the C libraries and stuff. But there are still some problems.
First, it's impossible to perform =conda init= to patch files like =.bashrc=, because the command is hell-bent on modifying =/gnu/store/=. So I do this manually, look for the =init_conda= procedures in [[file:Console.org][Console.org]].
Second, base environment root is =/gnu/store=, so don't install anything there.
Third, by default it tries to create envronments in =/gnu/store=. I think it's enough to create one environment like this to fix it:
#+begin_src sh
mkdir -p ~/.conda/envs
conda create -p ~/.conda/envs/test
#+end_src
** wakatime-cli
| Note | Description |
|------+-----------------------|
@ -402,44 +416,3 @@ Before I figure out how to package this for Guix:
- Clone [[https://github.com/wakatime/wakatime-cli][the repo]]
- Run ~go build~
- Copy the binary to the =~/bin= folder
** ActivityWatch
| Note | Description |
|------+-----------------------|
| TODO | Package this for Guix |
The official binaries work just fine after some patching, except for the =aw-qt= binary.
Properly building from source is more awkward, as there is poetry, which isn't oficially supported by Guix yet.
The patching is as follows:
- Get ELF interpeter patch from ~guix build glibc~, after which patch ELF interpeter path for the required binaries, e.g.:
#+begin_src bash eval :no
patchelf --set-interpreter /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 aw-qt
patchelf --set-interpreter /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 aw-server/aw-server
patchelf --set-interpreter /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 aw-server-rust/aw-server-rust
patchelf --set-interpreter /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 aw-watcher-afk/aw-watcher-afk
patchelf --set-interpreter /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib/ld-linux-x86-64.so.2 aw-watcher-window/aw-watcher-window
#+end_src
Add libz to RPATH
| Category | Guix dependency |
|----------+-----------------|
| system | zlib |
#+begin_src bash eval :no
patchelf --set-rpath /gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib/ aw-qt
patchelf --set-rpath /gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib/ aw-server/aw-server
patchelf --set-rpath /gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib/ aw-server-rust/aw-server-rust
patchelf --set-rpath /gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib/ aw-watcher-afk/aw-watcher-afk
patchelf --set-rpath /gnu/store/rykm237xkmq7rl1p0nwass01p090p88x-zlib-1.2.11/lib/ aw-watcher-window/aw-watcher-window
#+end_src
As aw-qt doesn't work properly, and the only thing it does is makes a tray icon anyhow, here is a script to launch the required components:
#+begin_src bash :tangle ./bin/aw-start
~/bin/activitywatch/aw-server/aw-server &
~/bin/activitywatch/aw-watcher-afk/aw-watcher-afk &
~/bin/activitywatch/aw-watcher-window/aw-watcher-window &
#+end_src