mirror of
https://github.com/SqrtMinusOne/dotfiles.git
synced 2025-12-11 19:45:25 +03:00
feat(guix): global npm & conda
This commit is contained in:
parent
c138635f6a
commit
342b9f5d48
4 changed files with 156 additions and 36 deletions
47
.profile
47
.profile
|
|
@ -27,32 +27,43 @@ done
|
||||||
# Guix settings:1 ends here
|
# Guix settings:1 ends here
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:2]]
|
# [[file:Console.org::*Guix settings][Guix settings:2]]
|
||||||
if [ -f /run/current-system/profile/etc/profile.d/nix.sh ]; then
|
export JUPYTER_CONFIG_DIR=$HOME/.config/jupyter
|
||||||
. /run/current-system/profile/etc/profile.d/nix.sh
|
|
||||||
fi
|
|
||||||
# Guix settings:2 ends here
|
# Guix settings:2 ends here
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:3]]
|
# [[file:Console.org::*Guix settings][Guix settings:3]]
|
||||||
|
export GUIX_PACKAGE_PATH=~/guix-packages
|
||||||
|
# Guix settings:3 ends here
|
||||||
|
|
||||||
|
# [[file:Console.org::*Other package managers][Other package managers:1]]
|
||||||
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
|
||||||
|
# Other package managers:1 ends here
|
||||||
|
|
||||||
|
# [[file:Console.org::*Other package managers][Other package managers:2]]
|
||||||
|
if [ -f /run/current-system/profile/etc/profile.d/nix.sh ]; then
|
||||||
|
. /run/current-system/profile/etc/profile.d/nix.sh
|
||||||
|
fi
|
||||||
|
# Other package managers:2 ends here
|
||||||
|
|
||||||
|
# [[file:Console.org::*Other package managers][Other package managers:3]]
|
||||||
if [ -d "$HOME/.guix-extra-profiles/desktop" ]; then
|
if [ -d "$HOME/.guix-extra-profiles/desktop" ]; then
|
||||||
export FONTCONFIG_PATH="$HOME/.guix-extra-profiles/desktop/desktop/etc/fonts"
|
export FONTCONFIG_PATH="$HOME/.guix-extra-profiles/desktop/desktop/etc/fonts"
|
||||||
fi
|
fi
|
||||||
# Guix settings:3 ends here
|
# Other package managers:3 ends here
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:4]]
|
# [[file:Console.org::*Other package managers][Other package managers:4]]
|
||||||
export JUPYTER_CONFIG_DIR=$HOME/.config/jupyter
|
|
||||||
# Guix settings:4 ends here
|
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:5]]
|
|
||||||
export GUIX_PACKAGE_PATH=~/guix-packages
|
|
||||||
# Guix settings:5 ends here
|
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:6]]
|
|
||||||
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
|
|
||||||
# Guix settings:6 ends here
|
|
||||||
|
|
||||||
# [[file:Console.org::*Guix settings][Guix settings:7]]
|
|
||||||
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
|
||||||
# Guix settings:7 ends here
|
# Other package managers:4 ends here
|
||||||
|
|
||||||
|
# [[file:Console.org::*npm][npm:2]]
|
||||||
|
export NPM_CONFIG_USERCONFIG=$HOME/._npmrc
|
||||||
|
# npm:2 ends here
|
||||||
|
|
||||||
|
# [[file:Console.org::*npm][npm:3]]
|
||||||
|
NPM_PACKAGES="${HOME}/.npm-packages"
|
||||||
|
|
||||||
|
export PATH="$PATH:$NPM_PACKAGES/bin"
|
||||||
|
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
|
||||||
|
# npm:3 ends here
|
||||||
|
|
||||||
# [[file:Console.org::*XResources][XResources:1]]
|
# [[file:Console.org::*XResources][XResources:1]]
|
||||||
xrdb ~/.Xresources
|
xrdb ~/.Xresources
|
||||||
|
|
|
||||||
69
Console.org
69
Console.org
|
|
@ -14,7 +14,12 @@
|
||||||
- [[#contents][Contents]]
|
- [[#contents][Contents]]
|
||||||
- [[#profile][.profile]]
|
- [[#profile][.profile]]
|
||||||
- [[#environment][Environment]]
|
- [[#environment][Environment]]
|
||||||
- [[#various-paths][Various paths]]
|
- [[#my-paths][My paths]]
|
||||||
|
- [[#guix-settings][Guix settings]]
|
||||||
|
- [[#other-package-managers][Other package managers]]
|
||||||
|
- [[#npm][npm]]
|
||||||
|
- [[#xresources][XResources]]
|
||||||
|
- [[#off-package-manager-paths][(OFF) Package manager paths]]
|
||||||
- [[#bash][Bash]]
|
- [[#bash][Bash]]
|
||||||
- [[#bash_profile][.bash_profile]]
|
- [[#bash_profile][.bash_profile]]
|
||||||
- [[#bashrc][.bashrc]]
|
- [[#bashrc][.bashrc]]
|
||||||
|
|
@ -33,6 +38,8 @@
|
||||||
- [[#copy-to-clipboard][Copy to clipboard]]
|
- [[#copy-to-clipboard][Copy to clipboard]]
|
||||||
- [[#ui][UI]]
|
- [[#ui][UI]]
|
||||||
- [[#alacritty][Alacritty]]
|
- [[#alacritty][Alacritty]]
|
||||||
|
- [[#various-console-applications][Various console applications]]
|
||||||
|
- [[#guix-settings][Guix settings]]
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
* =.profile=
|
* =.profile=
|
||||||
|
|
@ -73,6 +80,23 @@ for i in $GUIX_EXTRA_PROFILES/*; do
|
||||||
done
|
done
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Set Jupyter config PATH. It defaults to readonly directory somewhere in Guix profile.
|
||||||
|
#+begin_src sh
|
||||||
|
export JUPYTER_CONFIG_DIR=$HOME/.config/jupyter
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
Set a folder for my packages.
|
||||||
|
#+begin_src sh
|
||||||
|
export GUIX_PACKAGE_PATH=~/guix-packages
|
||||||
|
#+end_src
|
||||||
|
** Other package managers
|
||||||
|
Using other package managers with Guix requires some extra work.
|
||||||
|
|
||||||
|
Make flatpak apps visible to launchers:
|
||||||
|
#+begin_src sh
|
||||||
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
|
||||||
|
#+end_src
|
||||||
|
|
||||||
Enable Nix
|
Enable Nix
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
if [ -f /run/current-system/profile/etc/profile.d/nix.sh ]; then
|
if [ -f /run/current-system/profile/etc/profile.d/nix.sh ]; then
|
||||||
|
|
@ -87,25 +111,34 @@ if [ -d "$HOME/.guix-extra-profiles/desktop" ]; then
|
||||||
fi
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
Set Jupyter config PATH. It defaults to readonly directory somewhere in Guix profile.
|
Make nix apps visible to launchers:
|
||||||
#+begin_src sh
|
|
||||||
export JUPYTER_CONFIG_DIR=$HOME/.config/jupyter
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
Set a folder for my packages.
|
|
||||||
#+begin_src sh
|
|
||||||
export GUIX_PACKAGE_PATH=~/guix-packages
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
Make flatpak apps visible to launchers
|
|
||||||
#+begin_src sh
|
|
||||||
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.local/share/flatpak/exports/share"
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
Make nix apps visible to launchers
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
|
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$HOME/.nix-profile/share/applications"
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
*** npm
|
||||||
|
npm is especially cumbersome, for instance because by default it tries to install packages to =/gnu/store/=.
|
||||||
|
|
||||||
|
In principle, one can set a prefix like this:
|
||||||
|
#+begin_src conf :tangle ~/._npmrc
|
||||||
|
prefix=/home/pavel/.npm-packages
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
But I also want to use node from conda occasionally, where prefix is already set correctly. So instead of tangling the above to the =~/.npmrc= directly, I set an environment variable in the profile:
|
||||||
|
|
||||||
|
#+begin_src sh
|
||||||
|
export NPM_CONFIG_USERCONFIG=$HOME/._npmrc
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
The variable is unset in a script in [[file:Guix.org::*conda][Guix.org]].
|
||||||
|
|
||||||
|
Set PATH & MANPATH
|
||||||
|
#+begin_src sh
|
||||||
|
NPM_PACKAGES="${HOME}/.npm-packages"
|
||||||
|
|
||||||
|
export PATH="$PATH:$NPM_PACKAGES/bin"
|
||||||
|
export MANPATH="${MANPATH-$(manpath)}:$NPM_PACKAGES/share/man"
|
||||||
|
#+end_src
|
||||||
** XResources
|
** XResources
|
||||||
| Guix dependency |
|
| Guix dependency |
|
||||||
|-----------------|
|
|-----------------|
|
||||||
|
|
@ -307,7 +340,7 @@ if [ -d "/usr/share/fzf" ]; then
|
||||||
fi
|
fi
|
||||||
#+end_src
|
#+end_src
|
||||||
*** Aliases
|
*** Aliases
|
||||||
#+begin_src bash :noweb-ref shell-aliases
|
#+begin_src bash :noweb yes :noweb-ref shell-aliases
|
||||||
alias v="vim"
|
alias v="vim"
|
||||||
alias gg="lazygit"
|
alias gg="lazygit"
|
||||||
alias ls="exa --icons"
|
alias ls="exa --icons"
|
||||||
|
|
|
||||||
40
Guix.org
40
Guix.org
|
|
@ -41,6 +41,7 @@ References:
|
||||||
- [[#flatpak][flatpak]]
|
- [[#flatpak][flatpak]]
|
||||||
- [[#conda][conda]]
|
- [[#conda][conda]]
|
||||||
- [[#slack][Slack]]
|
- [[#slack][Slack]]
|
||||||
|
- [[#virt-manager][virt-manager]]
|
||||||
- [[#wakatime-cli][wakatime-cli]]
|
- [[#wakatime-cli][wakatime-cli]]
|
||||||
- [[#manifest][Manifest]]
|
- [[#manifest][Manifest]]
|
||||||
:END:
|
:END:
|
||||||
|
|
@ -647,3 +648,42 @@ System
|
||||||
'(
|
'(
|
||||||
<<packages("system")>>))
|
<<packages("system")>>))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
Finally, I also want to have an ability to use global npm. Some settings for that are located in [[file:Console::*npm][Console.org]]. Here we want to unset =NPM_CONFIG_USERCONFIG= if there is npm available in the environment.
|
||||||
|
|
||||||
|
So here is a script to set up conda hooks:
|
||||||
|
#+begin_src bash :tangle ~/bin/scripts/setup-conda-npm
|
||||||
|
# Get writable conda envs with npm & without
|
||||||
|
readarray -t CONDA_ENVS_ALL <<< $(conda env list --json | jq '.envs[]')
|
||||||
|
CONDA_ENVS_NPM=()
|
||||||
|
CONDA_ENVS_NO_NPM=()
|
||||||
|
for env in "${CONDA_ENVS_ALL[@]}"; do
|
||||||
|
env="${env:1:${#env}-2}"
|
||||||
|
if [ -w "$env" ]; then
|
||||||
|
if [ -f "$env/bin/npm" ]; then
|
||||||
|
CONDA_ENVS_NPM+=($env)
|
||||||
|
else
|
||||||
|
CONDA_ENVS_NO_NPM+=($env)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for env in "${CONDA_ENVS_NPM[@]}"; do
|
||||||
|
echo "Found npm in $env"
|
||||||
|
mkdir -p "$env/etc/conda/activate.d"
|
||||||
|
mkdir -p "$env/etc/conda/deactivate.d"
|
||||||
|
|
||||||
|
echo "unset NPM_CONFIG_USERCONFIG" > "$env/etc/conda/activate.d/conda.sh"
|
||||||
|
echo "set -e NPM_CONFIG_USERCONFIG" > "$env/etc/conda/activate.d/conda.fish"
|
||||||
|
echo "export NPM_CONFIG_USERCONFIG=$HOME/._npmrc" > "$env/etc/conda/deactivate.d/conda.sh"
|
||||||
|
echo "export NPM_CONFIG_USERCONFIG=$HOME/._npmrc" > "$env/etc/conda/deactivate.d/conda.fish"
|
||||||
|
done
|
||||||
|
|
||||||
|
for env in "${CONDA_ENVS_NO_NPM}"; do
|
||||||
|
echo "Did not found npm in $env"
|
||||||
|
rm -rf "$env/etc/conda/activate.d/conda.sh" || true
|
||||||
|
rm -rf "$env/etc/conda/activate.d/conda.fish" || true
|
||||||
|
rm -rf "$env/etc/conda/deactivate.d/conda.sh" || true
|
||||||
|
rm -rf "$env/etc/conda/deactivate.d/conda.fish" || true
|
||||||
|
done
|
||||||
|
#+end_src
|
||||||
|
|
|
||||||
36
bin/scripts/setup-conda-npm
Executable file
36
bin/scripts/setup-conda-npm
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# [[file:../../Guix.org::*Manifest][Manifest:3]]
|
||||||
|
# Get writable conda envs with npm & without
|
||||||
|
readarray -t CONDA_ENVS_ALL <<< $(conda env list --json | jq '.envs[]')
|
||||||
|
CONDA_ENVS_NPM=()
|
||||||
|
CONDA_ENVS_NO_NPM=()
|
||||||
|
for env in "${CONDA_ENVS_ALL[@]}"; do
|
||||||
|
env="${env:1:${#env}-2}"
|
||||||
|
if [ -w "$env" ]; then
|
||||||
|
if [ -f "$env/bin/npm" ]; then
|
||||||
|
CONDA_ENVS_NPM+=($env)
|
||||||
|
else
|
||||||
|
CONDA_ENVS_NO_NPM+=($env)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for env in "${CONDA_ENVS_NPM[@]}"; do
|
||||||
|
echo "Found npm in $env"
|
||||||
|
mkdir -p "$env/etc/conda/activate.d"
|
||||||
|
mkdir -p "$env/etc/conda/deactivate.d"
|
||||||
|
|
||||||
|
echo "unset NPM_CONFIG_USERCONFIG" > "$env/etc/conda/activate.d/conda.sh"
|
||||||
|
echo "set -e NPM_CONFIG_USERCONFIG" > "$env/etc/conda/activate.d/conda.fish"
|
||||||
|
echo "export NPM_CONFIG_USERCONFIG=$HOME/._npmrc" > "$env/etc/conda/deactivate.d/conda.sh"
|
||||||
|
echo "export NPM_CONFIG_USERCONFIG=$HOME/._npmrc" > "$env/etc/conda/deactivate.d/conda.fish"
|
||||||
|
done
|
||||||
|
|
||||||
|
for env in "${CONDA_ENVS_NO_NPM}"; do
|
||||||
|
echo "Did not found npm in $env"
|
||||||
|
rm -rf "$env/etc/conda/activate.d/conda.sh" || true
|
||||||
|
rm -rf "$env/etc/conda/activate.d/conda.fish" || true
|
||||||
|
rm -rf "$env/etc/conda/deactivate.d/conda.sh" || true
|
||||||
|
rm -rf "$env/etc/conda/deactivate.d/conda.fish" || true
|
||||||
|
done
|
||||||
|
# Manifest:3 ends here
|
||||||
Loading…
Add table
Reference in a new issue