Skip to content

Commit a622d4b

Browse files
committed
Nix home-manager
1 parent 7032893 commit a622d4b

File tree

1 file changed

+67
-143
lines changed

1 file changed

+67
-143
lines changed

books/linux-workstation.org

Lines changed: 67 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -451,37 +451,66 @@ Open the default terminal emulator (foot) with the keyboard shortcut:
451451
=Win+Enter= (hold down the "Windows" key on your keyboard, then
452452
simultaneously press Enter.)
453453

454-
My custom config replaces several of the default configuration files.
455-
So you must first get rid of these files, by renaming them with the
456-
suffix =.orig= for posterity:
454+
**** Install Nix
455+
456+
First, enable transient root (required for Nix on rpm-ostree systems):
457+
458+
#+begin_run
459+
sudo tee /etc/ostree/prepare-root.conf <<'EOF'
460+
[composefs]
461+
enabled = yes
462+
[root]
463+
transient = true
464+
EOF
465+
#+end_run
466+
467+
Track the config in initramfs and reboot:
468+
469+
#+begin_run
470+
rpm-ostree initramfs-etc --track=/etc/ostree/prepare-root.conf
471+
systemctl reboot
472+
#+end_run
473+
474+
After reboot, install Nix using the Determinate Systems installer:
457475

458476
#+begin_run
459-
mv ~/.config ~/.config.orig
460-
mv ~/.bashrc ~/.bashrc.orig
461-
mv ~/.bash_profile ~/.bash_profile.orig
477+
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
478+
sh -s -- install ostree --no-confirm
462479
#+end_run
463480

464-
Next, install my [[https://github.com/enigmacurry/sway-home][customized sway config repository]] :
481+
Verify installation:
482+
483+
#+begin_run
484+
nix --version
485+
#+end_run
486+
487+
**** Install Home Manager
488+
489+
Clone [[https://github.com/enigmacurry/sway-home][my customized sway config repository]]:
465490

466491
#+begin_run
467492
git clone https://github.com/enigmacurry/sway-home \
468493
~/git/vendor/enigmacurry/sway-home
469494
#+end_run
470495

471-
Run the included setup script:
496+
Install the configuration using Home Manager:
472497

473498
#+begin_run
474499
cd ~/git/vendor/enigmacurry/sway-home
475-
./setup.sh
500+
just hm-install
476501
#+end_run
477502

478-
The =setup.sh= script will make [[https://github.com/EnigmaCurry/sway-home/blob/master/setup.sh#L57-L61][symlinks]] to the repository files from
479-
the same original paths as the files you just moved. It also asks you
480-
some questions to help setup your git profile.
503+
This will install all dotfiles, packages (including Emacs), and shell
504+
configuration. Any existing files that conflict will be backed up with
505+
a =.backup= suffix.
506+
507+
During installation, you will be prompted to enter your git user name
508+
and email if not already configured. This creates a local config file
509+
at =~/.config/git/config.local= which is not tracked by the
510+
repository, allowing each user to have their own identity.
481511

482-
Once you have finished entering the information setup asks for, press
483-
=Win+Shift+E=, and choose Log Out. Log back in, and this will load the
484-
new config files.
512+
Once installation completes, press =Win+Shift+E= and choose Log Out.
513+
Log back in, and this will load the new config files.
485514

486515
*** Setup display resolutions and orientation
487516

@@ -1013,110 +1042,32 @@ This will allow you to run the host programs =toolbox=, =podman= and
10131042
[[https://www.gnu.org/software/emacs/][Emacs]] is my long time favorite code editor (IDE) and for writing
10141043
documentation (including this book).
10151044

1016-
*** Install Emacs
1017-
1018-
Because Sway runs on Wayland, you'll want to install the Wayland
1019-
(pgtk) version of Emacs. In Fedora 40 onwards, the Wayland (pgtk)
1020-
version is already the default. For Fedora 39, [[https://copr.fedorainfracloud.org/coprs/enigm-a/emacs-pgtk-nativecomp][you can use this COPR]]
1021-
(a COPR is to Fedora what PPA is to Ubuntu and what AUR is to Arch
1022-
Linux), which includes a custom build for Wayland (pgtk).
1023-
1024-
To enable this, you need to be running your dev distrobox:
1025-
1026-
#+begin_run
1027-
distrobox enter dev
1028-
#+end_run
1029-
1030-
Install Emacs:
1031-
1032-
#+attr_shortcode: :style secondary :title Run this inside the distrobox:
1033-
#+begin_run
1034-
sudo dnf install emacs
1035-
#+end_run
1036-
1037-
*** Create Emacs script
1038-
1039-
In order to be able to quickly launch Emacs inside the distrobox from
1040-
the host, you will need a little script installed on the host.
1041-
1042-
You can create this script and put it in =/usr/local/bin/emacs=. Run
1043-
this on the host (not in the distrobox), to create it as the root user:
1044-
1045-
#+begin_run
1046-
cat << EOF | sudo tee /usr/local/bin/emacs
1047-
#!/bin/bash
1048-
## Run Emacs in the dev distrobox and pass it any args:
1049-
distrobox enter --name dev -- bash -l -c emacs
1050-
EOF
1051-
sudo chmod a+x /usr/local/bin/emacs
1052-
#+end_run
1053-
1054-
Now you can run Emacs from the host, and it will run inside the
1055-
Distrobox.
1056-
1057-
*** Install dependencies
1058-
1059-
Most Emacs packages are written in Emacs Lisp, and therefore have no
1060-
external dependencies. The one exception is for Vterm terminal
1061-
support, which requires compiling a C library (libvterm). This
1062-
compilation can be done automatically by Emacs, but it requires you
1063-
have some tools preinstalled:
1045+
*** Emacs is already installed
10641046

1065-
* CMake
1066-
* libtool
1047+
If you followed the [[*Install Home Manager][Home Manager installation]] earlier, Emacs
1048+
(=emacs-pgtk= for native Wayland support) and [[https://github.com/EnigmaCurry/emacs][my configuration]] are
1049+
already installed.
10671050

1068-
Install the dependencies inside the distrobox:
1051+
*** Start Emacs
10691052

1070-
#+attr_shortcode: :style secondary :title run this inside the distrobox
1071-
#+begin_run
1072-
sudo dnf install cmake libtool
1073-
#+end_run
1074-
1075-
*** Remove any existing Emacs config
1076-
1077-
Assuming you want to use my Emacs config, you need to delete any
1078-
existing config you already have. Also note that Emacs creates a
1079-
default config the first time it runs, so if you started Emacs
1080-
already, you may have a config and not even know it.
1081-
1082-
Here's how to remove the existing Emacs config:
1053+
Run:
10831054

10841055
#+begin_run
1085-
rm ~/.emacs ~/.emacs.d -rf
1056+
emacs
10861057
#+end_run
10871058

1088-
*** Install my Emacs config
1089-
1090-
[[https://github.com/EnigmaCurry/emacs][My Emacs config is on github]]. Install it with the following script:
1091-
1092-
#+begin_run
1093-
REMOTE=https://github.com/EnigmaCurry/emacs.git
1094-
REPO=${HOME}/git/vendor/enigmacurry/emacs
1095-
BRANCH=straight
1059+
*** Enable modules
10961060

1097-
(set -e
1098-
test -d ~/.emacs.d && (echo "~/.emacs.d already exists. Aborting install." && exit 1)
1099-
test -d ${REPO} || git clone -b ${BRANCH} ${REMOTE} ${REPO}
1100-
mkdir ~/.emacs.d && ls -1 ${REPO}/*.el | xargs -iXX ln -s XX ~/.emacs.d
1101-
mkdir ~/.emacs.d/straight && ln -s ${REPO}/straight-versions ~/.emacs.d/straight/versions
1102-
ln -s ${REPO}/snippets ~/.emacs.d/snippets
1103-
)
1104-
#+end_run
1061+
My config is composed of several optional modules. The initial config
1062+
has zero modules loaded by default. To enable them, you must run:
11051063

1106-
*** Start Emacs to finish the installation
1064+
#+begin_example
1065+
M-x my/machine-labels-enable-all
1066+
#+end_example
11071067

1108-
The first time Emacs starts, it will install all of the dependencies
1109-
listed in the main config file =~/.emacs.d/init.el=.
1110-
1111-
Run:
1112-
1113-
#+begin_run
1114-
emacs
1115-
#+end_run
1116-
1117-
Wait for everything to install. You may see a blank screen for up to
1118-
10 minutes, but you should see some minimal information of the
1119-
progress in the bottom minibuffer.
1068+
Then restart Emacs, and wait for everything to install. You may see a
1069+
blank screen for up to 10 minutes, but you should see some minimal
1070+
information of the progress in the bottom minibuffer.
11201071

11211072
If it gets stuck at any point, quit and restart it, and it should
11221073
continue where it left off. If you get any error message, you may want
@@ -1129,10 +1080,9 @@ emacs --debug-init
11291080
This will usually give you a more verbose error message which can be
11301081
helpful in debugging the startup.
11311082

1132-
11331083
*** Read the README for my config
11341084

1135-
More notes are available in the [[https://github.com/EnigmaCurry/emacs#readme][README]].
1085+
You can read more about this config at [[https://emacs.rymcg.tech][emacs.rymcg.tech]]
11361086

11371087
** SSH
11381088
:PROPERTIES:
@@ -1242,41 +1192,16 @@ when you log in. (In the case of the solokey, the key is never held in
12421192
memory, but you still need to hold the identity of it in the
12431193
ssh-agent.)
12441194

1245-
Keychain is a program that helps you setup the ssh-agent. Install
1246-
=keychain= in each of your distroboxes and/or workstations:
1247-
1248-
#+attr_shortcode: :title Run this on your Fedora workstations: :style secondary
1249-
#+begin_run
1250-
sudo dnf install keychain
1251-
#+end_run
1252-
1253-
#+attr_shortcode: :title Run this on your Debian / Ubuntu workstations: :style secondary
1254-
#+begin_run
1255-
sudo apt install keychain
1256-
#+end_run
1257-
1258-
#+attr_shortcode: :title Run this on your Arch Linux workstations: :style secondary
1259-
#+begin_run
1260-
sudo pacman -S keychain
1261-
#+end_run
1262-
1263-
To configure keychain, edit your =~/.bashrc= file:
1264-
1265-
#+attr_shortcode: :file ~/.bashrc
1266-
#+begin_edit
1267-
## Put this line in your ~/.bashrc:
1268-
## (If you're using my config, this is already in it.)
1269-
eval $(keychain --eval --quiet)
1270-
#+end_edit
1195+
Keychain is a program that helps you setup the ssh-agent. If you
1196+
installed [[*Install Home Manager][Home Manager]] earlier, =keychain= is already installed
1197+
via Nix, and is already configured in your =~/.bashrc=.
12711198

1272-
Log out of your desktop session, and log back in. Open your terminal,
1273-
and you should be automatically prompted to enter your SSH passphrase.
1274-
Once you have entered the passphrase, the SSH key will remain resident
1275-
in memory until you log out.
1199+
When you open your terminal, you should be automatically prompted to
1200+
enter your SSH passphrase. Once you have entered the passphrase, the
1201+
SSH key will remain resident in memory until you log out.
12761202

12771203
Double check that the key has been loaded, run:
12781204

1279-
#+attr_shortcode: :title run this inside your distrobox
12801205
#+begin_run
12811206
ssh-add -L
12821207
#+end_run
@@ -1294,7 +1219,6 @@ Apparently, keychain does not yet know how to load the Solokey
12941219
automatically. You must add the Solokey to the ssh-agent manually, one
12951220
time, each time you boot your workstation:
12961221

1297-
#+attr_shortcode: :title run this inside your distrobox
12981222
#+begin_run
12991223
## Do this to load your Solokey into the ssh-agent:
13001224
ssh-add -K

0 commit comments

Comments
 (0)