alpha
Login
or
Join now
lass.pds.lassul.us
/
superconfig
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
1
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
1
Pipelines
tools.age-detect: init
author
lassulus
date
1 year ago
(Aug 27, 2025, 3:48 PM CEST)
commit
ba99ea2e
ba99ea2e714355ecc5e8e23ed277425ee325227e
parent
32f5656f
32f5656f2d797540534b1b3ca7f7ed289ddf2873
+102
2 changed files
Expand all
Collapse all
Unified
Split
tools
age-detect
age-detect
flake-module.nix
+83
tools/age-detect/age-detect
View file
Reviewed
···
1
1
+
#!/usr/bin/env bash
2
2
+
set -euo pipefail
3
3
+
4
4
+
# age-detect: Detects connected age-compatible security keys
5
5
+
# Returns identity file path and detected key information
6
6
+
7
7
+
# Function to detect connected security keys and their age identities
8
8
+
detect_age_keys() {
9
9
+
local temp_identities
10
10
+
temp_identities=$(mktemp)
11
11
+
12
12
+
# Check for Secure Enclave on macOS (highest priority)
13
13
+
if [[ "$(uname)" == "Darwin" ]] && command -v age-plugin-se >/dev/null 2>&1; then
14
14
+
echo "AGE-PLUGIN-SE-15FM0MYMDXM39K8EKG0TNG" > "$temp_identities"
15
15
+
echo "IDENTITY_FILE=$temp_identities"
16
16
+
echo "DETECTED_KEY=se"
17
17
+
echo "KEY_TYPE=se"
18
18
+
return
19
19
+
fi
20
20
+
21
21
+
# Check for YubiKeys (second priority)
22
22
+
if command -v ykman >/dev/null 2>&1; then
23
23
+
local yubikey_serial
24
24
+
yubikey_serial=$(ykman info 2>/dev/null | grep "Serial number:" | cut -d: -f2 | tr -d ' ' || true)
25
25
+
if [[ -n "$yubikey_serial" ]]; then
26
26
+
echo "AGE-PLUGIN-YUBIKEY-1M2PLUQYZ242EPUSSHDFWJ" > "$temp_identities"
27
27
+
echo "IDENTITY_FILE=$temp_identities"
28
28
+
case "$yubikey_serial" in
29
29
+
"16679898")
30
30
+
echo "DETECTED_KEY=yubi1"
31
31
+
;;
32
32
+
"11342136")
33
33
+
echo "DETECTED_KEY=yubi2"
34
34
+
;;
35
35
+
*)
36
36
+
echo "DETECTED_KEY=yubikey-${yubikey_serial}"
37
37
+
;;
38
38
+
esac
39
39
+
echo "KEY_TYPE=yubikey"
40
40
+
return
41
41
+
fi
42
42
+
fi
43
43
+
44
44
+
# Check for Solo2 (lowest priority)
45
45
+
if command -v fido2-token >/dev/null 2>&1; then
46
46
+
if fido2-token -L 2>/dev/null | grep -q "Solo 2"; then
47
47
+
# FIDO2-HMAC doesn't use identity file
48
48
+
rm -f "$temp_identities"
49
49
+
echo "IDENTITY_FILE="
50
50
+
echo "DETECTED_KEY=solo2"
51
51
+
echo "KEY_TYPE=solo2"
52
52
+
return
53
53
+
fi
54
54
+
fi
55
55
+
56
56
+
# No keys detected
57
57
+
rm -f "$temp_identities"
58
58
+
echo "IDENTITY_FILE="
59
59
+
echo "DETECTED_KEY="
60
60
+
echo "KEY_TYPE="
61
61
+
}
62
62
+
63
63
+
# Parse command line arguments
64
64
+
case "${1:-detect}" in
65
65
+
detect)
66
66
+
detect_age_keys
67
67
+
;;
68
68
+
--help|-h)
69
69
+
echo "Usage: age-detect [detect]"
70
70
+
echo ""
71
71
+
echo "Detects the first available age-compatible security key and outputs:"
72
72
+
echo " IDENTITY_FILE=<path> - Path to temporary identity file for age (empty for Solo2)"
73
73
+
echo " DETECTED_KEY=<name> - Name of the detected key (e.g., yubi1, solo2, se)"
74
74
+
echo " KEY_TYPE=<type> - Type of key (yubikey, solo2, se)"
75
75
+
echo ""
76
76
+
echo "Priority order: se > yubikey > solo2"
77
77
+
;;
78
78
+
*)
79
79
+
echo "Unknown command: $1" >&2
80
80
+
echo "Use --help for usage information" >&2
81
81
+
exit 1
82
82
+
;;
83
83
+
esac
+19
tools/age-detect/flake-module.nix
View file
Reviewed
···
1
1
+
{ self, ... }:
2
2
+
{
3
3
+
perSystem =
4
4
+
{ pkgs, ... }:
5
5
+
{
6
6
+
packages.age-detect = pkgs.writeShellApplication {
7
7
+
name = "age-detect";
8
8
+
runtimeInputs = with pkgs; [
9
9
+
age
10
10
+
age-plugin-yubikey
11
11
+
age-plugin-fido2-hmac
12
12
+
age-plugin-se
13
13
+
yubikey-manager
14
14
+
libfido2
15
15
+
];
16
16
+
text = builtins.readFile ./age-detect;
17
17
+
};
18
18
+
};
19
19
+
}