CLI tool
ryantm/agenix avatar
ryantm/agenix

agenix keeps its access control in a Nix file of SSH keys

age-encrypted secrets for NixOS and Home manager

2,544 stars159 forksNixCC0-1.0

At a glance

What is it?
A Nix module and CLI that encrypt secrets with SSH public keys and decrypt them at activation time for NixOS and Home Manager. The repository pins one nixpkgs channel in its quick start, offers four installation methods, ships example fixtures whose filenames are the feature list, and published two minor releases eighty minutes apart.
Who is it for?
agenix is a good fit if your whole configuration is already in Nix and you want secrets to travel in the same repository as the code that consumes them, because the whole design is that encrypted files are ordinary Nix store paths and decryption happens on the target machine rather than at build time. Four things to weigh.
Can I use it commercially?
Yes. CC0-1.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 33 days ago.
What is it written in?
Mainly Nix, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 22, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • ryantm/agenix2,544 ★ · +44
Star history
Repository2026-09-302026-11-22
ryantm/agenix2.5k2.5k

44 Stars in the last 53 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Authorization is a Nix file listing the keys allowed per secret

The whole access control model is one file. In your secrets directory you create `agenix-rules.nix`, and in it you list the public SSH keys permitted to decrypt each encrypted file.

There is no separate role system, no group inheritance, and no per-environment distinction beyond which keys you name. Whoever holds a listed private key can read that secret, which is the entire basis of the authorization.

The CLI's job is to create and rekey those `.age` files. Creation looks like this:

bash
nix run github:ryantm/agenix -- -e example.age

Rekeying is the operation that matters operationally. Since access is expressed as a list of recipients baked into the ciphertext, rotating a key is not a matter of changing the rules file; you have to re-encrypt the file so the ciphertext carries the new recipient set, and remove the old one. Get that wrong and you have a rules file that grants access the ciphertext does not honour, or worse, a key you meant to retire still being able to read the data.

The front page describes one encryption mode only, SSH public keys. That is worth noticing against the example directory, which includes a fixture named for a password file. A filename mentioning a password does not establish the encryption method: it may simply hold a password as the secret. Consult the project documentation and configured recipients rather than inferring passphrase support from the filename.

One module option is the entire integration contract

A secret is declared in a NixOS module like this:

nix
{
  age.secrets.example.file = ./secrets/example.age;
  # Use config.age.secrets.example.path wherever a service expects a secret file.
}

Everything downstream depends on that second line of the comment. The module takes an encrypted file, decrypts it at activation time on the intended machine or user, and exposes the result as a path under `config.age.secrets.<name>.path`.

That is the whole integration story, and it is a good one. Any NixOS service that accepts a file path can consume an agenix secret without knowing anything about age, SSH keys, or decryption, because the service is handed a normal path that happens to be materialised by the activation process rather than committed to the store.

The ordering matters for anyone writing a service option. The encrypted source is declared in the configuration; the plaintext is materialised during activation. Services should consume the configured path after secret activation, rather than expecting plaintext in the Nix store during evaluation.

The same shape exists on the Home Manager side, and the documentation publishes a separate module reference for each, since the option namespaces differ between a machine and a user.

Four installation methods and three entry points at the root

The documentation publishes four separate installation guides, one each for flakes, niv, nix-channel, and fetchTarball, plus coverage of Home Manager installation.

Four ways to install one module is a lot, and each carries a different cost. A flake input is the modern route and gives you a lockfile. niv is a lighter dependency pinning tool. nix-channel is the older channel model, still needed if you are not using flakes at all. fetchTarball is the lowest common denominator that works anywhere.

The root directory explains why there are so many. There is a `flake.nix` and a `flake.lock` for the flake route, a `default.nix` for the classic expression route, and an `overlay.nix` alongside a `pkgs/` directory, which is what lets agenix be consumed as a package set rather than only as flake modules.

So the project is not opinionated about how you bring it in. That is considerate for a tool whose audience spans very different Nix setups, and it does mean that the quick start on the front page shows you exactly one of the four, the one where you are already using flakes.

The rest of the layout is conventional: `modules/` for the module implementations, `test/` for the test suite, `doc/` for the documentation sources, and a `contrib/` directory whose purpose the top-level listing does not spell out.

The example filenames are the feature list

There are six files under `example/`, and their names are more informative than any documentation would be.

There is a file called `-leading-hyphen-filename.age`. That is a regression fixture, and the thing it guards against is obvious once you see it: a filename beginning with a hyphen gets parsed as an option by any command-line tool that is not careful, so creating or rekeying such a file has to work. It is the kind of edge case that only gets a fixture after somebody hit it.

There is `armored-secret.age`, which says ASCII-armored output is supported rather than only the binary form. That matters because armored files are what you can paste into a ticket or a chat message without breaking the terminal.

There is `passwordfile-user1.age`, a filename suggesting that the encrypted content is a user password file. The filename alone does not establish that the file uses passphrase-based encryption.

Then there are `secret1.age` and `secret2.age`, which are the plain cases, and `secrets.nix`, which is the rules file tying recipients to them.

The repository also carries an `example_keys/` directory at the root. Given that the entire model is recipient keys, that directory is either the public keys used by these examples or a set of throwaway key pairs for testing, and the top-level listing does not say which.

Two minor releases eighty minutes apart

The three most recent tags are 0.18.0 from 2026-09-27, 0.17.0 from 2026-09-26 at 17:55, and 0.16.0 from 2026-09-26 at 16:35.

So two minor version bumps landed eighty minutes apart on the same afternoon, and a third minor bump the following day. Three minor releases in under two days.

For a project at version 0.x, minor bumps are how breaking changes get made, since there is no stability guarantee before 1.0. Reading a minor bump as a routine increment is the mistake this cadence invites. A module option can change shape, a CLI flag can change meaning, and a `pkgs/` overlay can move under you, all inside an eighty-minute window.

The default branch took its last push on 2026-10-02, a few days after that run of releases, so work continues and there will be more.

The version numbers are plain and the tags carry no suffix, which at least removes one source of ambiguity. What it does not remove is the decision you have to make about how you consume them: a flake input pinned to a specific revision behaves very differently from one following a branch, and this project's recent history makes that choice matter more than it would in a slower repository.

The quick start pins one nixpkgs channel and omits the threat model

The front page is short, and one line in it deserves a second look. The example flake sets its nixpkgs input to a specific channel rather than to a floating one:

nix
{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
  inputs.agenix.url = "github:ryantm/agenix";

  outputs = { nixpkgs, agenix, ... }: {
    nixosConfigurations.my-host = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [ agenix.nixosModules.default ./configuration.nix ];
    };
  };
}

That is a deliberate pin, and it is good practice in isolation. It is also the pin a reader will copy, which means a quick start copied verbatim ties a machine to one NixOS release channel rather than to whatever your configuration actually needs. The example also fixes the system to x86_64 Linux, so the same copy does not cover an aarch64 host.

What the front page does not do is mention the threat model. The documentation list includes a page titled for threat model and warnings, which is the first thing you would want to read before putting encryption in front of a deployment key, and the summary sentence above it says nothing about where keys live or what happens if one leaks.

The tutorial is linked too, and covers a complete rules file, key discovery, installation, and deployment. Between that and the two module references and the CLI reference, the actual documentation is thorough; it is simply all one click away from a page that is otherwise about four sentences long.

Editorial conclusion

agenix is a good fit if your whole configuration is already in Nix and you want secrets to travel in the same repository as the code that consumes them, because the whole design is that encrypted files are ordinary Nix store paths and decryption happens on the target machine rather than at build time. Four things to weigh. The model is SSH public keys only, so anyone holding a listed private key can read a secret, and the rules file is the complete access control list with no group or role concept. Protect each recipient private key on the host or authorised workstation where it is needed, and retain securely controlled recovery access. Avoid copying private keys into the world-readable Nix store. Read the threat model and warnings page before you adopt it, since the project publishes one deliberately. Expect to pin versions deliberately: three releases landed in two days, two of them eighty minutes apart, so a channel that follows the tip is not a stable base. And confirm CC0-1.0 is acceptable for your organisation, since a public-domain dedication is an unusual choice for infrastructure code and some compliance frameworks expect a named license.

Frequently asked questions

how to use agenix

Create an `agenix-rules.nix` in your secrets directory listing the public SSH keys allowed to decrypt each file, then create the encrypted secret with `nix run github:ryantm/agenix -- -e example.age`. Declare it in a module with `age.secrets.example.file` and read the decrypted file from `config.age.secrets.example.path`.

agenix vs sops nix

The repository contains no comparison with sops-nix. It describes itself as encrypting secrets with SSH public keys so the encrypted files can be stored and deployed with Nix, and it links a separate threat model and warnings page.

Which installation methods does agenix document?

Four, each with its own guide: flakes, niv, nix-channel, and fetchTarball, with Home Manager installation covered as well. The repository root carries a `flake.nix` with a lockfile, a `default.nix`, and an `overlay.nix` with a `pkgs/` directory.

What license is agenix released under?

CC0-1.0, with a LICENSE file at the repository root. It is a public-domain dedication rather than a conventional permissive software license, which is an unusual choice for infrastructure code.

What examples ship in the agenix repository?

Six files under `example/`: one whose filename begins with a hyphen, an armored secret, a password-file secret, two numbered secrets, and a `secrets.nix` rules file. The repository also has an `example_keys/` directory at the root.

How often is agenix released?

Quickly at present. Three minor releases landed in under two days, with 0.16.0 and 0.17.0 both on 2026-09-26 about eighty minutes apart and 0.18.0 on 2026-09-27. The last push to the default branch is dated 2026-10-02.

Official sources

  1. Issues
  2. License: CC0-1.0
  3. README
  4. Releases
  5. ryantm/agenix on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/ryantm-agenix.svg)](https://hysenlabs.com/projects/ryantm-agenix)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/ryantm-agenix.svg)](https://hysenlabs.com/projects/ryantm-agenix)

Was this useful?