diff --git a/doc/guides/keys.md b/doc/guides/keys.md index 142e5ad..de0b6f3 100644 --- a/doc/guides/keys.md +++ b/doc/guides/keys.md @@ -18,6 +18,7 @@ The `source` of your key can be a literal string (unencrypted), a path work well with wire keys include: - GPG +- [sops](https://github.com/getsops/sops) ([Example](#encrypting-with-sops)) - [Age](https://github.com/FiloSottile/age) - Anything that non-interactively decrypts to `stdout`. @@ -94,6 +95,21 @@ in wire.makeHive { Hello World! ``` +### Encrypting with Sops + +With some sops file: + +```yaml:line-numbers [secret.yaml] +hive: + some_secret: XXXXXXXXXXXXXXXXXXXXXXX +something: + another_secret: XXXXXXXXXXXXXXXXXXXXXXX +``` + +You can easily create a function to grab values out of your encrypted sops file: + +<<< @/snippets/guides/sops-example.nix [hive.nix] + ### Encrypting with KeepassXC A simple example of extracting a KeepassXC attachment into a wire key. diff --git a/doc/snippets/guides/sops-example.nix b/doc/snippets/guides/sops-example.nix new file mode 100644 index 0000000..6309484 --- /dev/null +++ b/doc/snippets/guides/sops-example.nix @@ -0,0 +1,33 @@ +let + sources = import ./npins; + wire = import sources.wire; +in + wire.makeHive { + meta.nixpkgs = import sources.nixpkgs {}; + + node-1 = {lib, ...}: let + mkSops = key: [ + "sops" + "-d" + "--extract" + (lib.concatMapStrings (segment: ''["${segment}"]'') key) + "${./secrets.yaml}" + ]; + in { + deployment.key = { + "some_secret.txt" = { + source = mkSops [ + "hive" + "some_secret" + ]; + }; + + "another_secret.txt" = { + source = mkSops [ + "something" + "another_secret" + ]; + }; + }; + }; + }