sync-env-file
Generate a local .env from chezmoi templates and Azure Key Vault secrets.
Why it exists
Local development often needs a .env file with a mix of committed defaults and secrets from a vault. Teams usually solve this with one-off shell scripts that are hard to reuse across projects.
sync-env-file provides a small, generic CLI that:
- Keeps templates under version control via chezmoi
- Pulls secrets from Azure Key Vault at render time
- Writes a single repo-root
.envwith one command
No bespoke scripts, no copy-pasted vault logic.
Installation
Recommended: uvx (no project dependency)
Requires uv. uvx runs the CLI from an isolated Python 3.9+ environment, so the project does not need this package as a dependency:
uvx sync-env-file init
uvx sync-env-file
Other install options
From PyPI:
pip install sync-env-file
As a project dependency with uv:
uv add sync-env-file
Requires Python 3.9+, chezmoi, and the Azure CLI (external tools — not installed by the package or uvx).
Quick start
With uvx (no project dependency):
uvx sync-env-file init
# Edit .chezmoi/chezmoi.toml and .chezmoi/private_dot_env.tmpl
az login
uvx sync-env-file
If installed via pip or uv add, omit the uvx prefix:
sync-env-file init
# Edit .chezmoi/chezmoi.toml and .chezmoi/private_dot_env.tmpl
az login
sync-env-file
API overview
| Command | Description |
|---|---|
sync-env-file |
Same as sync-env-file sync |
sync-env-file sync |
Render .env from .chezmoi/ templates (requires az login) |
sync-env-file init |
Scaffold .chezmoi/chezmoi.toml, private_dot_env.tmpl, and .gitignore entries |
sync-env-file init --force |
Overwrite existing scaffold files |
Exit codes: 0 on success, non-zero on tool errors (missing chezmoi/az, no active Azure account, chezmoi apply failure).
Configuration
After init, edit two files under .chezmoi/:
chezmoi.toml
Sets the default Key Vault name:
[azureKeyVault]
defaultVault = "your-vault-name"
sync-env-file passes --config, --source, and --destination to chezmoi so paths stay repo-relative.
private_dot_env.tmpl
Defines the rendered .env content. Use chezmoi's azureKeyVault template function for secrets:
APP_BASE_URL=https://api.example.com
APP_API_KEY={{ azureKeyVault "example-api-key" | quote }}
See examples/minimal-consumer/.chezmoi/private_dot_env.tmpl for additional patterns (connection strings, optional passthrough variables).
Extended example
See examples/minimal-consumer/ for a full PyPI-first consumer project (not shipped in the wheel).
Limitations
- Requires chezmoi and Azure CLI installed and on
PATH - Secrets are fetched from Azure Key Vault only (no AWS/GCP vaults)
- Renders a single target file: repo-root
.env - Requires an active Azure account with RBAC read access to the configured vault
- Does not manage chezmoi installation, vault provisioning, or secret rotation
Roadmap
- Optional support for additional secret backends (if demand exists)
- Richer scaffold templates for common connection-string patterns
Development
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run mypy .
CI and the advisory semantic-version check run on GitHub-hosted ubuntu-latest
runners with read-only repository permissions. Public pull requests do not need
access to the organization's self-hosted runners. The manual PyPI release
workflow is managed separately; see the release instructions below.
Releasing
Releases are published to PyPI from the GitHub Actions workflow in this repository; the steps are in CONTRIBUTING.
How to contribute
See CONTRIBUTING for issue reporting, development setup, and pull request guidelines.
Maintainers
- @arog-lahcim — primary maintainer
License
Apache License 2.0 — see LICENSE.
Metadata
Release files for sync-env-file 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sync_env_file-0.1.1.tar.gz | 10.1 kB | Without provenance | Details for sync_env_file-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sync_env_file-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for sync_env_file-0.1.1-py3-none-any.whl |
Total release size: 23.4 kB
Release files / sync_env_file-0.1.1.tar.gz
| Download URL | sync_env_file-0.1.1.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42dc3411f645362f257fface15717b8135e00625f3620933fcc05c44965e16c2
|
|
BLAKE2b-256 checksum How to use checksums |
1cb6cb96c01f996c3715a64cd1fbba8d603e1c095c1ed1ed1d1f5ddb85912853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sync_env_file-0.1.1-py3-none-any.whl
| Download URL | sync_env_file-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
053e0ecc92e00a8e59d8ffa886c40a7c34374a39601610f6099e4c3361ffe206
|
|
BLAKE2b-256 checksum How to use checksums |
677174244835294ced1b369b89a9b684d58627a61c511ba086e5798640fc844e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sync-env-file 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.