This repository has no description
0

Configure Feed

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

keys: add YubiKey identity files and update flake-module to handle both .age and .identity files

+54 -9
+52 -9
keys/flake-module.nix
··· 1 1 { lib, ... }: 2 2 let 3 - # Helper to read age keys (public keys only) 3 + # Helper to read age keys with different types 4 4 readAgeKeys = 5 5 baseDir: 6 6 let 7 7 dir = baseDir + "/age"; 8 8 in 9 9 if builtins.pathExists dir then 10 - lib.mapAttrs' ( 11 - name: _: 12 - let 13 - # Remove everything after the first dot 14 - keyName = builtins.head (lib.splitString "." name); 15 - in 16 - lib.nameValuePair keyName (builtins.readFile (dir + "/${name}")) 17 - ) (builtins.readDir dir) 10 + let 11 + allFiles = builtins.readDir dir; 12 + # Group files by base name and type 13 + processFile = 14 + name: type: 15 + if type == "regular" then 16 + let 17 + parts = lib.splitString "." name; 18 + baseName = builtins.head parts; 19 + extension = if builtins.length parts > 1 then lib.last parts else ""; 20 + in 21 + { 22 + name = baseName; 23 + value = 24 + if extension == "age" then 25 + { 26 + public = builtins.readFile (dir + "/${name}"); 27 + identity = null; 28 + } 29 + else if extension == "identity" then 30 + { 31 + public = null; 32 + identity = builtins.readFile (dir + "/${name}"); 33 + } 34 + else 35 + null; 36 + } 37 + else 38 + null; 39 + 40 + # Process all files and merge by base name 41 + fileAttrs = lib.filterAttrs (_n: v: v != null) (lib.mapAttrs processFile allFiles); 42 + 43 + # Merge entries with same base name 44 + mergeEntries = lib.foldl' ( 45 + acc: entry: 46 + let 47 + existing = 48 + acc.${entry.name} or { 49 + public = null; 50 + identity = null; 51 + }; 52 + merged = { 53 + public = if entry.value.public != null then entry.value.public else existing.public; 54 + identity = if entry.value.identity != null then entry.value.identity else existing.identity; 55 + }; 56 + in 57 + acc // { ${entry.name} = merged; } 58 + ) { } (lib.attrValues fileAttrs); 59 + in 60 + mergeEntries 18 61 else 19 62 { }; 20 63
+1
keys/age/yubi1.identity
··· 1 + AGE-PLUGIN-YUBIKEY-1M2PLUQYZ242EPUSSHDFWJ
+1
keys/age/yubi2.identity
··· 1 + AGE-PLUGIN-YUBIKEY-18QG66QYZQA3VW5QLERCNM