This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / keys / flake-module.nix
1.8 kB 65 lines
1{ self, lib, ... }: 2let 3 # Helper to read all files from a subdirectory 4 readKeysFromDir = baseDir: subDir: 5 let 6 dir = baseDir + "/${subDir}"; 7 in 8 if builtins.pathExists dir then 9 lib.mapAttrs (name: _: 10 let 11 # Remove file extension to get key name 12 keyName = lib.removeSuffix ".${subDir}" name; 13 in 14 builtins.readFile (dir + "/${name}") 15 ) (builtins.readDir dir) 16 else 17 {}; 18 19 # Helper to read PGP keys with metadata 20 readPgpKeysFromDir = baseDir: 21 let 22 dir = baseDir + "/pgp"; 23 in 24 if builtins.pathExists dir then 25 lib.mapAttrs (name: _: 26 let 27 # Remove .pgp extension 28 keyName = lib.removeSuffix ".pgp" name; 29 in 30 { 31 key = dir + "/${name}"; 32 # For now, manually specify IDs - could be extracted from files later 33 id = 34 if keyName == "yubi" then "DBCD757846069B392EA9401D6657BE8A8D1EE807" 35 else null; 36 } 37 ) (builtins.readDir dir) 38 else 39 {}; 40 41in 42{ 43 flake.keys = { 44 # SSH keys (any format: rsa, ed25519, ecdsa) 45 ssh = readKeysFromDir ./. "ssh"; 46 47 # PGP/GPG keys with metadata 48 pgp = readPgpKeysFromDir ./.; 49 50 # Age keys (including age-plugin-se keys from Secure Enclave) 51 age = readKeysFromDir ./. "age"; 52 53 # Utility functions 54 lib = { 55 # Convert SSH Ed25519 public keys to age recipients 56 # Note: Only works for Ed25519 keys, not ECDSA/RSA 57 sshToAge = sshPubKey: 58 throw "sshToAge conversion requires runtime evaluation with ssh-to-age tool"; 59 60 # Check if a key is from Secure Enclave (age-plugin-se) 61 isSecureEnclaveKey = ageKey: 62 lib.hasPrefix "age1se1q" ageKey; 63 }; 64 }; 65}