2020-05-17 13:04:07 +00:00
#+TITLE : Phundrak-flavored Arch Linux
2020-07-16 12:25:18 +00:00
#+setupfile : headers
2020-01-16 18:48:14 +00:00
#+OPTIONS : auto-id:t
#+HTML_HEAD_EXTRA : <meta name="description" content="Phundrak-flavored Arch Linux" />
#+HTML_HEAD_EXTRA : <meta property="og:title" content="Phundrak-flavored Arch Linux" />
#+HTML_HEAD_EXTRA : <meta property="og:description" content="How to install a Phundrak-flavored Arch Linux" />
2020-05-17 18:32:23 +00:00
#+PROPERTY : header-args :tangle no :exports none
2020-07-17 13:26:08 +00:00
#+PROPERTY : header-args:sh :tangle no :exports code
2020-05-17 18:32:23 +00:00
#+PROPERTY : header-args:fish :exports code :noweb yes
2020-05-28 10:05:36 +00:00
#+PROPERTY : header-args:emacs-lisp :exports none :noweb yes :tangle no :cache yes
2020-01-16 18:48:14 +00:00
* Introduction
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Introduction-cd5792cd
2020-01-16 18:48:14 +00:00
:END:
Here will be presented what I do to get my system up and running on a fresh
Arch Linux install. These installation instructions were written in order to
get an Arch Linux distribution up and running with the same configuration as
my main computer’ s and my travelling laptop’ s configuration.
* Install Arch Linux
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Install_Arch_Linux-ac7ad3b2
2020-01-16 18:48:14 +00:00
:END:
I usually install Arch from the [[https://www.archlinux.org/download/ ][vanilla ISO ]], however I began using [[https://github.com/MatMoul/archfi ][archfi ]] to
install easily the distro (I’ ve done it so many times, I know how it works
2020-09-28 16:17:07 +00:00
now). Usually, my distros will be installed on two partitions: ~/home~ and ~/~
(root).
2020-01-16 18:48:14 +00:00
If the computer supports EFI bootloaders, the EFI partition will be mounted on
2020-09-28 16:17:07 +00:00
~/boot/efi~ . I generally use ~systemd-boot~ as my boot manager, but if you are
more comfortable with another one, just install what you want. Be aware that
if you format your ~/boot~ partition, you will delete all boot managers that
already exist; so, if you are dual-booting, *DO NOT FORMAT IT* . Yes, I made
the mistake of wiping the Windows boot manager when I used to dual-boot.
In order to use the ~suspend-then-hibernate~ systemd command, it is necessary
to have a swap partition at least twice the size of your installed RAM. That
is because when this command will be run, the system will try to save the
current state of your machine, stored in your RAM, to the swap filesystem. If
there is not enough space, the command will fail, and you won’ t be able to use
this command.
** Get the latest, fastest mirrors
2020-01-16 18:48:14 +00:00
:PROPERTIES:
2020-09-28 16:17:07 +00:00
:CUSTOM_ID: Install_Arch_Linux-Get_the_latest_fastest_mirrors-765401c9
2020-01-16 18:48:14 +00:00
:END:
When you boot into the live ISO, execute the following command:
2020-09-28 16:17:07 +00:00
#+BEGIN_SRC sh
2020-01-16 18:48:14 +00:00
pacman -Sy reflector
2020-09-28 16:17:07 +00:00
reflector -c FR -c DE -c BE -l 200 -p http -p https --sort rate \
2020-01-16 18:48:14 +00:00
--save /etc/pacman.d/mirrorlist --verbose
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
This will update the packages from your live ISO, and you will get the best
mirrors for your installation. Of course, change the countries accordingly to
2020-09-28 16:17:07 +00:00
your location. In my case, I am only interested in French, German, and
Belgian mirrors.
2020-01-16 18:48:14 +00:00
** Install the system
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Install_Arch_Linux-Install_the_system-3ff49aa6
2020-01-16 18:48:14 +00:00
:END:
Then you can use a custom script to ease your installation of Arch if you do
not wish to do it manually. Personally, I’ ve done it several times already, I
know how the distro works, I just want to be able to install my distro
2020-09-28 16:17:07 +00:00
quickly now. I’ ll need to download the script with ~wget~ , but apparently it
isn’ t installed by default on Arch ISOs anymore, so I’ ll need to install it.
#+BEGIN_SRC sh
pacman -S wget
#+END_SRC
Now, let’ s grab the script. You can check it on [[https://github.com/matmoul/archfi ][Github ]].
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC sh
wget archfi.sf.net/archfi
# Or from matmoul.github.io/archfi if SourceForge is down
sh archfi
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
Then, follow the instructions and install Arch Linux. Take the opportunity to
2020-09-28 16:17:07 +00:00
install as many packages as you need, mainly ~yay~ which I use as my package
manager (it is just a wrapper for ~pacman~ ) and AUR helper, and
~pacman-contrib~ which will help us installing some packages later.
2020-01-16 18:48:14 +00:00
Once your system is installed, reboot and remove your installation media from
your computer.
2020-09-28 16:17:07 +00:00
* Execute bootstrap
2020-01-16 18:48:14 +00:00
:PROPERTIES:
2020-09-28 16:17:07 +00:00
:HEADER-ARGS:fish: :tangle ~/.config/yadm/bootstrap :shebang "#!/usr/bin/fish" :exports code :mkdirp yes
:CUSTOM_ID: Execute_bootstrap-e37054ef
2020-01-16 18:48:14 +00:00
:END:
2020-09-28 16:17:07 +00:00
With the installation of Arch with ~archfi~ , I will have [[https://github.com/Jguer/yay ][yay ]], an AUR helper,
installed. This will allow me to have some basic packages installed in order
to run the bootstrap described below. So, let’ s install ~fish~ (our shell
running the script), ~git~ , and my dotfiles manager ~yadm~ .
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC sh
2020-02-17 14:47:12 +00:00
yay -Sy fish git yadm
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
~yadm~ comes with a very handy feature: its bootstrap script. It can be
2020-02-17 14:47:12 +00:00
executed automatically once the dotfiles are cloned with yadm:
2020-09-28 16:17:07 +00:00
#+BEGIN_SRC sh
2020-02-17 14:47:12 +00:00
yadm clone https://labs.phundrak.com/phundrak/dotfiles
# or if labs.phundrak.com is down or too slow for you
2020-09-28 16:17:07 +00:00
#yadm clone https://github.com/phundrak/dotfiles
2020-01-16 18:48:14 +00:00
#+END_SRC
Let’ s take a look at what it does.
** Decrypt private yadm files
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Decrypt_private_yadm_files-68af7157
2020-01-16 18:48:14 +00:00
:END:
Some private files are stored encrypted in the repository of my yadm
dotfiles. I will need them later on during the bootstrap execution.
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
if test "$USER" = 'phundrak'
yadm decrypt
else
whiptail --yesno "Decrypt private files?" 8 40 && yadm decrypt
end
2020-01-16 18:48:14 +00:00
#+END_SRC
** Get a correct keyboard layout
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Get_a_correct_keyboard_layout-77d24b30
2020-01-16 18:48:14 +00:00
:END:
I use mainly the [[https://bepo.fr/wiki/Accueil ][bépo ]] layout, a French keyboard layout inspired by Dvorak
layouts, however I sometimes need to switch back to the standard French
AZERTY or the American QWERTY layout, so I make it so the Menu key switches
for me my layout between these three. This makes it so my xorg configuration
of my keyboard looks like this:
#+BEGIN_SRC fish
set keyboardconf \
'Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
2020-07-17 14:56:22 +00:00
Option "XkbLayout" "fr"
2020-01-16 18:48:14 +00:00
Option "XkbModel" "pc104"
2020-07-17 14:56:22 +00:00
Option "XkbVariant" "bepo_afnor"
Option "XkbOptions" "caps:ctrl_modifier"
2020-01-16 18:48:14 +00:00
EndSection'
#+END_SRC
2020-09-28 16:17:07 +00:00
So, let’ s ask the user if they want to set it as their keyboard
configuration.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
printf "\n# Set keyboard layout #########################################################\n\n"
2020-09-28 16:17:07 +00:00
whiptail --yesno "Would you like to set your keyboard layout to the bépo layout?" 8 55
if test $status -eq 0
echo $keyboardconf | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf
end
2020-01-16 18:48:14 +00:00
#+END_SRC
** Set our locale
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_our_locale-e74d772a
2020-01-16 18:48:14 +00:00
:END:
I use two main locales, the French and US UTF-8 locales, and I like to keep
the Japanese locale activated just in case.
#+BEGIN_SRC fish
set mylocales "en_US.UTF-8 UTF-8" "fr_FR.UTF-8 UTF-8" "ja_JP.UTF-8 UTF-8"
#+END_SRC
2020-09-28 16:17:07 +00:00
I’ ll let the user accept them one by one.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
2020-02-22 10:55:17 +00:00
printf "\n# Set locale ##################################################################\n\n"
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
for item in $mylocales
2020-09-28 16:17:07 +00:00
whiptail --yesno "Set the \"$item\" locale?" 8 40
if test $status -eq 0 -a (grep -e "#$item" /etc/locale.gen)
2020-01-16 18:48:14 +00:00
sudo sed -i "/$item/s/ ^#//g" /etc/locale.gen
end
end
#+END_SRC
This is my configuration I usually use when it comes to my locale.
#+BEGIN_SRC fish
set localeconf "LANG=en_US.UTF-8
LC_COLLATE=C
LC_NAME=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8"
#+END_SRC
2020-09-28 16:17:07 +00:00
Let’ s set it as our system’ s locale if the user whishes to.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
whiptail --yesno "Do you agree to have the following locale set?\n\n $localeconf" 20 43
if test $status -eq 0
echo $localeconf | sudo tee /etc/locale.conf
end
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
Now we can generate our locale!
#+BEGIN_SRC fish
printf "\n# Generate locale #############################################################\n\n"
sudo locale-gen
#+END_SRC
** Create some folders
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Create_some_folders-bf701387
2020-01-16 18:48:14 +00:00
:END:
Let’ s create some folders we might need for mounting our drives, Android
devices and CDs.
#+BEGIN_SRC fish
printf "\n# Create directories for mounting #############################################\n\n"
sudo mkdir -p /mnt/ {USB,CD,Android}
sudo chown $USER:(id -g $USER) /mnt/ {USB,CD,Android}
#+END_SRC
** Set user’ s shell to fish
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_user’ s_shell_to_fish-1a794be2
2020-01-16 18:48:14 +00:00
:END:
First of all, the bootstrap shell will set the user’ s shell to fish.
#+BEGIN_SRC fish
printf "\n# Set fish as the default shell ###############################################\n\n"
2020-09-28 16:17:07 +00:00
whiptail --yesno "Set the current user’ s default shell to fish?" 8 50
if test $status -eq 0 -a ! "$SHELL" = '/usr/bin/fish'
2020-02-17 15:26:12 +00:00
chsh -s /usr/bin/fish
end
2020-01-16 18:48:14 +00:00
#+END_SRC
** Install basic packages
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_basic_packages-17173316
2020-01-16 18:48:14 +00:00
:END:
Let’ s set in a custom varible what packages we’ ll be needing.
#+BEGIN_SRC fish
set PACKAGES \
2020-05-17 20:21:13 +00:00
acpilight adobe-source-han-sans-jp-fonts arc-gtk-theme asar ascii aspell-en \
aspell-fr awesome awesome-terminal-fonts awesome-freedesktop-git base-devel \
2020-07-11 16:07:11 +00:00
bashtop bat biber bitwarden-bin bluez-firmware bluez-utils bookworm bzip2 \
2020-05-28 10:05:36 +00:00
chicken chromium clisp corrupter-git cppcheck cppreference \
2020-08-22 15:00:44 +00:00
cppreference-devhelp cpupower discord-canary discount docker docker-compose \
dockerfile-language-server-bin doxygen emacs emacs-org-mode exa exfat-utils \
farbfeld fd ffmpegthumbnailer findutils firefox flake8 flat-remix-gtk freeglut \
fzf gcc-libs gdb gimp gnome-disk-utility gnome-epub-thumbnailer gnu-free-fonts \
gnuplot go go-tools golangci-lint-bin graphviz htop i3lock-color inetutils \
isync inter-font javascript-typescript-langserver js-beautify jfsutils jmtpfs \
lain-git libxft-bgra linux-headers lldb logrotate ly meson minted man-db \
2020-05-28 10:05:36 +00:00
man-pages mpc mpd mpd-rich-presence-discord-git mpv mupdf-tools nano ncdu \
2020-10-14 16:30:36 +00:00
ncmpcpp nemo-fileroller nemo-preview neofetch netctl network-manager-applet \
networkmanager networkmanager-openvpn nitrogen nm-connection-editor nodejs-vmd \
nomacs nordic-theme-git nordvpn-bin noto-fonts-emoji npm ntfs-3g numlockx \
obs-studio openssh otf-fandol otf-ipafont p7zip pacman-contrib pandoc-bin pass \
2020-08-24 12:45:58 +00:00
pavucontrol pdfpc picom-ibhagwan-git powerline-fonts prettier \
pulseaudio-bluetooth python-autoflake python-envtpl-git python-epc \
python-importmagic python-language-server python-nose python-pip python-ptvsd \
python-pytest qt5-imageformats qemu r raw-thumbnailer reflector ripgrep rofi \
rsync rtv ruby-rb-fsevent ruby-sass rustup samba scrot sent shadow siji-git \
2020-05-17 20:21:13 +00:00
simplescreenrecorder sshfs st-luke-git sxiv texlive-bin texlive-langchinese \
2020-08-24 12:45:58 +00:00
texlive-langcyrillic texlive-langgreek texlive-langjapanese texlive-langkorean \
texlive-latexextra texlive-localmanager-git texlive-most tmux tree \
ttf-arphic-uming ttf-baekmuk ttf-charis-sil ttf-dejavu \
2020-05-28 10:05:36 +00:00
ttf-google-fonts-opinionated-git ttf-hanazono ttf-joypixels ttf-koruri \
ttf-liberation ttf-monapo ttf-sazanami ttf-tibetan-machine typescript \
typescript-language-server-bin unicode-emoji unrar usbutils valgrind \
vscode-css-languageserver-bin vscode-html-languageserver-bin w3m wget \
2020-10-14 16:30:36 +00:00
x11-ssh-askpass xclip xdg-user-dirs-gtk xfce-polkit xidlehook xfsprogs \
xorg-drivers xorg-server xorg-xinit xss-lock xvkbd yaml-language-server-bin \
zeal
2020-05-17 20:21:13 +00:00
#+END_SRC
2020-01-16 18:48:14 +00:00
These are the minimum I would have in my own installation. You can edit it
however you want. Let’ s install those.
#+BEGIN_SRC fish
printf "\n# Installing needed packages ##################################################\n\n"
sudo pacman -Syu
2020-02-17 19:28:40 +00:00
for pkg in $PACKAGES
yay -S --needed $pkg
end
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-01-30 13:06:46 +00:00
** Tangle configuration files from Org files
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Tangle_configuration_files_from_Org_files-cc524361
2020-01-30 13:06:46 +00:00
:END:
2020-05-17 18:02:45 +00:00
Before tangling our configuration files, we need to create some directories
first so our files can be properly tangled. Here’ s the list of directories we
need to create:
#+NAME: dirs-tangled-files
| $HOME/.config/awesome |
| $HOME/.config/awesome/theme |
| $HOME/.config/emacs/private |
| $HOME/.config/fish |
| $HOME/.config/gtk-2.0 |
| $HOME/.config/gtk-3.0 |
| $HOME/.config/ncmpcpp |
| $HOME/.config/neofetch |
| $HOME/.config/picom |
| $HOME/.config/yadm |
| $HOME/.local/bin |
| $HOME/org/capture |
2020-05-17 18:16:56 +00:00
#+NAME: gen-dirs-tangle
2020-05-28 10:05:36 +00:00
#+BEGIN_SRC emacs-lisp :var dirs=dirs-tangled-files
2020-05-17 18:02:45 +00:00
(mapconcat (lambda (x) (format "mkdir -p %s" (car x)))
dirs
"\n")
#+END_SRC
2020-09-11 22:38:11 +00:00
#+RESULTS[a95e25a5f3ac91b1f884b39dde38e3b51366b188]: gen-dirs-tangle
#+begin_example
mkdir -p $HOME/.config/awesome
mkdir -p $HOME/.config/awesome/theme
mkdir -p $HOME/.config/emacs/private
mkdir -p $HOME/.config/fish
mkdir -p $HOME/.config/gtk-2.0
mkdir -p $HOME/.config/gtk-3.0
mkdir -p $HOME/.config/ncmpcpp
mkdir -p $HOME/.config/neofetch
mkdir -p $HOME/.config/picom
mkdir -p $HOME/.config/yadm
mkdir -p $HOME/.local/bin
mkdir -p $HOME/org/capture
#+end_example
2020-05-17 18:16:56 +00:00
Our code to generate such directories looks like this:
#+BEGIN_SRC fish :noweb yes
<<gen-dirs-tangle() >>
#+END_SRC
2020-05-17 18:02:45 +00:00
2020-01-30 13:06:46 +00:00
The next step is to tangle all the Org files. Here is the list of files that
are to be tangled:
#+NAME: tangled-files
2020-09-13 16:15:21 +00:00
| filename |
|-------------|
| awesome.org |
| bin.org |
| emacs.org |
| fish.org |
| index.org |
| picom.org |
| rustfmt.org |
| tmux.org |
2020-01-30 13:06:46 +00:00
#+NAME: generate-tangle
2020-05-28 10:05:36 +00:00
#+BEGIN_SRC emacs-lisp :var files=tangled-files[,0]
2020-03-15 11:24:46 +00:00
(mapconcat (lambda (x) (concat
(format "printf '\\n\\n==== Tangling %s\\n\\n' && \\\n" x)
(concat "emacs -q --batch --eval '(require \\'ob-tangle)' \\\n"
"--eval '(setq org-confirm-babel-evaluate nil)' \\\n"
(format "--eval '(org-babel-tangle-file \"~/org/config/ %s\")'\n" x))))
files
"\n")
2020-01-30 13:06:46 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
#+RESULTS[87a25d6c524e8d1346452c54aa42ac3ac09d94cf]: generate-tangle
2020-01-30 13:06:46 +00:00
#+begin_example
2020-09-03 10:15:16 +00:00
printf '\n\n==== Tangling awesome.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/awesome.org")'
2020-03-15 11:24:46 +00:00
printf '\n\n==== Tangling bin.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/bin.org")'
2020-09-13 16:15:21 +00:00
printf '\n\n==== Tangling emacs.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/emacs.org")'
2020-03-15 11:24:46 +00:00
printf '\n\n==== Tangling fish.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/fish.org")'
printf '\n\n==== Tangling index.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/index.org")'
2020-09-03 10:15:16 +00:00
printf '\n\n==== Tangling picom.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/picom.org")'
printf '\n\n==== Tangling rustfmt.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/rustfmt.org")'
2020-03-15 11:24:46 +00:00
printf '\n\n==== Tangling tmux.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-tangle-file "~/org/config/tmux.org")'
2020-01-30 13:06:46 +00:00
#+end_example
#+BEGIN_SRC fish :noweb yes
printf "\n# Tangling org files ##########################################################\n\n"
<<generate-tangle() >>
#+END_SRC
2020-01-16 18:48:14 +00:00
** Setting up Emacs: Installing Spacemacs
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Setting_up_Emacs:_Installing_Spacemacs-0b3d44b2
2020-01-16 18:48:14 +00:00
:END:
Now, the first thing we want to do with Emacs is install its Spacemacs
2020-02-16 22:41:28 +00:00
distribution. We’ ll clone its =develop= branch into =~/.config/emacs= . We
need to do this prior to our dotfiles’ cloning because of some submodules
that are cloned within our =~/.config/emacs= directory, and git won’ t let us
clone Spacemacs in an already existing and non-empty directory. To make sure
it isn’ t one, let’ s delete any potentially existing =~/.config/emacs=
directory:
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
printf "\n# Installing Spacemacs ########################################################\n\n"
2020-09-28 16:17:07 +00:00
rm -rf $HOME/.config/emacs $HOME/ .emacs* .spacemacs
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
Now we can clone Spacemacs:
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
git clone --branch develop https://github.com/syl20bnr/spacemacs ~/ .config/emacs
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
And we can restore what might have been deleted in our =~/.emacs.d/private=
directory:
#+BEGIN_SRC fish
2020-02-16 22:41:28 +00:00
yadm checkout -- ~/.config/emacs/private/
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
** Set up dotfiles’ git repository
2020-01-16 18:48:14 +00:00
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-ab372bd9
2020-01-16 18:48:14 +00:00
:END:
*** Update our dotfiles’ remotes
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-Update_our_dotfiles’ _remotes-5a0fe6f7
2020-01-16 18:48:14 +00:00
:END:
This line in the bootstrap script will test if the current user is using my
username. If yes, it’ s probably me.
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
if test "$USER" = 'phundrak'
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
If it is me installing and using these dotfiles, I want the remotes of my
dotfiles to be set to ssh remotes using my ssh keys.
#+BEGIN_SRC fish
printf "\n# Update yadm’ s remotes #######################################################\n\n"
yadm remote set-url origin git@labs.phundrak.com:phundrak/dotfiles.git
yadm remote add github git@github.com:phundrak/dotfiles.git
#+END_SRC
2020-09-28 16:17:07 +00:00
2020-01-16 18:48:14 +00:00
I will also want to decrypt my encrypted files, such as said ssh keys.
#+BEGIN_SRC fish
printf "\n# Decrypt encrypted dotfiles ##################################################\n\n"
yadm decrypt
#+END_SRC
2020-09-28 16:17:07 +00:00
Finally, let’ s close this ~if~ statement.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
end
2020-01-16 18:48:14 +00:00
#+END_SRC
*** Update our submodules
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_dotfiles-Update_our_submodules-3e921579
2020-01-16 18:48:14 +00:00
:END:
Now we can download the various dependencies of our dotfiles. To do so,
let’ s run the following command:
#+BEGIN_SRC fish
printf "\n# Getting yadm susbmodules ####################################################\n\n"
yadm submodule update --init --recursive
#+END_SRC
2020-02-22 11:57:06 +00:00
** Enable some services
2020-01-16 18:48:14 +00:00
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-3d38d98e
2020-01-16 18:48:14 +00:00
:END:
We have installed some packages which require some services to run. Let’ s
enable them.
2020-02-22 11:57:06 +00:00
*** Systemd-timesyncd
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Systemd-timesyncd-d887e45b
2020-02-22 11:57:06 +00:00
:END:
This service enables time syncing with the NTP protocol, so I can be sure my
computer’ s time is correct. The service first needs to be enabled:
#+BEGIN_SRC fish
printf "\n# Enabling timesync ###########################################################\n\n"
sudo systemctl enable --now systemd-timesyncd
#+END_SRC
Now, let systemd know I want to use the NTP protocol to keep my computer’ s
time synced.
#+BEGIN_SRC fish
sudo timedatectl set-ntp true
#+END_SRC
2020-01-16 18:48:14 +00:00
*** Docker
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Docker-305e8309
2020-01-16 18:48:14 +00:00
:END:
First, let’ s activate Docker.
#+BEGIN_SRC fish
printf "\n# Enabling and starting Docker ################################################\n\n"
sudo systemctl enable --now docker
#+END_SRC
Now, if we wish it, we can be added to the =docker= group so we won’ t have
to type =sudo= each time we call Docker or Docker Compose.
#+BEGIN_SRC fish
read --prompt "echo 'Do you wish to be added to the `docker` group? (Y/n): ' " -l adddockergroup
if test $adddockergroup = 'y' || test $adddockergroup = "Y" || test $adddockergroup = ''
sudo usermod -aG docker $USER
end
#+END_SRC
*** Emacs
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Emacs-c7785c21
2020-01-16 18:48:14 +00:00
:END:
Emacs will run as a user service, which means it won’ t be launched until we
2020-09-28 16:17:07 +00:00
log in. However, the service won’ t be started immediately, I personally
prefer to start a standalone instance in which installing and compiling the
Emacs packages will happen, and then once that is done I will start the
service.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
printf "\n# Enabling Emacs as user service ##############################################\n\n"
2020-09-28 16:17:07 +00:00
systemctl --user enable emacs
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-03-25 12:03:57 +00:00
*** Mpd
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Mpd-f0f5b9b7
2020-03-25 12:03:57 +00:00
:END:
Mpd will also use as a user service in order to get rid of some lines of
code in my configuration.
#+BEGIN_SRC fish
printf "\n# Enabling Mpd as a user service ##############################################\n\n"
mkdir -p ~/.config/mpd/playlists
systemctl --user enable --now mpd
#+END_SRC
2020-01-16 18:48:14 +00:00
*** SSH server
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-SSH_server-204f5997
2020-01-16 18:48:14 +00:00
:END:
Maybe we want to activate an SSH server on our machine. If so, we can enable
it. Let’ s ask the question.
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
whiptail --yesno 'Do you want to activate the ssh server?' 8 50
if test $status -eq 0
2020-01-16 18:48:14 +00:00
printf "\n# Enabling ssh server #########################################################\n\n"
sudo systemctl enable --now sshd
end
#+END_SRC
*** Ly
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Ly-f4b161c0
2020-01-16 18:48:14 +00:00
:END:
Ly is a display manager based on ncurses which I find nice enough for me to
use (I generally don’ t like using display managers). Let’ s enable it, and
let’ s disable tty2 while we’ re at it (Ly uses it to run X).
#+BEGIN_SRC fish
sudo systemctl disable getty@tty2
2020-09-28 16:17:07 +00:00
sudo systemctl enable --now ly
2020-01-16 18:48:14 +00:00
#+END_SRC
*** Acpilight
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-Acpilight-39152794
2020-01-16 18:48:14 +00:00
:END:
2020-09-28 16:17:07 +00:00
~acpilight~ is our utility managing the brightness of our screen. There is
2020-01-16 18:48:14 +00:00
actually no service to enable here, but we must ensure the user is part of
2020-09-28 16:17:07 +00:00
the ~video~ group so we can modify the brightness of our screen without
using ~sudo~ .
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
sudo usermod -aG video $USER
#+END_SRC
*** NordVPN
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Enable_some_services-NordVPN-75c1bd88
2020-01-16 18:48:14 +00:00
:END:
Thanks to the AUR package ~nordvpn-bin~ , I no longer have to manually
2020-09-28 16:17:07 +00:00
maintain my VPN connections with OpenVPN. However, it requires a service
that we should activate:
#+BEGIN_SRC fish
sudo systemctl enable --now nordvpnd
#+END_SRC
Let’ s also set its default protocol to UDP. This will allow me to use any
port while connected to any WiFi as long as the 443 port is available.
Because yes, I do connect to a WiFi that blocks some important ports, such
as the IMAP and SMTP ports. Thanks University of Paris 8 for being SO
paranoid.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
nordvpn s protocol udp
2020-01-16 18:48:14 +00:00
#+END_SRC
** Symlink some system config files
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Symlink_some_system_config_files-1dd95175
2020-01-16 18:48:14 +00:00
:END:
We have some files in [[file:ect/ ][etc/ ]] that are to be symlinked to =/etc= .
#+BEGIN_SRC fish
for f in (find ~/.etc -type f)
2020-09-28 16:17:07 +00:00
set dest (echo $f | sed -n 's|^.*etc\(.* \)$|/etc\1|p')
2020-01-16 18:48:14 +00:00
sudo ln -s $f $dest
end
#+END_SRC
** Install packages from git
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_packages_from_git-7c6a6ea4
2020-01-16 18:48:14 +00:00
:END:
Now, let’ s install some packages from git directly.
2020-02-17 15:09:23 +00:00
#+BEGIN_SRC fish
mkdir -p ~/fromGIT
#+END_SRC
2020-01-16 18:48:14 +00:00
*** Reveal.JS
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_packages_from_git-Reveal.JS-bb4da0bf
2020-01-16 18:48:14 +00:00
:END:
I sometimes use Reveal.JS to make presentations, and I set its location in
my [[file:.spacemacs ][dotspacemacs ]] file to be in =~/fromGIT= , so let’ s clone it there.
#+BEGIN_SRC fish
printf "\n# Install Reveal.JS ###########################################################\n\n"
cd ~/fromGIT
git clone https://github.com/hakimel/reveal.js.git
#+END_SRC
** Install Rust
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_Rust-1839c4d0
2020-01-16 18:48:14 +00:00
:END:
*** Install the toolchains
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_Rust-Install_the_toolchains-3480764a
2020-01-16 18:48:14 +00:00
:END:
2020-09-28 16:17:07 +00:00
When using Rust, I bounce between two toolchains, the ~stable~ toolchain and
the ~nightly~ toolchain, although I try to stick with Rust Stable. To
install them, I will use ~rustup~ which has already been installed
previously.
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
printf "\n# Install the rust toolchains, nightly is the default one #####################\n\n"
2020-09-28 16:17:07 +00:00
rustup default stable
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
This will both download the stable toolchain and set it as the default one.
Now to install the nightly toolchain, let’ s run this:
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
2020-09-28 16:17:07 +00:00
rustup toolchain install nightly
2020-01-16 18:48:14 +00:00
#+END_SRC
*** Install some utilities
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_Rust-Install_some_utilities-c4a7c785
2020-01-16 18:48:14 +00:00
:END:
2020-09-28 16:17:07 +00:00
We’ ll need some utilities when developing Rust from Emacs, namely ~rustfmt~
and ~racer~ . Let’ s install them with ~cargo~ .
2020-01-16 18:48:14 +00:00
#+BEGIN_SRC fish
printf "\n# Add rust utilities ##########################################################\n\n"
cargo install rustfmt racer
#+END_SRC
2020-09-28 16:17:07 +00:00
We will also need some components for development purposes.
#+NAME: rust-components-table
| Component | Why |
|-----------+---------------------------------------------|
| rust-src | Rust documentation in Emacs |
| rls | LSP backend for Emacs |
| clippy | A better version of cargo’ s ~check~ command |
#+NAME: rust-components-gen
#+BEGIN_SRC emacs-lisp :var components=rust-components-table[,0]
(mapconcat (lambda (x) (format "rustup component add %s" x))
components
"\n")
#+END_SRC
#+RESULTS[b3935b1c09d86fe506b43670f52960306a1e9809]:
: rustup component add rust-src
: rustup component add rls
: rustup component add clippy
Here is the code to do so:
#+BEGIN_SRC fish :noweb yes
<<rust-components-gen() >>
2020-01-16 18:48:14 +00:00
#+END_SRC
** Install some python packages
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Install_some_python_packages-a4447a6f
2020-01-16 18:48:14 +00:00
:END:
Some packages will be needed from pip in order to get our Emacs setup
2020-09-28 16:17:07 +00:00
correctly working.
#+NAME: python-packages-table
2020-10-01 16:26:52 +00:00
| Package | Why |
|-----------------------------+-------------------------|
| python-language-server[all] | Python LSP packages |
| pyls-isort | Import sortings for LSP |
| pyls-mypy | Mypy linter for LSP |
| pyls-black | Black plugin for pyls |
2020-09-28 16:17:07 +00:00
#+NAME: python-packages-gen
#+BEGIN_SRC emacs-lisp :var packages=python-packages-table[,0]
(format "pip install --user %s"
(s-join " " packages))
2020-01-16 18:48:14 +00:00
#+END_SRC
2020-10-01 16:26:52 +00:00
#+RESULTS[cb6abaea9d7130a67569af2b4d1a545651bf29ab]: python-packages-gen
: pip install --user python-language-server[all] pyls-isort pyls-mypy pyls-black
2020-09-28 16:17:07 +00:00
Let’ s install them locally for our user.
#+BEGIN_SRC fish :noweb yes
printf "\n# Installing Python packages ##################################################\n\n"
<<python-packages-gen() >>
2020-01-16 18:48:14 +00:00
#+END_SRC
** Set up Chicken (Scheme interpreter/compiler)
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_Chicken_ (Scheme_interpreter-compiler)-3c1a3c4a
2020-01-16 18:48:14 +00:00
:END:
Chicken needs to be set up before being used. First, we need to install its
documentation.
#+BEGIN_SRC fish
2020-01-29 20:19:57 +00:00
printf "\n# Setting up Chicken ##########################################################\n\n"
2020-01-16 18:48:14 +00:00
chicken-install -s apropos chicken-doc
#+END_SRC
Then, we’ ll complete the documentation like so:
#+BEGIN_SRC fish
cd (chicken-csi -b -e "(import (chicken platform))" -p "(chicken-home)")
curl https://3e8.org/pub/chicken-doc/chicken-doc-repo.tgz | sudo tar zx
#+END_SRC
2020-01-29 20:19:57 +00:00
** Set up our fish shell
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-f0741c22
2020-01-29 20:19:57 +00:00
:END:
The last thing we want to do is to set up our fish shell with some extensions
in order to improve the user experience.
2020-09-28 16:17:07 +00:00
*** Install ~fisher~
2020-01-29 20:19:57 +00:00
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-Install_ =fisher= -3a44531b
2020-01-29 20:19:57 +00:00
:END:
2020-09-28 16:17:07 +00:00
We will be using ~fisher~ as our extensions manager for Fish. Let’ s install
2020-01-29 20:19:57 +00:00
it.
#+BEGIN_SRC fish
printf "\n# Installing fisher ###########################################################\n\n"
curl https://git.io/fisher --create-dirs -sLo ~/ .config/fish/functions/fisher.fish
#+END_SRC
*** Install our extensions
:PROPERTIES:
2020-06-07 15:36:02 +00:00
:CUSTOM_ID: Execute_bootstrap-Set_up_our_fish_shell-Install_our_extensions-188e4566
2020-01-29 20:19:57 +00:00
:END:
I generally use the following extensions in my Fish shell.
2020-09-28 16:17:07 +00:00
#+NAME: fish-extensions-table
2020-01-29 20:19:57 +00:00
#+CAPTION: Fish extensions managed by Fisher
2020-09-28 16:17:07 +00:00
| Package name | Description |
|-----------------------------+------------------------------------------------------------------|
| decors/fish-colored-man | Color man pages to make them more readable |
| franciscolourenco/done | Automatically receive notifications when a long process finishes |
| jethrokuan/fzf | Improved key bindings for [[https://github.com/junegunn/fzf][junegunn/fzf]] |
| jethrokuan/z | Pure-fish [[https://github.com/rupa/z][rupa/z]]-like directory jumping |
| jorgebucaran/fish-bax | Run bash scripts, replaying environment changes in fish |
| jorgebucaran/fish-getopts | CLI options parser; alternative to the [[https://fishshell.com/docs/current/commands.html#argparse][argparse]] fish builtin |
| laughedelic/pisces | Autoclose parentheses, braces, quotes and other paired symbols |
| oh-my-fish/theme-bobthefish | A Powerline-style, Git-aware fish theme optimized for awesome. |
#+NAME: fish-extensions-gen
#+BEGIN_SRC emacs-lisp :var extensions=fish-extensions-table[,0]
2020-03-15 11:24:46 +00:00
(mapconcat (lambda (x) (format "fisher add %s" x))
extensions
"\n")
2020-01-29 20:19:57 +00:00
#+END_SRC
2020-09-28 16:17:07 +00:00
#+RESULTS[a88b321ba9148acc8c28c7fb1aaf924c23b6b072]: fish-extensions-gen
: fisher add decors/fish-colored-man
2020-01-29 20:19:57 +00:00
: fisher add franciscolourenco/done
: fisher add jethrokuan/fzf
: fisher add jethrokuan/z
2020-09-28 16:17:07 +00:00
: fisher add jorgebucaran/fish-bax
2020-01-29 20:19:57 +00:00
: fisher add jorgebucaran/fish-getopts
: fisher add laughedelic/pisces
2020-09-28 16:17:07 +00:00
: fisher add oh-my-fish/theme-bobthefish
2020-01-29 20:19:57 +00:00
#+BEGIN_SRC fish :noweb yes
printf "\n# Installing Fisher Extensions ################################################\n\n"
2020-09-28 16:17:07 +00:00
<<fish-extensions-gen() >>
2020-01-29 20:19:57 +00:00
#+END_SRC