working version

This commit is contained in:
2026-02-13 12:15:46 +02:00
parent 1217337fbb
commit 6cff65f288
37 changed files with 2232 additions and 1872 deletions

View File

@@ -1,27 +1,27 @@
# Example working scenario
This folder contains a complete, practical dotfiles + bootstrap setup that exercises most `flow`
features.
This folder contains a complete dotfiles + bootstrap setup for the current `flow` schema.
## What this example shows
- Dotfiles repository layout with `common/` packages and `profiles/work/` overrides
- Self-hosted `flow` config + manifest in `common/flow/.config/flow/`
- Bootstrap profiles for Linux (auto PM detection), Ubuntu (`apt`), Fedora (`dnf`), and macOS
(`brew`)
- Bootstrap actions: `requires`, `hostname`, `locale`, `shell`, package install, binary install,
`ssh_keygen`, `configs`, and `runcmd`
- Package name mapping via `package-map` (`apt`/`dnf`/`brew`)
- Dotfiles repo workflows: `status`, `pull`, `push`, `sync --relink`, and `edit`
- Flat repo-root layout with reserved dirs:
- `_shared/` (shared configs)
- `_root/` (root-targeted configs)
- profile dirs (`linux-auto/`, `macos-dev/`)
- Unified YAML config under `_shared/flow/.config/flow/*.yaml`
- Profile package list syntax: string, type prefix, and object entries
- Binary install definition with `asset-pattern`, `platform-map`, `extract-dir`, and `install`
- Required env vars, templating, SSH keygen, runcmd, post-link, and config skip patterns
## Layout
- `dotfiles-repo/common/flow/.config/flow/config` example `flow` config
- `dotfiles-repo/common/flow/.config/flow/manifest.yaml` profiles + package map + binaries
- `dotfiles-repo/common/zsh/.zshrc`, `common/git/.gitconfig`, `common/tmux/.tmux.conf`
- `dotfiles-repo/common/nvim/.config/nvim/init.lua`
- `dotfiles-repo/common/bin/.local/bin/flow-hello`
- `dotfiles-repo/profiles/work/git/.gitconfig` and `profiles/work/zsh/.zshrc` overrides
- `dotfiles-repo/_shared/flow/.config/flow/config.yaml`
- `dotfiles-repo/_shared/flow/.config/flow/packages.yaml`
- `dotfiles-repo/_shared/flow/.config/flow/profiles.yaml`
- `dotfiles-repo/_shared/...`
- `dotfiles-repo/_root/...`
- `dotfiles-repo/linux-auto/...`
- `dotfiles-repo/macos-dev/...`
## Quick start
@@ -35,7 +35,7 @@ Initialize and link dotfiles:
```bash
flow dotfiles init --repo "$EXAMPLE_REPO"
flow dotfiles link
flow dotfiles link --profile linux-auto
flow dotfiles status
```
@@ -43,15 +43,15 @@ Check repo commands:
```bash
flow dotfiles repo status
flow dotfiles repo pull --relink
flow dotfiles repo pull --relink --profile linux-auto
flow dotfiles repo push
```
Edit package or file/path targets:
```bash
flow dotfiles edit zsh --no-commit
flow dotfiles edit common/flow/.config/flow/manifest.yaml --no-commit
flow dotfiles edit git --no-commit
flow dotfiles edit _shared/flow/.config/flow/profiles.yaml --no-commit
```
Inspect bootstrap profiles and package resolution:
@@ -59,20 +59,13 @@ Inspect bootstrap profiles and package resolution:
```bash
flow bootstrap list
flow bootstrap packages --resolved
flow bootstrap packages --profile fedora-dev --resolved
flow bootstrap packages --profile linux-auto --resolved
flow bootstrap show linux-auto
```
Run bootstrap in dry-run mode:
Run bootstrap dry-run:
```bash
flow bootstrap run --profile linux-auto --var TARGET_HOSTNAME=devbox --var USER_EMAIL=you@example.com --dry-run
flow bootstrap run --profile work-linux --var WORK_EMAIL=you@company.com --dry-run
flow bootstrap run --profile macos-dev --dry-run
```
## Manifest notes
- `linux-auto` omits `package-manager` to demonstrate auto-detection.
- `ubuntu-dev` uses legacy `packages.package` key to show compatibility.
- `package-map` rewrites logical names like `fd` and `python-dev` per package manager.
- If mapping is missing for the selected manager, `flow` uses the original package name and warns.

View File

@@ -0,0 +1 @@
{{ env.TARGET_HOSTNAME }}

View File

@@ -0,0 +1,3 @@
#!/usr/bin/env sh
echo "custom root script"

View File

@@ -0,0 +1,15 @@
repository:
dotfiles-url: /ABSOLUTE/PATH/TO/flow-cli/example/dotfiles-repo
dotfiles-branch: main
paths:
projects-dir: ~/projects
defaults:
container-registry: registry.example.com
container-tag: latest
tmux-session: default
targets:
personal: orb personal.orb
work@ec2: work.internal ~/.ssh/id_work

View File

@@ -0,0 +1,37 @@
packages:
- name: fd
type: pkg
sources:
apt: fd-find
dnf: fd-find
brew: fd
- name: ripgrep
type: pkg
sources:
apt: ripgrep
dnf: ripgrep
brew: ripgrep
- name: wezterm
type: cask
sources:
brew: wezterm
- name: neovim
type: binary
source: github:neovim/neovim
version: "0.10.4"
asset-pattern: "nvim-{{os}}-{{arch}}.tar.gz"
platform-map:
linux-x64: { os: linux, arch: x64 }
linux-arm64: { os: linux, arch: arm64 }
darwin-arm64: { os: macos, arch: arm64 }
extract-dir: "nvim-{{os}}64"
install:
bin: [bin/nvim]
share: [share/nvim]
man: [share/man/man1/nvim.1]
- name: docker
type: pkg

View File

@@ -0,0 +1,39 @@
profiles:
linux-auto:
os: linux
requires: [TARGET_HOSTNAME, USER_EMAIL]
hostname: "{{ env.TARGET_HOSTNAME }}"
shell: zsh
packages:
- git
- tmux
- zsh
- fd
- ripgrep
- binary/neovim
- name: docker
allow_sudo: true
post-install: |
sudo groupadd docker || true
sudo usermod -aG docker $USER
ssh-keygen:
- type: ed25519
filename: id_ed25519
comment: "{{ env.USER_EMAIL }}"
configs:
skip: [tmux]
runcmd:
- mkdir -p ~/projects
- git config --global user.email "{{ env.USER_EMAIL }}"
post-link: |
echo "All configs linked."
echo "Restart your shell to apply changes."
macos-dev:
os: macos
shell: zsh
packages:
- git
- tmux
- cask/wezterm
- binary/neovim

View File

@@ -0,0 +1,4 @@
export EDITOR=vim
export PATH="$HOME/.local/bin:$PATH"
alias ll='ls -lah'

View File

@@ -1,15 +0,0 @@
[repository]
dotfiles_url = /ABSOLUTE/PATH/TO/flow-cli/example/dotfiles-repo
dotfiles_branch = main
[paths]
projects_dir = ~/projects
[defaults]
container_registry = registry.example.com
container_tag = latest
tmux_session = default
[targets]
personal = orb personal.orb
work@ec2 = work.internal ~/.ssh/id_work

View File

@@ -1,2 +0,0 @@
export FLOW_ENV=example
export FLOW_EDITOR=vim

View File

@@ -1,96 +0,0 @@
profiles:
linux-auto:
os: linux
requires: [TARGET_HOSTNAME, USER_EMAIL]
hostname: "$TARGET_HOSTNAME"
locale: en_US.UTF-8
shell: zsh
packages:
standard: [git, tmux, zsh, fd, ripgrep, python-dev]
binary: [neovim, lazygit]
ssh_keygen:
- type: ed25519
filename: id_ed25519
comment: "$USER_EMAIL"
configs: [flow, zsh, git, tmux, nvim, bin]
runcmd:
- mkdir -p ~/projects
- git config --global user.email "$USER_EMAIL"
ubuntu-dev:
os: linux
package-manager: apt
packages:
package: [git, tmux, zsh, fd, ripgrep, python-dev]
binary: [neovim]
configs: [flow, zsh, git, tmux]
fedora-dev:
os: linux
package-manager: dnf
packages:
standard: [git, tmux, zsh, fd, ripgrep, python-dev]
binary: [neovim]
configs: [flow, zsh, git, tmux]
macos-dev:
os: macos
package-manager: brew
packages:
standard: [git, tmux, zsh, fd, ripgrep]
cask: [wezterm]
binary: [neovim]
configs: [flow, zsh, git, nvim]
work-linux:
os: linux
package-manager: apt
requires: [WORK_EMAIL]
packages:
standard: [git, tmux, zsh]
configs: [git, zsh]
runcmd:
- git config --global user.email "$WORK_EMAIL"
package-map:
fd:
apt: fd-find
dnf: fd-find
brew: fd
python-dev:
apt: python3-dev
dnf: python3-devel
brew: python
ripgrep:
apt: ripgrep
dnf: ripgrep
brew: ripgrep
binaries:
neovim:
source: github:neovim/neovim
version: "0.10.4"
asset-pattern: "nvim-{{os}}-{{arch}}.tar.gz"
platform-map:
linux-amd64: { os: linux, arch: x86_64 }
linux-arm64: { os: linux, arch: arm64 }
macos-arm64: { os: macos, arch: arm64 }
install-script: |
curl -fL "{{downloadUrl}}" -o /tmp/nvim.tar.gz
tar -xzf /tmp/nvim.tar.gz -C /tmp
mkdir -p ~/.local/bin
cp /tmp/nvim-*/bin/nvim ~/.local/bin/nvim
lazygit:
source: github:jesseduffield/lazygit
version: "0.44.1"
asset-pattern: "lazygit_{{version}}_{{os}}_{{arch}}.tar.gz"
platform-map:
linux-amd64: { os: Linux, arch: x86_64 }
linux-arm64: { os: Linux, arch: arm64 }
macos-arm64: { os: Darwin, arch: arm64 }
install-script: |
curl -fL "{{downloadUrl}}" -o /tmp/lazygit.tar.gz
tar -xzf /tmp/lazygit.tar.gz -C /tmp
mkdir -p ~/.local/bin
cp /tmp/lazygit ~/.local/bin/lazygit

View File

@@ -1,8 +0,0 @@
export EDITOR=vim
export PATH="$HOME/.local/bin:$PATH"
alias ll='ls -lah'
if [ -f "$HOME/.config/flow/env.sh" ]; then
. "$HOME/.config/flow/env.sh"
fi

View File

@@ -0,0 +1,3 @@
[user]
name = Example Linux User
email = linux@example.com

View File

@@ -3,5 +3,3 @@ export PATH="$HOME/.local/bin:$PATH"
alias ll='ls -lah'
alias gs='git status -sb'
export WORK_MODE=1

View File

@@ -1,6 +0,0 @@
[user]
name = Example Work User
email = work@example.com
[url "git@github.com:work/"]
insteadOf = https://github.com/work/