mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
* linux: round a Wayland window's bottom corners Bump Rune to 431469b999268a56ef7fbc60ed55975753ee22df. Under GNOME Wayland winit draws the client-side frame, whose headerbar rounds the top corners and whose shadow cuts a 10-point rounded window, but the content's surface stayed square: the bottom corners showed past the frame's border and the border's straight bands crossed the shadow's cut-out (#1779). Rune (#1188) rounds the content's bottom corners with the frame while the window floats, and keeps them square when it is maximized, tiled or fullscreen; a compositor that draws the decorations itself (KDE, sway, Hyprland) keeps the surface it had. Patch sctk-adwaita from the same rev as winit, since Rune's winit calls the vendored frame's `AdwaitaFrame::content_corner_radius`. The rev also carries Rune's macOS/iOS/Linux build fix after the crate extractions (#1203), and its wheel fix (#1214): a wheel over a scroll bar now scrolls the viewport it follows, so Hex's wheel-over-the-right-edge tests keep their positions. The bump brings the type-erased `window::Host` and window/ reorganisation, the rune-core/rune-gpu/rune-image/rune-spell extraction, then rune-text, rune-media and rune-edit, the non-generic `RuntimeCore`, windows-sys 0.61, deep Taffy stack segments, one flatten and one detached-table prune, the new wheel distance and chaining, and text, markdown and scroll fixes. No Hex call sites changed. Goldens are refreshed for Rune's visuals: the OpenCode icon catalog's marks (terminal, search, keyboard, globe) in every pane and overlay, and the shortcut-mode bars from Rune's border-over-fill change. cargo check --all-targets, cargo test (2811 passed), cargo clippy --all-targets --all-features, cargo fmt --check, code-shape.py, check-nix-git-pins.py and its tests, nix build of the cargoDeps, and cargo test rune_ui all pass. * history: read Dictation stats from the window's settings The pane closed its stats dialog and reloaded the rollup from the process-wide labs switch. A test that applies another LabsSettings (as several do) flips that mirror under it, so the dialog vanished mid-test. Take the window's own `settings.labs.history_stats` instead, as the Stats button and the dialog already do. * nix: vendor Rune's fonts for rune-text, and run the suite serially Rune's crates/rune-text includes crates/rune/assets/Inter-*.ttf by a path relative to the workspace root; a vendored crate sits in git/ beside rune-0.0.1, so link git/rune to it for the include. The package check also runs plain cargo test, which shares Hex's process-global lab switches and model-download state. nextest isolates each test everywhere else, so run this one test at a time. * goldens: refresh the meeting capsules on Rune's icons Dev's capsule layout moved the time and close button above the title; with Rune's icon catalog the copy-agent-prompt mark is the boxed terminal. Only those four renders change. * nix: run the package check one test at a time the hook's way `preCheck` runs before cargoCheckHook, which then sets RUST_TEST_THREADS=$NIX_BUILD_CORES, so the export there was a no-op and the suite still raced on its process-global state. Set dontUseCargoParallelTests instead, and take the rune vendor directory's name from its cargoGitDependencies key, failing loudly if its assets are missing. Drop the link once Rune moves the fonts into rune-text.
298 lines
9.3 KiB
Nix
298 lines
9.3 KiB
Nix
{
|
|
lib,
|
|
rustPlatform,
|
|
pkg-config,
|
|
cmake,
|
|
python3,
|
|
shaderc,
|
|
vulkan-headers,
|
|
vulkan-loader,
|
|
spirv-headers,
|
|
openblas,
|
|
alsa-lib,
|
|
alsa-plugins,
|
|
pipewire,
|
|
libva,
|
|
ffmpeg-headless,
|
|
openssl,
|
|
libxkbcommon,
|
|
wayland,
|
|
fontconfig,
|
|
freetype,
|
|
curl,
|
|
util-linux,
|
|
wl-clipboard,
|
|
wtype,
|
|
makeWrapper,
|
|
autoAddDriverRunpath,
|
|
symlinkJoin,
|
|
libx11,
|
|
libxcb,
|
|
libxcursor,
|
|
libxrandr,
|
|
libxi,
|
|
mkShell,
|
|
rust-analyzer,
|
|
rustfmt,
|
|
clippy,
|
|
}:
|
|
|
|
let
|
|
buildEnv = {
|
|
OPENSSL_NO_VENDOR = "1";
|
|
BLA_VENDOR = "OpenBLAS";
|
|
};
|
|
runtimeEnv = {
|
|
LD_LIBRARY_PATH = lib.makeLibraryPath [
|
|
vulkan-loader
|
|
openblas
|
|
alsa-lib
|
|
wayland
|
|
libxkbcommon
|
|
fontconfig
|
|
# The X11 window and its XWayland overlay dlopen their libraries, so no
|
|
# DT_NEEDED entry finds them: x11rb's `dl-libxcb` loads libxcb.so.1, and
|
|
# winit's X11 backend loads libX11.so.6, libXcursor.so.1, libXi.so.6 and
|
|
# libX11-xcb.so.1 (in libx11), plus libxkbcommon-x11 (in libxkbcommon).
|
|
libxcb
|
|
libx11
|
|
libxcursor
|
|
libxi
|
|
# Linux Annotate dlopens libpipewire-0.3, libva and libva-drm. libva finds VA-API
|
|
# drivers through its built-in /run/opengl-driver path or LIBVA_DRIVERS_PATH.
|
|
pipewire
|
|
libva
|
|
];
|
|
ALSA_PLUGIN_DIR = symlinkJoin {
|
|
name = "hex-alsa-plugins";
|
|
paths = [
|
|
"${pipewire}/lib/alsa-lib"
|
|
"${alsa-plugins}/lib/alsa-lib"
|
|
];
|
|
};
|
|
};
|
|
runtimePackages = [
|
|
curl
|
|
wl-clipboard
|
|
wtype
|
|
# Annotate runs ffmpeg and ffprobe; the headless build includes libx264.
|
|
ffmpeg-headless
|
|
];
|
|
# Every Git dependency Cargo.lock pins, with the revision its output hash was
|
|
# computed from. scripts/check-nix-git-pins.py fails a pull request that bumps
|
|
# one without the other, before Nix reports a hash mismatch.
|
|
cargoGitDependencies = {
|
|
"transcribe-rs-0.3.11" = {
|
|
rev = "e37c66b6df43af51fde8dec34f98a07aaf09564c";
|
|
hash = "sha256-MJJiug3LfbKsuHcL2+LJk95+j5kk/MWzb5ihdBlHLmE=";
|
|
};
|
|
"rune-0.0.1" = {
|
|
rev = "431469b999268a56ef7fbc60ed55975753ee22df";
|
|
hash = "sha256-1Y8Y3EmOZqI+p+0P9RjYq5piMpHycWAESSYSiQ5kzaA=";
|
|
};
|
|
"transcribe-cpp-sys-0.4.1" = {
|
|
rev = "bcb639faa4c74a2300ba19e30360cb2355b1663a";
|
|
hash = "sha256-1VztJ0VhPTjAuk4J0NT9KapDOqplegpHOqHsTpfHXWc=";
|
|
};
|
|
};
|
|
# The vendor tree names every Git crate `<name>-<version>`, so the rune
|
|
# package's directory follows its key in the table above.
|
|
runeVendor = builtins.head (
|
|
builtins.filter (name: lib.hasPrefix "rune-" name) (builtins.attrNames cargoGitDependencies)
|
|
);
|
|
in
|
|
rustPlatform.buildRustPackage (finalAttrs: {
|
|
pname = "hex";
|
|
version = (builtins.fromTOML (builtins.readFile ../Cargo.toml)).package.version;
|
|
|
|
src = lib.fileset.toSource {
|
|
root = ../.;
|
|
fileset = lib.fileset.unions [
|
|
../Cargo.toml
|
|
../Cargo.lock
|
|
../.cargo
|
|
../build.rs
|
|
../crates
|
|
../src
|
|
../tests
|
|
../native
|
|
../resources
|
|
../assets
|
|
../packaging
|
|
# The Labs registry's published copy: a Rust test compares it to the registry.
|
|
../site/src/labs.json
|
|
../macos/HexMicrophoneDriver/Info.plist
|
|
# Built in: a 2.3.1 install moves itself into this installer's layout.
|
|
../.github/release/install-linux.sh
|
|
];
|
|
};
|
|
|
|
# nixpkgs' vendor directory keeps every crate in one place, keyed by name and
|
|
# version, so it cannot hold two copies from different sources. Rune's
|
|
# `vendor/tiny-skia-path` is a path dependency inside Rune (a Git crate here)
|
|
# at 0.11.4, the same name and version as resvg's from crates.io, so this
|
|
# vendors crates.io's crates in `registry/` and every Git source's crates in
|
|
# `git/`, and points each source at its own directory: Cargo tells them apart
|
|
# by source. The script is importCargoLock's, rewritten; each fragment below
|
|
# must still be in it (the guard says which is gone), so a nixpkgs change
|
|
# fails loudly here instead of vendoring something wrong.
|
|
cargoDeps =
|
|
(rustPlatform.importCargoLock {
|
|
lockFile = ../Cargo.lock;
|
|
outputHashes = builtins.mapAttrs (_: dependency: dependency.hash) cargoGitDependencies;
|
|
}).overrideAttrs
|
|
(old: {
|
|
buildCommand =
|
|
let
|
|
# importCargoLock's script, and what this override turns it into.
|
|
fragments = [
|
|
{
|
|
what = "the single vendored-sources config";
|
|
from = ''
|
|
[source.crates-io]
|
|
replace-with = "vendored-sources"
|
|
|
|
[source.vendored-sources]
|
|
directory = "cargo-vendor-dir"'';
|
|
to = ''
|
|
[source.crates-io]
|
|
replace-with = "registry-vendor-dir"
|
|
|
|
[source.registry-vendor-dir]
|
|
directory = "cargo-vendor-dir/registry"
|
|
|
|
[source.git-vendor-dir]
|
|
directory = "cargo-vendor-dir/git"'';
|
|
}
|
|
{
|
|
what = "the one-directory crate link";
|
|
from = ''ln -s "$crate" $out/$(basename "$crate" | cut -c 34-)'';
|
|
to = ''
|
|
dest=$(basename "$crate" | cut -c 34-)
|
|
if [ -e "$crate/.cargo-config" ]; then
|
|
mkdir -p $out/git
|
|
ln -s "$crate" $out/git/$dest
|
|
else
|
|
mkdir -p $out/registry
|
|
ln -s "$crate" $out/registry/$dest
|
|
fi'';
|
|
}
|
|
{
|
|
what = "the Git source config append";
|
|
from = ''cat "$crate/.cargo-config" >> $out/.cargo/config.toml'';
|
|
to = ''sed 's/replace-with = "vendored-sources"/replace-with = "git-vendor-dir"/' "$crate/.cargo-config" >> $out/.cargo/config.toml'';
|
|
}
|
|
];
|
|
missing = builtins.filter (fragment: !(lib.hasInfix fragment.from old.buildCommand)) fragments;
|
|
in
|
|
if missing != [ ] then
|
|
throw (
|
|
"nix/package.nix: importCargoLock's vendor script changed; re-apply the split into "
|
|
+ "a registry and a Git vendor directory. Missing: "
|
|
+ lib.concatMapStringsSep ", " (fragment: fragment.what) missing
|
|
)
|
|
else
|
|
lib.replaceStrings (map (fragment: fragment.from) fragments) (map (
|
|
fragment: fragment.to
|
|
) fragments) old.buildCommand
|
|
+ "\n"
|
|
+ ''
|
|
# Rune's `crates/rune-text` loads its default fonts from
|
|
# `crates/rune/assets` through a path relative to Rune's
|
|
# workspace root (`../../../rune/assets/…`). A vendored crate
|
|
# sits in `git/` beside the rune package, not inside that
|
|
# workspace, so point that path at the rune package's own
|
|
# assets. Drop this once Rune moves the fonts into rune-text.
|
|
mkdir -p $out/git
|
|
rune_vendor=${runeVendor}
|
|
if [ ! -d "$out/git/$rune_vendor/assets" ]; then
|
|
echo "nix/package.nix: $out/git/$rune_vendor/assets is missing; rune-text's font include needs it" >&2
|
|
exit 1
|
|
fi
|
|
ln -sfn "$rune_vendor" $out/git/rune
|
|
'';
|
|
});
|
|
|
|
nativeBuildInputs = [
|
|
pkg-config
|
|
cmake
|
|
python3
|
|
shaderc
|
|
makeWrapper
|
|
autoAddDriverRunpath
|
|
];
|
|
buildInputs = [
|
|
vulkan-headers
|
|
vulkan-loader
|
|
spirv-headers
|
|
openblas
|
|
alsa-lib
|
|
openssl
|
|
libxkbcommon
|
|
wayland
|
|
fontconfig
|
|
freetype
|
|
libx11
|
|
libxcb
|
|
libxcursor
|
|
libxrandr
|
|
libxi
|
|
];
|
|
|
|
# OpenCode HTTP requests run through curl, including in the tests; the
|
|
# 2.3.1 adoption test runs the Linux installer, which needs flock.
|
|
nativeCheckInputs = [
|
|
curl
|
|
util-linux
|
|
];
|
|
|
|
dontUseCmakeConfigure = true;
|
|
env = buildEnv;
|
|
# Desktop and installed-model tests are #[ignore]; run the remaining suite.
|
|
doCheck = true;
|
|
# Hex's suite keeps process-global state (the lab switches, a model download
|
|
# in flight), while CI and `scripts/check` run nextest, which isolates each
|
|
# test in its own process. Plain `cargo test` shares one process, so let
|
|
# cargoCheckHook run it one test at a time (it sets RUST_TEST_THREADS=1).
|
|
dontUseCargoParallelTests = true;
|
|
preCheck = ''
|
|
export HOME="$TMPDIR/hex-test-home"
|
|
mkdir -p "$HOME"
|
|
'';
|
|
|
|
postInstall = ''
|
|
install -Dm644 ${../packaging/anomaly.hex.desktop} $out/share/applications/anomaly.hex.desktop
|
|
mkdir -p $out/share/icons
|
|
cp -R ${../packaging/linux/icons/hicolor} $out/share/icons/hicolor
|
|
substituteInPlace $out/share/applications/anomaly.hex.desktop \
|
|
--replace-fail '@HEX_BIN@' "$out/bin/hex"
|
|
'';
|
|
|
|
postFixup = ''
|
|
wrapProgram $out/bin/hex \
|
|
--prefix PATH : ${lib.makeBinPath runtimePackages} \
|
|
--prefix LD_LIBRARY_PATH : ${runtimeEnv.LD_LIBRARY_PATH} \
|
|
--set ALSA_PLUGIN_DIR ${runtimeEnv.ALSA_PLUGIN_DIR}
|
|
'';
|
|
|
|
passthru.devShell = mkShell {
|
|
inputsFrom = [ finalAttrs.finalPackage ];
|
|
env = buildEnv // runtimeEnv;
|
|
packages = runtimePackages ++ [
|
|
rust-analyzer
|
|
rustfmt
|
|
clippy
|
|
];
|
|
};
|
|
|
|
meta = {
|
|
description = "Local-first voice dictation (Linux beta)";
|
|
homepage = "https://anoma.ly/hex/";
|
|
license = lib.licenses.mit;
|
|
mainProgram = "hex";
|
|
platforms = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
];
|
|
};
|
|
})
|