This repository has no description
2.2 kB
56 lines
1{ self, ... }:
2{
3 perSystem =
4 { lib, pkgs, ... }:
5 let
6 # The Android wrapper's package name (android/AndroidManifest.xml).
7 androidPackage = "us.lassul.assist";
8 # Written by `clan vars generate coaxmetal` (machines/coaxmetal/hermes-voice.nix);
9 # until then there is no assetlinks.json and Chrome opens the app as a
10 # Custom Tab.
11 fingerprint = self + "/vars/per-machine/coaxmetal/hermes-voice-android-signing/fingerprint/value";
12 assetlinks = pkgs.writeText "assetlinks.json" (
13 builtins.toJSON [
14 {
15 relation = [ "delegate_permission/common.handle_all_urls" ];
16 target = {
17 namespace = "android_app";
18 package_name = androidPackage;
19 sha256_cert_fingerprints = [ (lib.removeSuffix "\n" (builtins.readFile fingerprint)) ];
20 };
21 }
22 ]
23 );
24 icon = pkgs.runCommand "hermes-voice-icon" { nativeBuildInputs = [ pkgs.imagemagick ]; } ''
25 mkdir $out
26 for size in 192 512; do
27 magick -size 512x512 xc:'#111' -fill '#4fb477' -draw 'circle 256,256 256,128' \
28 -resize ''${size}x$size -strip -define png:exclude-chunks=date,time \
29 $out/icon-$size.png
30 done
31 '';
32 static = pkgs.runCommand "hermes-voice-static" { } ''
33 cp -r ${./static} $out
34 chmod u+w $out
35 cp ${icon}/*.png $out/
36 ${lib.optionalString (builtins.pathExists fingerprint) ''
37 mkdir $out/.well-known
38 cp ${assetlinks} $out/.well-known/assetlinks.json
39 ''}
40 '';
41 in
42 {
43 # Full-duplex voice conversations with Hermes: gpt-live-1 in the
44 # browser, delegating real work to the Hermes API server.
45 packages.hermes-voice =
46 (pkgs.writeShellApplication {
47 name = "hermes-voice";
48 # A later --config on the command line overrides the packaged one.
49 text = ''
50 export HERMES_VOICE_STATIC=${static}
51 exec ${pkgs.python3}/bin/python3 ${./hermes_voice.py} --config ${./config.json} "$@"
52 '';
53 }).overrideAttrs
54 { passthru.usage = builtins.readFile ./usage.kdl; };
55 };
56}