193 lines
8.8 KiB
Cheetah
193 lines
8.8 KiB
Cheetah
{{- $name := "Brian Zalewski" -}}
|
|
{{- $email := "brian@megabyte.space" -}}
|
|
{{- $restricted := false -}}
|
|
{{- $work := false -}}
|
|
{{- $gpgKeyId := "0xF0A300E4199A1C33" -}}
|
|
{{- $gmailAddress := "blzalewski@gmail.com" -}}
|
|
{{- $gmailAddressAppPassword := "" -}}
|
|
{{- $domain := "megabyte.space" -}}
|
|
{{- $cloudflareUsername := "brian@megabyte.space" -}}
|
|
{{- $cloudflareToken := "" -}}
|
|
{{- $cloudflareAccessKeyId := "" -}}
|
|
{{- $cloudflareSecretAccessKey := "" -}}
|
|
{{- $cloudflareR2AccountId := "" -}}
|
|
{{- $githubUsername := "ProfessorManhattan" -}}
|
|
{{- $githubReadToken := "" -}}
|
|
{{- $gitlabReadToken := "" -}}
|
|
{{- $locale := (output "echo" "$LANG") }}
|
|
{{- $ngrokAuthToken := "" -}}
|
|
{{- $slackApiToken := "" -}}
|
|
{{- $tabbyConfigId := "" -}}
|
|
{{- $tabbySyncToken := "" -}}
|
|
{{- $timezone := "America/New_York" -}}
|
|
{{- $toolchains := list "docker" "iac" "java" "kubernetes" "node" "python" "rust" "extra" "gpg" -}}
|
|
|
|
{{- $data := . }}
|
|
{{- $_ := set $data "host" (default (dict) (get $data "host")) -}}
|
|
{{- $_ := set $data "user" (default (dict) (get $data "user")) -}}
|
|
{{- $_ := set $data "toolchains" (default (dict) (get $data "toolchains")) -}}
|
|
|
|
{{- $headless := false -}}
|
|
{{- $ephemeral := false -}}
|
|
{{/* detect GitHub codespaces, VSCode remote containers, Docker containers, Multipass VMs, and Vagrant boxes */}}
|
|
{{- $ephemeralEnvOrUsername := or (env "CODESPACES") (env "REMOTE_CONTAINERS_IPC") (eq .chezmoi.username "root" "ubuntu" "vagrant" "vscode" "devcontainer") -}}
|
|
{{- $ephemeralCgroup := and (stat "/proc/1/cgroup") (output "cat" "/proc/1/cgroup" | regexMatch "(docker|lxc)") -}}
|
|
{{- if or $ephemeralEnvOrUsername $ephemeralCgroup -}}
|
|
{{- $headless = true -}}
|
|
{{- $ephemeral = true -}}
|
|
{{- writeToStdout "Chezmoi is running in a container.\n" -}}
|
|
{{- end -}}
|
|
|
|
{{- $chassisType := "desktop" }}
|
|
{{- if $ephemeral -}}
|
|
{{- $chassisType = "ephemeral" }}
|
|
{{- else if eq .chezmoi.os "linux" }}
|
|
{{- if (.chezmoi.kernel.osrelease | lower | contains "microsoft") -}}
|
|
{{- $chassisType = "wsl" }}
|
|
{{- else -}}
|
|
{{- $chassisType = (output "hostnamectl" "--json=short" | mustFromJson).Chassis }}
|
|
{{- end -}}
|
|
{{- else if eq .chezmoi.os "darwin" }}
|
|
{{- if contains "MacBook" (output "sysctl" "-n" "hw.model") }}
|
|
{{- $chassisType = "laptop" }}
|
|
{{- else }}
|
|
{{- $chassisType = "desktop" }}
|
|
{{- end }}
|
|
{{- else if eq .chezmoi.os "windows" }}
|
|
{{- $chassisType = (output "powershell.exe" "-noprofile" "-command" "if (Get-WmiObject -Class win32_battery -ComputerName localhost) { echo laptop } else { echo desktop }") }}
|
|
{{- end }}
|
|
|
|
{{- $cpuCores := 1 }}
|
|
{{- $cpuThreads := 1 }}
|
|
{{- if eq .chezmoi.os "darwin" }}
|
|
{{- $cpuCores = (output "sysctl" "-n" "hw.physicalcpu_max") | trim | atoi }}
|
|
{{- $cpuThreads = (output "sysctl" "-n" "hw.logicalcpu_max") | trim | atoi }}
|
|
{{- else if eq .chezmoi.os "linux" }}
|
|
{{- $cpuCores = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | sort --field-separator=',' --key='2,4' --unique | wc --lines") | trim | atoi }}
|
|
{{- $cpuThreads = (output "sh" "-c" "lscpu --online --parse | grep --invert-match '^#' | wc --lines") | trim | atoi }}
|
|
{{- else if eq .chezmoi.os "windows" }}
|
|
{{- $cpuCores = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfCores") | trim | atoi }}
|
|
{{- $cpuThreads = (output "powershell.exe" "-NoProfile" "-NonInteractive" "-Command" "(Get-CimInstance -ClassName 'Win32_Processor').NumberOfLogicalProcessors") | trim | atoi }}
|
|
{{- end }}
|
|
|
|
{{- $toolchainsEnabled := dict }}
|
|
{{- range $toolchain := $toolchains }}
|
|
{{- $withoutToolchains := env "WITHOUT_TOOLCHAINS" -}}
|
|
{{- $withoutToolchain := env (list "WITHOUT" (upper $toolchain) | join "_") -}}
|
|
{{- $withToolchain := env (list "WITH" (upper $toolchain) | join "_") -}}
|
|
{{- if and (or $withoutToolchains $withoutToolchain) (not $withToolchain) -}}
|
|
{{- writeToStdout (list "Disabled" $toolchain "toolchain.\n" | join " ") -}}
|
|
{{- $_ := set $toolchainsEnabled $toolchain false }}
|
|
{{- else }}
|
|
{{- $_ := set $toolchainsEnabled $toolchain true }}
|
|
{{- end}}
|
|
{{- end }}
|
|
|
|
{{- if stdinIsATTY -}}
|
|
|
|
{{- $work = promptBoolOnce $data.host "work" "Work Environment" $work -}}
|
|
{{- $restricted = promptBoolOnce $data.host "restricted" "Restricted Environment (no sudo access)" $restricted -}}
|
|
{{- $name = promptStringOnce $data.user "name" "Your Name" $name -}}
|
|
{{- $email = promptStringOnce $data.user "email" "Your Email" $email -}}
|
|
|
|
{{- range $toolchain := $toolchains }}
|
|
{{- $enabled := promptBoolOnce $data.toolchains $toolchain (list "Enable" $toolchain "toolchain" | join " ") (get $toolchainsEnabled $toolchain) -}}
|
|
{{- if and (eq $toolchain "kubernetes") $enabled (not $toolchainsEnabled.docker) -}}
|
|
{{- $_ := set $toolchainsEnabled "docker" $enabled }}
|
|
{{- writeToStdout "Enabled Docker toolchain to support Kubernetes.\n" -}}
|
|
{{- end -}}
|
|
{{- $_ := set $toolchainsEnabled $toolchain $enabled }}
|
|
{{- end }}
|
|
|
|
{{- $gpgKeyId = promptStringOnce $data.user "gpgKeyId" "Public GPG key ID" $gpgKeyId -}}
|
|
{{- $domain = promptStringOnce $data.user "domain" "Domain" $domain -}}
|
|
{{- $timezone = promptStringOnce $data.user "timezone" "Timezone" $timezone -}}
|
|
{{- $cloudflareToken = promptStringOnce $data.user "cloudflareToken" "CloudFlare API Token" $cloudflareToken -}}
|
|
{{- $githubUsername = promptStringOnce $data.user "githubUsername" "GitHub username" $githubUsername -}}
|
|
{{- $gitlabReadToken = promptStringOnce $data.user "gitlabReadToken" "GitLab read-only token (See: https://github.com/gabrie30/ghorg#scm-provider-setup)" $gitlabReadToken }}
|
|
{{- $githubReadToken = promptStringOnce $data.user "githubReadToken" "GitHub read-only token (See: https://github.com/gabrie30/ghorg#scm-provider-setup)" $githubReadToken }}
|
|
{{- $gmailAddress = promptStringOnce $data.user "gmailAddress" "G-mail address" $gmailAddress -}}
|
|
{{- $gmailAddressAppPassword = promptStringOnce $data.user "gmailAddressAppPassword" "G-mail app password" $gmailAddressAppPassword -}}
|
|
{{- $ngrokAuthToken = promptStringOnce $data.user "ngrokAuthToken" "Ngrok authentication token" $ngrokAuthToken -}}
|
|
{{- $slackApiToken = promptStringOnce $data.user "slackApiToken" "Slack API token" $slackApiToken -}}
|
|
{{- $tabbyConfigId = promptStringOnce $data.user "tabbyConfigId" "Tabby Configuration ID" $tabbyConfigId -}}
|
|
{{- $tabbySyncToken = promptStringOnce $data.user "tabbySyncToken" "Tabby Sync Token" $tabbySyncToken -}}
|
|
|
|
{{- else -}}
|
|
{{- $headless = true -}}
|
|
{{- writeToStdout "Chezmoi is running in headless environment.\n" -}}
|
|
{{- end -}}
|
|
|
|
encryption: "age"
|
|
age:
|
|
identity: "{{ .chezmoi.homeDir }}/.config/age/chezmoi.txt"
|
|
recipient: "age1necy24c4lzxheey4p2m8v4q000n442wyv47qc640ulyxx9l8dpesdqv7ey"
|
|
gpg:
|
|
recipient: "{{ $gpgKeyId }}"
|
|
data:
|
|
host:
|
|
arch: "{{ .chezmoi.arch }}"
|
|
cpu:
|
|
cores: "{{ $cpuCores }}"
|
|
threads: "{{ $cpuThreads }}"
|
|
distro:
|
|
family: "{{ .chezmoi.os }}"
|
|
id: "{{ get .chezmoi.osRelease "id" | default .chezmoi.os }}"
|
|
home: "{{ .chezmoi.homeDir }}"
|
|
homeParentFolder: "{{ if eq .chezmoi.os "linux" }}/home{{ else if eq .chezmoi.os "darwin" }}/Users{{ else }}C:\Users{{ end }}"
|
|
qubes: {{ ne (stat (joinPath "usr" "bin" "qubes-session")) false }}
|
|
softwareGroup: "terminal"
|
|
type: "{{ $chassisType }}"
|
|
work: {{ $work }}
|
|
restricted: {{ $restricted }}
|
|
headless: {{ $headless }}
|
|
toolchains:
|
|
{{- range $toolchain, $enabled := $toolchainsEnabled }}
|
|
{{ $toolchain}}: {{ $enabled }}
|
|
{{- end }}
|
|
user:
|
|
email: "{{ $email }}"
|
|
name: "{{ $name }}"
|
|
username: "{{ output "echo" "$USER" }}"
|
|
domain: "{{ $domain }}"
|
|
gpg:
|
|
id: "{{ $gpgKeyId }}"
|
|
gmail:
|
|
email: "{{ $gmailAddress }}"
|
|
password: "{{ $gmailAddressAppPassword }}"
|
|
githubUsername: "{{ $githubUsername }}"
|
|
locale: "{{ $locale }}"
|
|
timezone: "{{ $timezone }}"
|
|
CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}"
|
|
CLOUDFLARE_ACCESS_KEY_ID: "{{ $cloudflareAccessKeyId }}"
|
|
CLOUDFLARE_SECRET_ACCESS_KEY: "{{ $cloudflareSecretAccessKey }}"
|
|
CLOUDFLARE_R2_ACCOUNT_ID: "{{ $cloudflareR2AccountId }}"
|
|
CLOUDSDK_CORE_PROJECT: "megabyte-labs"
|
|
GCE_CREDENTIALS_FILE: "{{ joinPath .chezmoi.homeDir ".config" "gcp.json" }}"
|
|
GCE_SERVICE_ACCOUNT_EMAIL: "molecule@megabyte-labs.iam.gserviceaccount.com"
|
|
GITHUB_READ_TOKEN: "{{ $githubReadToken }}"
|
|
GITLAB_READ_TOKEN: "{{ $gitlabReadToken }}"
|
|
NGROK_AUTH_TOKEN: "{{ $ngrokAuthToken }}"
|
|
SLACK_API_TOKEN: "{{ $slackApiToken }}"
|
|
SNAPCRAFT_EMAIL: "{{ $email }}"
|
|
TABBY_CONFIG_ID: "{{ $tabbyConfigId }}"
|
|
TABBY_SYNC_TOKEN: "{{ $tabbySyncToken }}"
|
|
TINYPNG_API_KEY: "g355tx7dxG5yJfl0RXJnpQlQqk88dJBv"
|
|
diff:
|
|
format: "git"
|
|
pager: "delta"
|
|
git:
|
|
autoCommit: true
|
|
autoPush: true
|
|
scriptEnv:
|
|
LEXICON_CLOUDFLARE_USERNAME: "{{ $cloudflareUsername }}"
|
|
LEXICON_CLOUDFLARE_TOKEN: "{{ $cloudflareToken }}"
|
|
textconv:
|
|
- pattern: "**/*.plist"
|
|
command: "plutil"
|
|
args:
|
|
- "-convert"
|
|
- "xml1"
|
|
- "-o"
|
|
- "-"
|
|
- "-"
|