Skip to content

Commit 1c8840d

Browse files
committed
refactor: Allow talon to be overridden to allow beta use
1 parent 75a4a73 commit 1c8840d

File tree

7 files changed

+189
-136
lines changed

7 files changed

+189
-136
lines changed

README.md

+25-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ showing up.
2929

3030
## Can I use Talon Beta?
3131

32-
The Talon Beta URLs and tarballs are private and also change across each release.
33-
If you want to run the Talon Beta, download a beta tarball from the URLs hosted in
34-
the `#beta` slack channel, then use the `steam-run` approach mentioned above.
32+
Yes, but please remember the Talon Beta URLs are meant to be kept private. You can manually override the talon-nix
33+
flake, but it is important that you DO NOT include the hardcoded URLs in a public repository. You should keep the URL
34+
private by importing a secrets repo into your config flake, and have the beta URL inside of the secret flake. However,
35+
this will expose the URL in the nix store, so if you are using a shared system, you will need to use some other
36+
approach.
37+
38+
The following is an example of how this might look:
39+
40+
```nix
41+
nixpkgs = {
42+
overlays = [
43+
inputs.talon-nix.overlays.default
44+
(final: prev: {
45+
talon-unwrapped = prev.talon-unwrapped.overrideAttrs (oldAttrs: {
46+
version = "0.4.0-359-g5c35";
47+
src = builtins.fetchurl {
48+
url = inputs.nix-secrets.talon-beta-url;
49+
sha256 = "sha256:07ia3cnr1ayckcffr3zw6l9j3fz8ywxcxjw68ba647994s2n2zfa";
50+
};
51+
});
52+
})
53+
];
54+
};
55+
```
56+

flake.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+27-16
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,35 @@
55
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
66
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
77

8-
outputs = { self, nixpkgs, nix-github-actions }:
9-
let
10-
pkgs = import nixpkgs {
8+
outputs =
9+
{
10+
self,
11+
nixpkgs,
12+
nix-github-actions,
13+
}:
14+
let
1115
system = "x86_64-linux";
12-
config.allowUnfree = true;
13-
};
14-
in
15-
{
16-
overlays.default = import ./overlay.nix;
17-
nixosModules.talon = import ./nixos;
16+
overlays = import ./overlay.nix;
17+
pkgs = import nixpkgs {
18+
inherit system;
19+
overlays = [ overlays ];
20+
};
21+
in
22+
{
23+
overlays.default = overlays;
24+
nixosModules.talon = import ./nixos;
1825

19-
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
26+
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
2027

21-
checks.x86_64-linux = {
22-
talon = self.packages.x86_64-linux.default;
23-
};
28+
checks.${system} = {
29+
talon = self.packages.${system}.default;
30+
};
2431

25-
packages.x86_64-linux.default = pkgs.callPackage ./talon.nix { };
26-
devShells.x86_64-linux.default = import ./shell.nix { inherit pkgs; };
27-
};
32+
packages.${system} = {
33+
default = self.packages.${system}.talon;
34+
talon = pkgs.talon;
35+
talon-unwrapped = pkgs.talon-unwrapped;
36+
};
37+
devShells.${system}.default = import ./shell.nix { inherit pkgs; };
38+
};
2839
}

nixos/default.nix

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
{ config, lib, pkgs, ... }:
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
27

38
let
49
cfg = config.programs.talon;
5-
610
in
711
{
812
options.programs.talon = {

overlay.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
final: prev: {
2-
talon = final.callPackage ./talon.nix { };
2+
talon-unwrapped =
3+
if prev ? talon-unwrapped then prev.talon-unwrapped else prev.callPackage ./talon-unwrapped.nix { };
4+
talon = prev.callPackage ./talon.nix { pkgs = final; };
35
}

talon-unwrapped.nix

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchurl,
5+
}:
6+
let
7+
inherit (lib.importJSON ./src.json) version sha256;
8+
9+
meta = {
10+
homepage = "https://talonvoice.com/";
11+
description = "Voice coding application unwrapped";
12+
license = lib.licenses.unfree;
13+
maintainers = [ ];
14+
platforms = lib.platforms.linux;
15+
};
16+
in
17+
stdenv.mkDerivation {
18+
pname = "talon";
19+
inherit version;
20+
21+
src = fetchurl {
22+
url = "https://talonvoice.com/dl/latest/talon-linux.tar.xz";
23+
inherit sha256;
24+
};
25+
26+
preferLocalBuild = true;
27+
dontBuild = true;
28+
dontConfigure = true;
29+
30+
installPhase = ''
31+
runHook preInstall
32+
33+
mkdir -p $out/opt/talon
34+
cp -a * $out/opt/talon/
35+
36+
mkdir -p "$out/etc/udev/rules.d"
37+
cp 10-talon.rules $out/etc/udev/rules.d
38+
# Remove udev compatibility hack using plugdev for older debian/ubuntu
39+
# This breaks NixOS usage of these rules (see https://github.com/NixOS/nixpkgs/issues/76482)
40+
substituteInPlace $out/etc/udev/rules.d/10-talon.rules --replace 'GROUP="plugdev",' ""
41+
42+
mkdir -p $out/share/applications
43+
cat << EOF > $out/share/applications/talon.desktop
44+
[Desktop Entry]
45+
Categories=Utility;
46+
Exec=talon
47+
Name=Talon
48+
Terminal=false
49+
Type=Application
50+
EOF
51+
52+
mkdir -p $out/bin
53+
ln -s $out/opt/talon/talon $out/bin/talon
54+
ln -s $out/opt/talon/lib $out
55+
56+
runHook postInstall
57+
'';
58+
59+
inherit meta;
60+
}

talon.nix

+62-108
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,16 @@
1-
{ stdenv
2-
, buildFHSEnv
3-
, lib
4-
, fetchurl
1+
{
2+
buildFHSEnv,
3+
lib,
4+
pkgs,
55
}:
6-
76
let
8-
inherit (lib.importJSON ./src.json) version sha256;
9-
107
meta = {
118
homepage = "https://talonvoice.com/";
12-
description = "Voice coding application";
9+
description = "Voice coding application. FHS wrapped.";
1310
license = lib.licenses.unfree;
1411
maintainers = [ ];
1512
platforms = lib.platforms.linux;
1613
};
17-
18-
talon = stdenv.mkDerivation {
19-
pname = "talon";
20-
inherit version;
21-
22-
src = fetchurl {
23-
url = "https://talonvoice.com/dl/latest/talon-linux.tar.xz";
24-
inherit sha256;
25-
};
26-
27-
preferLocalBuild = true;
28-
dontBuild = true;
29-
dontConfigure = true;
30-
31-
installPhase = ''
32-
runHook preInstall
33-
34-
mkdir -p $out/opt/talon
35-
cp -a * $out/opt/talon/
36-
37-
mkdir -p "$out/etc/udev/rules.d"
38-
cp 10-talon.rules $out/etc/udev/rules.d
39-
# Remove udev compatibility hack using plugdev for older debian/ubuntu
40-
# This breaks NixOS usage of these rules (see https://github.com/NixOS/nixpkgs/issues/76482)
41-
substituteInPlace $out/etc/udev/rules.d/10-talon.rules --replace 'GROUP="plugdev",' ""
42-
43-
mkdir -p $out/share/applications
44-
cat << EOF > $out/share/applications/talon.desktop
45-
[Desktop Entry]
46-
Categories=Utility;
47-
Exec=talon
48-
Name=Talon
49-
Terminal=false
50-
Type=Application
51-
EOF
52-
53-
mkdir -p $out/bin
54-
ln -s $out/opt/talon/talon $out/bin/talon
55-
ln -s $out/opt/talon/lib $out
56-
57-
runHook postInstall
58-
'';
59-
60-
inherit meta;
61-
};
62-
6314
in
6415
buildFHSEnv {
6516
name = "talon";
@@ -69,65 +20,68 @@ buildFHSEnv {
6920
export LC_NUMERIC=C
7021
export QT_PLUGIN_PATH="/lib/plugins"
7122
72-
export LD_LIBRARY_PATH=${lib.concatStringsSep ":" [
73-
"/opt/talon/resources/python/lib/python3.11/site-packages/numpy.libs"
74-
"/opt/talon/resources/python/lib"
75-
]}
23+
export LD_LIBRARY_PATH=${
24+
lib.concatStringsSep ":" [
25+
"/opt/talon/resources/python/lib/python3.11/site-packages/numpy.libs"
26+
"/opt/talon/resources/python/lib"
27+
]
28+
}
7629
'';
7730

7831
extraInstallCommands = ''
79-
ln -s ${talon}/share $out/share
80-
ln -s ${talon}/etc $out/etc
32+
ln -s ${pkgs.talon-unwrapped}/share $out/share
33+
ln -s ${pkgs.talon-unwrapped}/etc $out/etc
8134
'';
8235

83-
runScript = "${talon}/bin/talon";
84-
85-
targetPkgs = pkgs: with pkgs; [
86-
stdenv.cc.cc
87-
stdenv.cc.libc
88-
dbus
89-
fontconfig
90-
freetype
91-
glib
92-
libGL
93-
libxkbcommon
94-
sqlite
95-
zlib
96-
libpulseaudio
97-
udev
98-
xorg.libX11
99-
xorg.libSM
100-
xorg.libXcursor
101-
xorg.libICE
102-
xorg.libXrender
103-
xorg.libxcb
104-
xorg.libXext
105-
xorg.libXcomposite
106-
xorg.libXrandr
107-
xorg.libXi
108-
bzip2
109-
ncurses5
110-
libuuid
111-
gtk3-x11
112-
gdk-pixbuf
113-
cairo
114-
libdrm
115-
gnome2.pango
116-
gdbm
117-
atk
118-
wayland
119-
wayland-protocols
120-
wlroots
121-
xwayland
122-
libinput
123-
libxml2
124-
speechd
125-
gfortran
126-
# gfortran.cc default output contains static libraries compiled without -fPIC
127-
# we want libgfortran.so instead (see: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/science/math/giac/default.nix)
128-
(lib.getLib gfortran.cc)
129-
talon
130-
];
36+
runScript = "${pkgs.talon-unwrapped}/bin/talon";
37+
38+
targetPkgs =
39+
pkgs: with pkgs; [
40+
stdenv.cc.cc
41+
stdenv.cc.libc
42+
dbus
43+
fontconfig
44+
freetype
45+
glib
46+
libGL
47+
libxkbcommon
48+
sqlite
49+
zlib
50+
libpulseaudio
51+
udev
52+
xorg.libX11
53+
xorg.libSM
54+
xorg.libXcursor
55+
xorg.libICE
56+
xorg.libXrender
57+
xorg.libxcb
58+
xorg.libXext
59+
xorg.libXcomposite
60+
xorg.libXrandr
61+
xorg.libXi
62+
bzip2
63+
ncurses5
64+
libuuid
65+
gtk3-x11
66+
gdk-pixbuf
67+
cairo
68+
libdrm
69+
gnome2.pango
70+
gdbm
71+
atk
72+
wayland
73+
wayland-protocols
74+
wlroots
75+
xwayland
76+
libinput
77+
libxml2
78+
speechd
79+
gfortran
80+
# gfortran.cc default output contains static libraries compiled without -fPIC
81+
# we want libgfortran.so instead (see: https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/science/math/giac/default.nix)
82+
(lib.getLib gfortran.cc)
83+
talon-unwrapped
84+
];
13185

13286
inherit meta;
13387
}

0 commit comments

Comments
 (0)