forked from
lass.pds.lassul.us/superconfig
This repository has no description
2.6 kB
67 lines
1{
2 perSystem =
3 { pkgs, ... }:
4 let
5 icon = pkgs.runCommand "hermes-voice-icon" { nativeBuildInputs = [ pkgs.imagemagick ]; } ''
6 mkdir $out
7 for size in 192 512; do
8 magick -size 512x512 xc:'#111' -fill '#4fb477' -draw 'circle 256,256 256,128' \
9 -resize ''${size}x$size -strip -define png:exclude-chunks=date,time \
10 $out/icon-$size.png
11 done
12 '';
13 static = pkgs.runCommand "hermes-voice-static" { } ''
14 cp -r ${./static} $out
15 chmod u+w $out
16 cp ${icon}/*.png $out/
17 '';
18 # The SDK is unfree; it only builds the APK and is not part of any system.
19 inherit
20 (import pkgs.path {
21 inherit (pkgs.stdenv.hostPlatform) system;
22 config.allowUnfree = true;
23 config.android_sdk.accept_license = true;
24 })
25 androidenv
26 ;
27 android = pkgs.callPackage ./android { inherit icon androidenv; };
28 in
29 {
30 # Full-duplex voice conversations with Hermes: gpt-live-1 in the
31 # browser, delegating real work to the Hermes API server.
32 packages.hermes-voice =
33 (pkgs.writeShellApplication {
34 name = "hermes-voice";
35 # A later --config on the command line overrides the packaged one.
36 text = ''
37 export HERMES_VOICE_STATIC=${static}
38 exec ${pkgs.python3}/bin/python3 ${./hermes_voice.py} --config ${./config.json} "$@"
39 '';
40 }).overrideAttrs
41 { passthru.usage = builtins.readFile ./usage.kdl; };
42
43 # The Android app: holds calls itself (WebRTC) and answers the headset's
44 # voice button, unsigned.
45 packages.hermes-voice-android = android;
46 checks.hermes-voice-android = android;
47
48 # Aligns and signs the APK with the keystore from
49 # `clan vars get coaxmetal hermes-voice-android-signing/keystore`.
50 packages.hermes-voice-android-sign = pkgs.writeShellApplication {
51 name = "hermes-voice-android-sign";
52 runtimeInputs = [ pkgs.jdk17_headless ];
53 text = ''
54 PATH=${android.buildTools}:$PATH
55 if [ $# -lt 3 ]; then
56 echo "usage: hermes-voice-android-sign KEYSTORE PASSWORD_FILE OUT_APK [UNSIGNED_APK]" >&2
57 exit 1
58 fi
59 aligned=$(mktemp)
60 trap 'rm -f "$aligned"' EXIT
61 zipalign -f -p 4 "''${4:-${android}/hermes-voice-android-unsigned.apk}" "$aligned"
62 apksigner sign --ks "$1" --ks-pass "file:$2" --v4-signing-enabled false --out "$3" "$aligned"
63 apksigner verify --print-certs "$3"
64 '';
65 };
66 };
67}