update readme
This commit is contained in:
parent
ef6a308fbe
commit
eb2b36fa24
299
README.md
299
README.md
@ -1,117 +1,226 @@
|
|||||||
# dotfiles
|
# Dotfiles
|
||||||
```shell
|
|
||||||
git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git ~/.dotfiles
|
## How to Use
|
||||||
cd ~/.dotfiles
|
|
||||||
./install.py
|
First, clone the repository:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git ~/.dotfiles && cd ~/.dotfiles
|
||||||
```
|
```
|
||||||
|
|
||||||
Do not forget to change the remote from https to ssh
|
The `setup` script will automatically update the remote repository URL. However, if you are configuring the dotfiles manually, make sure to change it after adding your SSH key:
|
||||||
```shell
|
|
||||||
|
```sh
|
||||||
git remote set-url origin git@gitea.tomastm.com:tomas.mirchev/dotfiles.git
|
git remote set-url origin git@gitea.tomastm.com:tomas.mirchev/dotfiles.git
|
||||||
git remote -v
|
git remote -v
|
||||||
```
|
```
|
||||||
|
|
||||||
### Todo
|
The `manage.py` script allows you to link configurations, install packages, and set up environments. To view available arguments, use:
|
||||||
- [ ] Uninstall option
|
|
||||||
- [ ] Fix inconsistencies with usage fn
|
```sh
|
||||||
|
manage.py -h
|
||||||
|
manage.py <link|install|setup> -h
|
||||||
|
```
|
||||||
|
|
||||||
|
### Common Commands:
|
||||||
|
|
||||||
|
- `manage.py link <environment> [--copy] [-f|--force] [-p|--package]`
|
||||||
|
- `manage.py install <environment> [-p|--package]`
|
||||||
|
- `manage.py setup <environment> [--extra]`
|
||||||
|
|
||||||
|
You can create multiple environments, following this structure:
|
||||||
|
|
||||||
|
- `config/<environment>`
|
||||||
|
- `config.json` (add `<environment>` to the JSON file)
|
||||||
|
- `setups/<environment>`
|
||||||
|
- Any additional scripts can be placed in `scripts/<script>`, following the naming convention `<env>-<script>`.
|
||||||
|
|
||||||
|
## Environments
|
||||||
|
|
||||||
|
Although you can specify any environment using `manage.py`, the recommended workflow follows this structure:
|
||||||
|
|
||||||
|
### MacOS (`macos`)
|
||||||
|
|
||||||
|
> **Setup command:** `manage.py setup macos`
|
||||||
|
|
||||||
|
Since macOS is the host machine, it should use minimal applications and configurations. Whenever possible, install applications via Homebrew.
|
||||||
|
|
||||||
|
Before formatting your machine, back up installed formulas and casks:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
scripts/macos-brew_backup.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
This backup will be restored automatically when setting up `macos`.
|
||||||
|
|
||||||
|
#### Essential Applications:
|
||||||
|
|
||||||
|
- **LinearMouse**: Invert scrolling, adjust scrolling by pixels, and fix pointer acceleration.
|
||||||
|
- **Karabiner**: Configure keybindings and modifier keys.
|
||||||
|
- **Rectangle**: Window tiling.
|
||||||
|
- **Window-Tagger**: Custom window manager ([repository](https://gitea.tomastm.com/tomas.mirchev/window-tagger)).
|
||||||
|
- **Ghostty**: Terminal emulator.
|
||||||
|
|
||||||
|
System settings cannot be automatically backed up. Refer to `obsidian#MacSettings.md` for manual adjustments.
|
||||||
|
|
||||||
|
#### UTM (Virtual Machines)
|
||||||
|
|
||||||
|
Development should occur inside virtual machines. UTM is preferred due to its open-source nature and support for both QEMU and Apple Hypervisor.
|
||||||
|
|
||||||
|
> **Note:** When installing ISOs, ensure the correct architecture is selected.
|
||||||
|
|
||||||
|
For Debian-based setups, avoid setting a `root` password to enable automatic `sudo` installation and add your user to the sudo group.
|
||||||
|
|
||||||
|
#### DNS Configuration
|
||||||
|
|
||||||
|
Communication between the host and virtual machines happens via local IPs set by UTM DHCP. To simplify this process, use `dnsmasq` (installed via `manage.py`).
|
||||||
|
|
||||||
|
##### 1. Verify `dnsmasq` is Running
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pgrep dnsmasq # Should return a PID if running
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 2. Determine the Default Gateway
|
||||||
|
|
||||||
|
On **macOS (host):**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ifconfig | grep 192
|
||||||
|
```
|
||||||
|
|
||||||
|
On the **VM** (in "Shared Network" mode):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ip r
|
||||||
|
```
|
||||||
|
|
||||||
|
Typically, the **gateway IP** is `192.168.64.1`. If different, update the next steps accordingly.
|
||||||
|
|
||||||
|
##### 3. Edit `dnsmasq.conf`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo vim /opt/homebrew/etc/dnsmasq.conf
|
||||||
|
```
|
||||||
|
|
||||||
|
Add:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
# Define local domains
|
||||||
|
address=/personal.utm.local/192.168.64.2
|
||||||
|
address=/university.utm.local/192.168.64.3
|
||||||
|
address=/personal.workstation.lan/192.168.50.2
|
||||||
|
|
||||||
|
# Listening addresses (include gateway IP)
|
||||||
|
listen-address=127.0.0.1,192.168.64.1
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 4. Configure macOS to Use `dnsmasq`
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo mkdir -p /etc/resolver
|
||||||
|
sudo vim /etc/resolver/local
|
||||||
|
sudo vim /etc/resolver/lan
|
||||||
|
```
|
||||||
|
|
||||||
|
Add:
|
||||||
|
|
||||||
|
```plaintext
|
||||||
|
nameserver 127.0.0.1
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/local
|
||||||
|
```
|
||||||
|
|
||||||
|
##### 5. Restart `dnsmasq` and Flush DNS Cache
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo brew services restart dnsmasq
|
||||||
|
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Notes
|
||||||
|
|
||||||
|
- `dnsmasq` requires manual removal on Brew upgrades or uninstallation:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
sudo rm -rf /opt/homebrew/Cellar/dnsmasq/*/sbin
|
||||||
|
sudo rm -rf /opt/homebrew/opt/dnsmasq
|
||||||
|
sudo rm -rf /opt/homebrew/var/homebrew/linked/dnsmasq
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux VM (`linux-vm`)
|
||||||
|
|
||||||
|
> **Setup command:** `manage.py setup linux-vm --extra "<hostname>"`
|
||||||
|
|
||||||
|
After running the setup script, follow any additional manual steps it outputs.
|
||||||
|
|
||||||
|
The most critical step is authenticating with the registry:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
docker login registry.tomastm.com
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux Dev (`linux-dev`)
|
||||||
|
|
||||||
|
This environment does not use a `setup` command, as it is configured via `Dockerfile`. However, `install` and `link` commands are available.
|
||||||
|
|
||||||
|
Use `link --copy` to avoid redundant configurations inside images, reducing final image size.
|
||||||
|
|
||||||
|
A base image (`base-debian`) contains essential utilities. Additional images exist for specific tools, such as `node` and `python`. View all images at: [Dev Containers](https://gitea.tomastm.com/tomas.mirchev/dev-containers).
|
||||||
|
|
||||||
|
Each project should run its own container instance, enabling seamless project switching. Code remains on a mounted volume from the Linux VM.
|
||||||
|
|
||||||
|
Containers persist until manually stopped, allowing `tmux` sessions to remain active.
|
||||||
|
|
||||||
|
For convenience, use the `dev` script located in `~/bin` (automatically added to `PATH`).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dev -i <image> <name>
|
||||||
|
|
||||||
|
# Example:
|
||||||
|
dev -i node myapp
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates a container named `node-myapp` (`<image>-<name>`).
|
||||||
|
|
||||||
|
All images support both `arm64` and `amd64` architectures, automatically detected during execution.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# Notes for README
|
## Miscellaneous
|
||||||
- How to update dotfiles? By default, they are symlinked.
|
|
||||||
-> Directly modify `config/shared/<config>` or `config/envs/<env>/<config>`
|
|
||||||
-> If new config, add it to `config.json` too.
|
|
||||||
-> And simply run `./manage.py link <env>`. If needed, do not forget to update the `config.json#install` or `homebrew dump`.
|
|
||||||
- How to unlink?
|
|
||||||
-> Just remove the symlink and unspecify it from `config.json` to keep it updated for the future.
|
|
||||||
|
|
||||||
# Files and steps
|
### Building NeoVim
|
||||||
Scripts:
|
|
||||||
- macos-save_homebrew.sh
|
|
||||||
- macos-install_homebrew.sh
|
|
||||||
- macos-change_hostname --hostname
|
|
||||||
- linux-setup_docker.sh
|
|
||||||
- linux-change_hostname --hostname
|
|
||||||
- setup_shh.sh -C $USER@$HOSTNAME -f internal|git|none
|
|
||||||
|
|
||||||
Setups:
|
NeoVim is mirrored to Gitea to build `.deb` packages for releases. Follow these steps:
|
||||||
- macos (--hostname)
|
|
||||||
- linux-vm (--hostname)
|
|
||||||
- linux-dev
|
|
||||||
|
|
||||||
|
```sh
|
||||||
# For MacOS
|
git clone git@gitea.tomastm.com:tomas.mirchev/neovim.git
|
||||||
```
|
cd neovim
|
||||||
$ git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git .dotfiles
|
git checkout tags/<tag>
|
||||||
$ cd .dotfiles
|
make CMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
$ ./manage.py setup macos --hostname macbook-pro
|
cd build
|
||||||
-> Install homebrew
|
cpack -G DEB
|
||||||
-> Install all apps from dump (also stored in ./config/envs/macos)
|
|
||||||
-> run: ./manage.py link macos (git, zsh, nvim-vanilla, tmux, karabiner, linearmouse, ghostty)
|
|
||||||
-> from shared: git, zsh, tmux, nvim-simple
|
|
||||||
-> from env macos: karabiner, linearmouse, ghostty
|
|
||||||
-> execute: ./scripts/macos-change_hostname --hostname $HOSTNAME
|
|
||||||
-> execute: ./scripts/setup_ssh.sh -C $USER@$HOSTNAME -f internal (-f: id_ed25519_internal)
|
|
||||||
-> execute: ./scripts/setup_ssh.sh -C $USER@$HOSTNAME -f git (-f: id_ed25519_git)
|
|
||||||
-> echo: "internal key generated, once vms and dns are ready: ssh-copy-id tomas@ip"
|
|
||||||
-> echo: "You ssh pub key is: <key>". do not forget to change from https to git
|
|
||||||
-> echo: "Do not forget to change git remote from https to git after adding SSH Key"
|
|
||||||
-> echo: "Next steps: setup UTM and DNS" (maybe store DNS settings in private repo)
|
|
||||||
-> todo: Add WindowTagger automatically too. In the meantime, echo it and reference to the repo.
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# For LinuxVM
|
This builds for the host machine's architecture. The package should follow this format:
|
||||||
## Create VM
|
|
||||||
### MacOS host with UTM
|
|
||||||
- Download the ISO for architecture ARM64.
|
|
||||||
- Create the VM with UTM.
|
|
||||||
- It is recommended to setup local DNS with `dnsmasq`.
|
|
||||||
|
|
||||||
### Other hosts
|
|
||||||
- Download the ISO for architecture AMD64.
|
|
||||||
- Setup Proxmox and create the VM.
|
|
||||||
|
|
||||||
## Setup VM
|
|
||||||
```
|
```
|
||||||
$ git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git .dotfiles
|
nvim-linux-$(dpkg --print-architecture).deb
|
||||||
$ cd .dotfiles
|
|
||||||
$ ./manage.py setup linux-vm --hostname <personal|university|client>-<utm|workstation>
|
|
||||||
-> execute: ./scripts/linux-setup_sudoers.sh
|
|
||||||
-> execute: mkdir /home/$USER/projects
|
|
||||||
-> execute: ./scripts/linux-setup_docker.sh
|
|
||||||
-> execute: ./scripts/linux-change_hostname.sh --hostname $HOSTNAME
|
|
||||||
-> execute: ./scripts/setup_ssh.sh -C $USER@HOSTNAME -f "" (-f: id_ed25519)
|
|
||||||
-> run: ./manage.py install linux-vm
|
|
||||||
-> run: ./manage.py link linux-vm
|
|
||||||
-> from shared: git, zsh, tmux, nvim-simple
|
|
||||||
-> echo: "You ssh pub key is: ". do not forget to change from https to git
|
|
||||||
-> echo: "use `dev` for bla bla"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# For LinuxDev
|
Create a new release in the mirrored repository and attach the `.deb` file.
|
||||||
Build with multi-stage.
|
|
||||||
|
|
||||||
## base-debian
|
### Proxmox
|
||||||
### Stage 1 - Setup NeoVim
|
|
||||||
```
|
|
||||||
RUN apt install python3
|
|
||||||
RUN git clone https://gitea.tomastm.com/tomas.mirchev/dotfiles.git .dotfiles \
|
|
||||||
&& cd .dotfiles \
|
|
||||||
&& ./manage.py setup linux-dev
|
|
||||||
-> wget tree-sitter && move (check architecture)
|
|
||||||
-> wget nvim.deb && install (check architecture)
|
|
||||||
-> nvim !lazy restore plugins
|
|
||||||
```
|
|
||||||
### Stage 2
|
|
||||||
- copy-from: .dotfiles & `./setup.py --env-linux-c --copy`
|
|
||||||
- copy-from: tree-sitter
|
|
||||||
- copy-from: `nvim.deb` & `apt install ./nvim.deb`
|
|
||||||
- copy-from: .local/share/nvim
|
|
||||||
- Setup locales (check debian setup)
|
|
||||||
- Create dev user
|
|
||||||
- Create workspace directory
|
|
||||||
|
|
||||||
## node
|
UTM is the preferred VM solution, but Proxmox can be used for homelab setups.
|
||||||
|
|
||||||
## python
|
To fix `apt update/upgrade` issues:
|
||||||
|
|
||||||
|
1. Go to "Datacenter" → "workstation" → "Repositories".
|
||||||
|
2. Disable both enterprise sources.
|
||||||
|
3. Add a new repository with "No-Subscription".
|
||||||
|
4. Refresh "Updates" and proceed.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user