Giter Club home page Giter Club logo

homeage's Introduction

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
  • Symlink (or copy if symlinks aren't supported) decrypted secrets
  • Safely cleans up secrets on generation change or systemd service stop
  • Encryption is normal age encryption, use your ssh or age keys
  • Decryption/cleanup secrets either through systemd services or home-manager activation (for systems without systemd support)

Management Scheme

Pre-Build:

  • Encrypt files with age and make them accessible to home-manager config (through git repository, builtin function, etc.).
  • Install your age/ssh key outside of the scope home-manager.

Post-build:

  • Encrypted files are copied into the nix store (globally available).
  • Scripts for decrypting are are in the nix store (globally available).
    • Because of this must to make sure your decryption key has correct file permissions set.

Systemd Installation

Service Start:

  • Decrypts secret and copies/symlinks to locations

Service Stop:

  • Cleans up decrypted secret and associated copies/symlinks

Home-manager activation:

  • With home-manager systemd reload enabled services will automatically reload/stop during activation for seamless cleanup and re-installation.

Activation Installation

Home-manager activation:

  • Cleans up all secrets that changed between current and previous generation
  • Decrypts secret and copies/symlinks to locations

Getting started

Non-flake

If you are using homeage without nix flakes feel free to contribute an example config.

Nix Flakes

Import homeage.homeManagerModules.homeage into the configuration and set 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}";

            homeage = {
                # Absolute path to identity (created not through home-manager)
                identityPaths = [ "~/.ssh/id_ed25519" ];

                # "activation" if system doesn't support systemd
                installationType = "systemd";

                file."pijulsecretkey" = {
                  # Path to encrypted file tracked by the git repository
                  source = ./secretkey.json.age;
                  symlinks = [ "${config.xdg.configHome}/pijul/secretkey.json" ];
                  copies = [ "${config.xdg.configHome}/no-symlink-support/secretkey.json" ];
                };
            };

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

Options

See source for all the options and their descriptions.

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!

homeage's People

Contributors

gerschtli avatar gvolpe avatar jordanisaacs avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.