Public fork of the original cachix/secretspec GitHub project; original credit belongs to its creators.
  • Rust 98.1%
  • Shell 1.1%
  • Nix 0.8%
Find a file
Kenny (Knight) Sheridan 95be8f84e8
Some checks failed
Test / tests (macos-latest) (push) Has been cancelled
Test / tests (ubuntu-latest) (push) Has been cancelled
Add upstream attribution to README
2026-05-26 23:30:11 -07:00
.claude Release v0.1.2 2025-07-17 13:21:08 -05:00
.github/workflows ci: update actions and fix outdated nix installer 2025-08-25 17:34:44 +02:00
docs Add GCP provider URI alias 2026-05-26 23:22:46 -07:00
examples/derive deps: remove unused dependencies 2026-01-28 19:03:17 +01:00
secretspec Add upstream attribution to README 2026-05-26 23:30:11 -07:00
secretspec-derive deps: remove unused dependencies 2026-01-28 19:03:17 +01:00
tests feat: add pass (password-store) provider 2025-12-20 11:47:51 -07:00
.envrc initial commit 2025-07-04 16:38:16 -05:00
.gitignore Add validation for undefined secrets in set command 2025-07-07 12:26:34 -05:00
Cargo.lock perf(onepassword): cache auth and batch fetch secrets 2026-01-29 22:10:47 +00:00
Cargo.toml perf(onepassword): cache auth and batch fetch secrets 2026-01-29 22:10:47 +00:00
CHANGELOG.md Add GCP provider URI alias 2026-05-26 23:22:46 -07:00
CLAUDE.md CLAUDE: tweak changelog entries instructions 2026-01-15 10:42:33 +01:00
devenv.lock deps: bump nixpkgs to stable 2026-01-28 18:56:01 +01:00
devenv.nix refactor: simplify SDK API by removing provider/profile parameters 2025-07-17 17:08:06 -05:00
devenv.yaml deps: bump nixpkgs to stable 2026-01-28 18:56:01 +01:00
dist-workspace.toml ci: update macOS runners from deprecated macos-13 to macos-15 2026-01-02 17:08:45 +01:00
flake.lock Add flake.nix for Nix integration 2026-02-07 22:19:54 -08:00
flake.nix fix: use apple-sdk_15 for modern nixpkgs-unstable 2026-02-21 14:28:45 -08:00
LICENSE add LICENSE 2025-07-07 23:45:56 -05:00
README.md let's try symlinking README.md to secretspec/README.md 2025-07-16 18:35:08 -05:00
secretspec.toml refactor: export Provider trait and update with_provider in derive macro 2025-07-24 23:32:11 -05:00

Build Status Crates.io docs.rs Discord channel

SecretSpec

This is my public fork for provider/backend experiments. SecretSpec is the work of the original cachix/secretspec creators and maintainers; all upstream credit belongs to them.

Declarative secrets, every environment, any provider.

SecretSpec separates the declaration of what secrets an application needs from where they are stored, enabling portable applications that work across different secret storage backends without code changes.

Documentation | Quick Start | Announcement Blog Post

Features

Quick Start

# 1. Initialize secretspec.toml (discovers secrets from .env)
$ secretspec init
✓ Created secretspec.toml with 0 secrets

Next steps:
  1. secretspec config init    # Set up user configuration
  2. secretspec check          # Verify all secrets are set
  3. secretspec run -- your-command  # Run with secrets

# 2. Set up provider backend
$ secretspec config init
? Select your preferred provider backend:
> onepassword: OnePassword password manager
  dotenv: Traditional .env files
  env: Read-only environment variables
  gcsm: Google Cloud Secret Manager
  keyring: Uses system keychain (Recommended)
  lastpass: LastPass password manager
  pass: Unix password manager (GPG)
? Select your default profile:
> development
  default
  none
✓ Configuration saved to /home/user/.config/secretspec/config.toml

# 3. Check and configure secrets
$ secretspec check

# 4. Run your application with secrets
$ secretspec run -- npm start

# Or with a specific profile and provider
$ secretspec run --profile production --provider dotenv -- npm start

See the Quick Start Guide for detailed instructions.

Installation

$ curl -sSL https://install.secretspec.dev | sh

See the installation guide for more options including Nix and Devenv.

Configuration

Each project has a secretspec.toml file that declares the required secrets:

[project]
name = "my-app"  # Inferred from current directory name when using `secretspec init`
revision = "1.0"
# Optional: extend other configuration files
extends = ["../shared/common", "../shared/auth"]

[profiles.default]
DATABASE_URL = { description = "PostgreSQL connection string", required = true }
REDIS_URL = { description = "Redis connection string", required = false, default = "redis://localhost:6379" }

# Profile-specific configurations
[profiles.development]
DATABASE_URL = { description = "PostgreSQL connection string", required = false, default = "sqlite://./dev.db" }
REDIS_URL = { description = "Redis connection string", required = false, default = "redis://localhost:6379" }

[profiles.production]
DATABASE_URL = { description = "PostgreSQL connection string", required = true }
REDIS_URL = { description = "Redis connection string", required = true }

See the configuration reference for all available options.

Profiles

Profiles allow you to define different secret requirements for each environment (development, production, etc.):

$ secretspec run --profile development -- npm start
$ secretspec run --profile production -- npm start

# Set default profile
$ secretspec config init

Learn more about profiles and profile selection.

Providers

SecretSpec supports multiple storage backends for secrets:

$ secretspec run --provider keyring -- npm start
$ secretspec run --provider dotenv -- npm start

# Configure default provider
$ secretspec config init

See provider concepts and provider reference for details.

Rust SDK

Generate strongly-typed Rust structs from your secretspec.toml:

secretspec_derive::declare_secrets!("secretspec.toml");

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load secrets with type safety
    let secrets = SecretSpec::load(Provider::Keyring)?;

    // Access secrets as struct fields
    println!("Database: {}", secrets.database_url);

    // Optional secrets are Option<String>
    if let Some(redis) = &secrets.redis_url {
        println!("Redis: {}", redis);
    }

    Ok(())
}

See the Rust SDK documentation for advanced usage including profile-specific types.

CLI Reference

Common commands:

# Initialize and configure
secretspec init                    # Create secretspec.toml
secretspec config init            # Set up user configuration

# Manage secrets
secretspec check                  # Verify all secrets are set
secretspec set KEY               # Set a secret interactively
secretspec get KEY               # Retrieve a secret
secretspec import PROVIDER       # Import secrets from another provider

# Run with secrets
secretspec run -- command        # Run command with secrets as env vars

See the full CLI reference for all commands and options.

Contributing

We welcome contributions! Areas where you can help:

  • New provider backends - See the provider implementation guide
  • Language SDKs - Help us support more languages beyond Rust
  • Package managers - Get SecretSpec into your favorite package manager
  • Documentation - Improve guides and examples

See our GitHub repository to get started.

License

This project is licensed under the Apache License 2.0.