All Projects → jordanisaacs → homeage

jordanisaacs / homeage

Licence: MIT license
runtime decrypted age secrets for nix home manager

Programming Languages

Nix
1067 projects

Projects that are alternatives of or similar to homeage

dotfiles
My NixOS dotfiles
Stars: ✭ 21 (-51.16%)
Mutual labels:  nix, nixos, home-manager
nix-configs
My Nix{OS} configuration files
Stars: ✭ 54 (+25.58%)
Mutual labels:  nix, nixos, home-manager
dotnix
Shackled within an elaborate prison of my own design.
Stars: ✭ 35 (-18.6%)
Mutual labels:  nix, nixos, home-manager
nyx
⚙️Nix[OS] Configuration
Stars: ✭ 50 (+16.28%)
Mutual labels:  nix, nixos, home-manager
elemental
Elemental, the component parts of a Nix/OS development system.
Stars: ✭ 44 (+2.33%)
Mutual labels:  nix, nixos, home-manager
dotfiles
No place like ~. Nix. All. The. Things.
Stars: ✭ 48 (+11.63%)
Mutual labels:  nix, nixos, home-manager
dconf2nix
🐾 Convert Dconf files (e.g. Gnome Shell) to Nix, as expected by Home Manager
Stars: ✭ 51 (+18.6%)
Mutual labels:  nix, nixos, home-manager
dotfiles
NixOS system config & Home-Manager user config
Stars: ✭ 43 (+0%)
Mutual labels:  nix, nixos, home-manager
impermanence
Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
Stars: ✭ 401 (+832.56%)
Mutual labels:  nix, nixos, home-manager
nix-config
A collection of my system configs and dotfiles
Stars: ✭ 35 (-18.6%)
Mutual labels:  nix, nixos, home-manager
system
Declarative NixOS system configuration for all my machines
Stars: ✭ 14 (-67.44%)
Mutual labels:  nix, nixos, home-manager
base16.nix
Quickly theme programs in your favourite base16 colorscheme
Stars: ✭ 61 (+41.86%)
Mutual labels:  nix, nixos, home-manager
nix-xdg
[WIP] Nix overlay for making programs xdg compliant
Stars: ✭ 18 (-58.14%)
Mutual labels:  nix, nixos, home-manager
nix-home
A Nix Home Manager setup. I've now moved to a new configuration system at hugoreeves/elemental
Stars: ✭ 60 (+39.53%)
Mutual labels:  nix, nixos, home-manager
nix-rice
A library to functionally define your configuration and theme (rice) with Nix
Stars: ✭ 43 (+0%)
Mutual labels:  nix, nixos, home-manager
nixops-tutorial
Tutorial for practical deployments with NixOps
Stars: ✭ 93 (+116.28%)
Mutual labels:  nix, nixos
digga
A flake utility library to craft shell-, home-, and hosts- environments.
Stars: ✭ 818 (+1802.33%)
Mutual labels:  nix, nixos
nix-config
My personal nix config
Stars: ✭ 32 (-25.58%)
Mutual labels:  nix, nixos
dotnix
nix stuff
Stars: ✭ 27 (-37.21%)
Mutual labels:  nix, nixos
nix2container
An archive-less dockerTools.buildImage implementation
Stars: ✭ 133 (+209.3%)
Mutual labels:  nix, nixos

homeage - runtime decrypted age secrets for nix home manager

homeage is a module for home-manager that enables runtime decryption of declarative age files.

Features

  • File agnostic declarative secrets that can be used inside your home-manager flakes
  • Each secret gets decrypted with its own systemd service integrating seamlessly with home-manager reload and update
  • Just normal age encryption, use ssh or age keys
  • Add symbolic links to decrypted files
  • Extremely little bash script so inspect the source yourself!

Management Scheme

Pre-Build: Files are encrypted by external age key in repository (unencrypted with associated public key on roadmap)

Post-Build: Files are encrypted by external age key while in nix store

Runtime: Files are stored unencrypted in /run/user/$UID/secrets and can be symlinked to other locations

Notes (in progress fixes):

  1. All home.file.<name>.symlinks are not cleaned up on new home-manager generation. Therefore a symlink that points to a decrypted yaml file named hello in one generation, instead of being deleted will point to a png file named hello in the next.

  2. The /run secrets folder is not cleaned on home-manager activation. Therefore old secrets will exist decrypted until reboot.

  3. Use the cpOnService at your own risk, as cleanup is not implemented the decrypted file will exist until manually deleted

Roadmap

  • Implement cleanup
  • Support passphrases
  • Support unencrypted with public key files
  • Add activation checks
  • Add tests

Getting started

Nix Flakes

While the following below is immense, its mostly just home manager flake boilerplate. All you need to do is import homeage.homeManagerModules.homeage into the configuration and set a valid homeage.identityPaths and your all set.

{
  inputs = {
    nixpkgs.url = "nixpkgs/nixos-unstable";
    home-manager = {
      url = "github:nix-community/home-manager";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    homeage = {
      url = "github:jordanisaacs/homeage";
      # Optional
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, homeage, ... }@inputs:
    let
      pkgs = import nixpkgs {
        inherit system;
      };
      
      system = "x86-64_linux";
      username = "jd";
      stateVersion = "21.05";
    in {
      homeManagerConfigurations = {
        jd = home-manager.lib.homeManagerConfiguration {
          inherit system stateVersion username pkgs;
          home.homeDirectory = "/home/${username}";

          configuration = {
            home.stateVersion = stateVersion;
            home.username = username;
            home.homeDirectory = "/home/${username}";

            # CHECK HERE for homeage configuration
            homeage.identityPaths = [ "~/.ssh/id_ed25519" ];
            homeage.file."pijulsecretkey" = {
              source = ./secretkey.json.age;
              path = "pijul/secretkey.json";
              symlinks = [ "${config.xdg.configHome}/pijul/secretkey.json" ];
            };

            imports = [ homeage.homeManagerModules.homeage ];
          };
        };
      };
    };
}

Options

Check out all the options

How it works

On home manager build, the age-encrypted files are built into the nix store and symlinked to the provided homeage.folder path. This is achieved through the home-manager home.file option. Notice that all secret files are encrypted while in the nix store. After the symlinks are finished by home-manager, the systemd units are run. Each secret has its own oneshot service that runs a decryption script. This works seamlessly with home-managers updating/reloading of systemd units. The script decrypts the secrets to /run/user/$UID/secrets/ using the identities provided by homeage.identityPaths. It then acts on the decrypted file (changing ownership, linking, etc.). When rebooting, the decrypted files are lost as they are in the /run folder. Therefore, the systemd unit is wanted by default.target so it will run on startup.

Acknowledgments

The inspiration for this came from RaitoBezarius' pull request to agenix. I have been trying to figure out how to do secrets with home manager for a while and that PR laid out the foundational ideas for how to do it!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].