Skip to content

sops wrapper with eval of .sops.nix as .sops.yaml #938

Description

@itzwam
#!/usr/bin/env bash

set -euo pipefail

set -x

NIX_RULES="$(readlink -f ./.sops.nix)"
SOPS_RULES="/tmp/sopsnix_$(pwd | sha1sum | cut -d' ' -f1)"

nix eval --json -v -f $NIX_RULES --apply 'creation_rules: if builtins.isList creation_rules then { inherit creation_rules; } else throw "Unknown format for secrets.nix"' | yq -r . > "$SOPS_RULES.$$"
if ! diff --color -uN $SOPS_RULES $SOPS_RULES.$$; then
  mv $SOPS_RULES.$$ $SOPS_RULES
else
  rm $SOPS_RULES.$$
fi

SOPS_CONFIG="$SOPS_RULES" exec sops "$@"

something like that, so that we could be able to declare the secrets settings / keys directly from Nix
or I may have missed something about the module

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions