age-encrypted secrets for NixOS and Home manager
  • Nix 68.9%
  • Shell 31.1%
Find a file
2026-11-27 15:46:50 -08:00
.github doc: consolidate README into maintained documentation (#410) 2026-09-30 01:57:46 +00:00
contrib contrib: fix _incr_version script 2022-09-25 14:22:15 -07:00
doc doc: remove unused Matrix support link (#412) 2026-09-30 02:11:42 +00:00
example format nix with rfc style 2025-08-05 05:46:34 -07:00
example_keys add README and examples 2020-09-03 13:16:44 -07:00
modules fixup: disable noswap when inside a container (#456) 2026-10-20 07:36:53 -07:00
pkgs fix: add correct agenix version in agenix.nix (#462) 2026-11-27 15:46:50 -08:00
test contrib: move CLI checks out of VM integration test (#409) 2026-09-29 18:26:20 -07:00
.gitignore chore: add nix build result path to gitignore 2022-10-15 12:10:02 -04:00
default.nix format nix with rfc style 2025-08-05 05:46:34 -07:00
flake.lock contrib: isolate integration checks in test flake (#407) 2026-09-27 16:29:24 -07:00
flake.nix doc: consolidate README into maintained documentation (#410) 2026-09-30 01:57:46 +00:00
LICENSE initial prototype 2020-08-31 21:37:26 -07:00
overlay.nix format nix with rfc style 2025-08-05 05:46:34 -07:00
README.md doc: link README guidance to published site (#411) 2026-09-29 19:13:39 -07:00

agenix: age-encrypted secrets for NixOS and Home Manager

Read the documentation.

agenix encrypts secrets with SSH public keys so the encrypted files can be stored and deployed with Nix. Its CLI creates and rekeys .age files; the NixOS and Home Manager modules decrypt them at activation time for the intended machine or user.

Quick start

Add the NixOS module to your flake:

{
  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 ];
    };
  };
}

In a secrets directory, create agenix-rules.nix listing the public SSH keys allowed to decrypt each file. Then run nix run github:ryantm/agenix -- -e example.age to create an encrypted secret. Declare it in a NixOS module:

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

The tutorial shows a complete rules file, key discovery, installation, and deployment.

Documentation

For help, use GitHub issues.