Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: diff *.age files #177

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,52 @@ but, if you want to (change the system based on your system):
};
}
```
7. NixOS rebuild or use your deployment tool like usual.
7. (Optional) Setup git to decrypt `*.age` files when showing diffs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should insert optional steps in the tutorial. It is hard enough to follow as is. I'd be okay with adding this as a separate section though!

between versions:

- Add a script that decrypts `*.age` files using the configured
`age.identityPaths` to your `configuration.nix`:

```nix
{ pkgs, ... }:

{
environment.systemPackages = let
rage-textconv = with pkgs;
writeShellApplication {
name = "rage-textconv";
runtimeInputs = [ rage ];
text = ''
rage --decrypt "$1" ${
lib.strings.concatMapStringsSep " "
(path: "-i ${lib.strings.escapeShellArg path}")
config.age.identityPaths
}
'';
};
in [ rage-textconv ];
}
```

- Create a `.gitattributes` file at the root of your repository that
sets a `diff` driver for `*.age` files:

```text
*.age diff=rage
```

- Map the `rage` driver to the previously defined `rage-textconv` script:

```ShellSession
$ git config diff.rage.textconv rage-textconv
```

With this in place, calls to `git diff` will decrypt both previous
and current versions of the target file prior to displaying the diff.
And it even works with git client interfaces, because they call git
diff under the hood!

8. NixOS rebuild or use your deployment tool like usual.

The secret will be decrypted to the value of `config.age.secrets.secret1.path` (`/run/agenix/secret1` by default).

Expand Down