Skip to content

Commit 3f545b8

Browse files
author
Marc Henry de Frahan
committed
Simplify the multi-arch home setup
1 parent a649f62 commit 3f545b8

18 files changed

+197
-266
lines changed

.chezmoi.toml.tmpl

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,18 @@
1717
{{ $ornl_hpc = true -}}
1818
{{- end -}}
1919

20-
{{/* Set scratch_root automatically based on system type */}}
21-
{{ $scratch_root := "${HOME}" -}}
20+
{{/* Scratch root for HPC systems */}}
21+
{{- $scratch_root := "${HOME}" -}}
2222
{{- if $nrel_hpc -}}
23-
{{ $scratch_root = "/scratch/${USER}" -}}
23+
{{- $scratch_root = "/scratch/${USER}" -}}
2424
{{- else if $ornl_hpc -}}
25-
{{ $scratch_root = "/lustre/orion/${USER}" -}}
25+
{{- $scratch_root = "/lustre/orion/${USER}" -}}
2626
{{- end -}}
2727

28-
{{/* Prompt for large install directory (pyenv, virtualenvs) */}}
29-
{{- $use_large_install_dir := false -}}
28+
{{/* Large install dir for systems with small home directories */}}
3029
{{- $large_install_dir := "${HOME}" -}}
31-
{{- if stdinIsATTY -}}
32-
{{- $use_large_install_dir = promptBoolOnce . "use_large_install_dir" "Install large executables in non-default location" -}}
33-
{{- else if hasKey . "use_large_install_dir" -}}
34-
{{- $use_large_install_dir = .use_large_install_dir -}}
35-
{{- end -}}
36-
{{- if $use_large_install_dir -}}
37-
{{- $default_install_dir := printf "%s/install" $scratch_root -}}
38-
{{- if stdinIsATTY -}}
39-
{{- $large_install_dir = promptStringOnce . "large_install_dir" (printf "Large install directory [%s]" $default_install_dir) -}}
40-
{{- if not $large_install_dir -}}
41-
{{- $large_install_dir = $default_install_dir -}}
42-
{{- end -}}
43-
{{- else if and (hasKey . "large_install_dir") .large_install_dir -}}
44-
{{- $large_install_dir = .large_install_dir -}}
45-
{{- else -}}
46-
{{- $large_install_dir = $default_install_dir -}}
47-
{{- end -}}
48-
{{- end -}}
30+
{{/* Multi-arch home: use ~/.local symlink to ~/.local-${ARCH} for shared NFS homes */}}
31+
{{- $is_multiarch_home := false -}}
4932

5033
[data]
5134
use_zsh_root_dir = {{ $use_zsh_root_dir }}
@@ -56,5 +39,5 @@
5639
nrel_cluster = {{ $nrel_cluster }}
5740
ornl_hpc = {{ $ornl_hpc }}
5841
scratch_root = {{ $scratch_root | quote }}
59-
use_large_install_dir = {{ $use_large_install_dir }}
60-
large_install_dir = {{ $large_install_dir | quote }}
42+
large_install_dir = {{ $large_install_dir | quote }}
43+
is_multiarch_home = {{ $is_multiarch_home }}

.chezmoiignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ requirements.txt
66
.shell-secrets
77
docker
88
.dockerignore
9+
.chezmoi-source
910

1011
{{- if ne .chezmoi.os "darwin" }}
1112
.config/karabiner

.github/workflows/ci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ jobs:
2626
- name: Dependencies
2727
run: |
2828
bash ./dotfiles/bin/executable_install_bootstrap_dependencies.sh
29-
- name: Add arch-specific bin to PATH
29+
- name: Add local bin to PATH
3030
run: |
31-
ARCH=$(uname -m)
32-
echo "$HOME/.local/${ARCH}/bin" >> $GITHUB_PATH
31+
echo "$HOME/.local/bin" >> $GITHUB_PATH
3332
- name: Clone dotfiles
3433
run: |
3534
mkdir -p "$HOME/.local/share/chezmoi"
3635
git config --global --add safe.directory "$HOME/.local/share/chezmoi"
3736
git clone --depth 1 --branch "${{ github.head_ref || github.ref_name }}" https://github.com/marchdf/dotfiles.git "$HOME/.local/share/chezmoi"
3837
- name: Install
3938
run: |
40-
chezmoi init --source="$HOME/.local/share/chezmoi" --promptBool test_machine=t,"Use ZSH_ROOT_DIR for tmux shell"=f,use_large_install_dir=f --promptString email=""
39+
chezmoi init --source="$HOME/.local/share/chezmoi" --promptBool test_machine=t,"Use ZSH_ROOT_DIR for tmux shell"=f --promptString email=""
4140
chezmoi data
4241
chezmoi apply
4342
- name: Cold start zsh

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,26 @@ chezmoi apply -v
3535

3636
### Linux
3737

38-
Install chezmoi to arch-specific bin:
38+
For a full environment with all dependencies (recommended), run the bootstrap script:
3939

4040
```bash
41-
ARCH=$(uname -m)
42-
mkdir -p ~/.local/${ARCH}/bin
43-
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/${ARCH}/bin
44-
export PATH="$HOME/.local/${ARCH}/bin:$PATH"
41+
curl -fsSL https://raw.githubusercontent.com/marchdf/dotfiles/main/bin/executable_install_bootstrap_dependencies.sh | bash
42+
chezmoi init git@github.com:marchdf/dotfiles.git
43+
chezmoi apply -v
4544
```
4645

47-
Then apply dotfiles:
46+
Or install manually:
4847

4948
```bash
49+
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b ~/.local/bin
50+
export PATH="$HOME/.local/bin:$PATH"
5051
chezmoi init git@github.com:marchdf/dotfiles.git
51-
chezmoi diff
5252
chezmoi apply -v
5353
```
5454

55-
For a full environment with all dependencies, run the bootstrap script first:
56-
57-
```bash
58-
curl -fsSL https://raw.githubusercontent.com/marchdf/dotfiles/main/bin/executable_install_bootstrap_dependencies.sh | bash
59-
```
55+
**Note:** Multi-architecture support (for shared NFS homes) can be enabled.
56+
`chezmoi apply` creates `~/.local-${ARCH}` directories and symlinks `~/.local` to the
57+
current architecture's directory.
6058

6159
Improved experience
6260
-------------------

bin/executable_cleanup_installs.sh

Lines changed: 0 additions & 135 deletions
This file was deleted.

bin/executable_install_bootstrap_dependencies.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ elif [[ "$OS" == "Linux" ]]; then
6464
else
6565
echo "Linux (Unknown distro)"
6666
fi
67-
ARCH=$(uname -m)
68-
ARCH_BIN="${HOME}/.local/${ARCH}/bin"
69-
mkdir -p "${ARCH_BIN}"
70-
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "${ARCH_BIN}"
71-
export PATH="${ARCH_BIN}:${HOME}/.local/bin:$PATH"
67+
68+
# Install chezmoi
69+
mkdir -p "${HOME}/.local/bin"
70+
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b "${HOME}/.local/bin"
71+
export PATH="${HOME}/.local/bin:$PATH"
7272
else
7373
echo "Unknown OS: $OS"
7474
fi

bin/executable_install_emms-print-metadata.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env bash
22

3-
ARCH=$(uname -m)
4-
ARCH_BIN="${HOME}/.local/${ARCH}/bin"
5-
mkdir -p "${ARCH_BIN}"
3+
LOCAL_BIN="${HOME}/.local/bin"
4+
mkdir -p "${LOCAL_BIN}"
65

76
EMMS_DIR="${HOME}/.emacs.d/build/emms"
8-
EMMS_EXEC="${ARCH_BIN}/emms-print-metadata"
7+
EMMS_EXEC="${LOCAL_BIN}/emms-print-metadata"
98

109
if [[ -x "${EMMS_EXEC}" ]]; then
1110
exit 0

docker/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ WORKDIR /home/$USERNAME
4444
COPY --chown=$USERNAME:$USERNAME ../bin/executable_install_bootstrap_dependencies.sh /tmp/install_bootstrap.sh
4545
RUN bash /tmp/install_bootstrap.sh && rm /tmp/install_bootstrap.sh
4646

47-
# Ensure chezmoi is in PATH (arch-specific first, then legacy)
48-
RUN ARCH=$(uname -m) && echo "export PATH=\"\$HOME/.local/\${ARCH}/bin:\$HOME/.local/bin:\$PATH\"" >> $HOME/.profile
49-
ENV PATH="/home/$USERNAME/.local/bin:${PATH}"
47+
# Ensure local bin is in PATH for runtime
48+
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.profile
5049

5150
# Initialize chezmoi with dotfiles from GitHub
52-
RUN chezmoi init https://github.com/marchdf/dotfiles.git \
53-
--promptBool test_machine=f,"Use ZSH_ROOT_DIR for tmux shell"=f,use_large_install_dir=f \
51+
RUN source $HOME/.profile && \
52+
chezmoi init https://github.com/marchdf/dotfiles.git \
53+
--promptBool test_machine=f,"Use ZSH_ROOT_DIR for tmux shell"=f \
5454
--promptString email="marchdf@docker-container.com" \
5555
&& chezmoi apply
5656

docker/Dockerfile.test

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,12 @@ RUN if ! getent group $USER_GID > /dev/null 2>&1; then groupadd --gid $USER_GID
6262
USER $USERNAME
6363
WORKDIR /home/$USERNAME
6464

65-
# Install chezmoi to arch-specific bin
66-
RUN ARCH=$(uname -m) && \
67-
mkdir -p $HOME/.local/${ARCH}/bin && \
68-
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/${ARCH}/bin
65+
# Install chezmoi
66+
RUN mkdir -p $HOME/.local/bin && \
67+
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $HOME/.local/bin
6968

70-
# Ensure tools are in PATH (arch-specific first, then legacy)
71-
RUN ARCH=$(uname -m) && echo "export PATH=\"\$HOME/.local/\${ARCH}/bin:\$HOME/.local/bin:\$PATH\"" >> $HOME/.profile
69+
# Ensure local bin is in PATH
70+
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.profile
7271
ENV PATH="/home/$USERNAME/.local/bin:${PATH}"
7372

7473
# Create directory structure for chezmoi source symlink

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ docker compose run --rm ubuntu-test
2323

2424
# Inside container - first time setup:
2525
chezmoi init --source /dotfiles-source \
26-
--promptBool test_machine=f,"Use ZSH_ROOT_DIR for tmux shell"=f,use_large_install_dir=f \
26+
--promptBool test_machine=f,"Use ZSH_ROOT_DIR for tmux shell"=f \
2727
--promptString email="marchdf@docker-container.com"
2828
chezmoi apply
2929

0 commit comments

Comments
 (0)