OPVLEXF5H3CHSU43PIQ4M75UAE3UIKQ5WTVYUOD4M7MPUHLP26LQC UV7MAQHGBWSPNBB2HUPC7YTSE4DUEH5S46ZHF4SXWCAUFEHCNOAAC MQT74AV47PUYNCX27OMFK6BFN7PP4DX46JAACN2EPRYXUXV7EL3AC RTBMBSBABSGTRICJ4AWBKWO3JJHBRKV6FGOMYPDD7X6SS6X35ZIQC 3JJNSJEGODVFHBIC2AOLOB3JZSFPPQBENWFLKHTSOGH7YGVW6GTQC QOY7D3GZ3WF7HAMEHAW2CIUB5TDQCFE3YDZEO23R5MFQEBN635WAC GQKXVOPSZ5OQOYQAVXKTNYSDZB222KUIB3VYF2M7UW2LNXPII6KQC KOXYNEPMHOWPUOUDAIDAVC2ZPUCLFGN23BM6QJ4UIDGVN73SUO7AC ONJIY3TNGUJSQ4HRL2AIMDKYWYFICVZAHRU2GVY7LZ7ULWPY7NWQC 5YWPZ2DSSOUZE4ZNS7QSDQE7NF3JYNGHEH75YOIAR7HOUTYAYUFQC JEXZ3CACDXO2EZPKB26KN3VSE5INEYDHNM4ZF2XJHGA5Z4A6QHBQC { self, config, lib, ... }: letinherit (lib) mkIf types;in {options.age-rekey = {enable = lib.mkEnableOption "age-rekey";hostPubkey = lib.mkOption {type = types.str;example = "ssh-ed25519 ...";description = "Host public key for rekeying";};# TODO(1/2): Per OS type handling. Probably better to not use an option.typeOf = lib.mkOption {type = types.str;example = "linux";description = "OS type (linux|darwin) for age identity paths";};};config = mkIf config.age-rekey.enable {# TODO(2/2): Per OS type.age.identityPaths = [ "/root/.ssh/id" ];age.rekey = {hostPubkey = config.age-rekey.hostPubkey;masterIdentities = [ (self + /yubikey.pub) ];localStorageDir = self + "/secrets/rekeyed/${config.networking.hostName}";storageMode = "local";};};}
{ self, inputs, ... }:{config.flake.agenix-rekey = inputs.age-rekey.configure {userFlake = self;inherit (self) nixosConfigurations;};config.flake.modules.nixos.secret-manager ={ config, ... }:{imports = [inputs.age.nixosModules.defaultinputs.age-rekey.nixosModules.default];config.age.rekey = {storageMode = "local";masterIdentities = [ ../yubikey.pub ];localStorageDir = ../secrets/rekeyed/${config.networking.hostName};};};config.flake.modules.darwin.secret-manager = {imports = [inputs.age.darwinModules.default];};}
inherit (lib) mkIf;in {age.identityPaths = [(if config.isLinux thenelse];}environment.systemPackages = mkIf config.isDesktop [pkgs.agenixpkgs.age-plugin-yubikey];inputs.agenix-rekey.packages.${pkgs.stdenv.hostPlatform.system}.default"${config.users.users.${config.system.primaryUser}.home}/.ssh/id")"${config.users.users.root.home}/.ssh/id"{ inputs, config, lib, pkgs, ... }: let
{ pkgs, lib, config, ... }: letinherit (lib) mkIf enabled;in mkIf config.isDesktop {services.pcscd = enabled;programs.yubikey-manager = enabled;programs.yubikey-touch-detector = enabled {libnotify = true;};security.pam.services = {sudo.u2fAuth = true;};}environment.systemPackages = [pkgs.yubikey-personalizationpkgs.yubioath-flutterpkgs.age-plugin-yubikey];services.udev.packages = [pkgs.yubikey-personalization];su.u2fAuth = true;sshd.u2fAuth = true;login = {u2fAuth = true;enableGnomeKeyring = true;};