Files
wayscriber/flake.nix
T
devmobasa 1dafb9385b docs: add nextest as the fast local test run
The local gate serializes tests because of a native font race. nextest
gives each test its own process, so the whole suite can run in parallel
while iterating. It is local only: it skips doctests and the isolated
render tests, so the gate stays as it is. Add it to the Nix shell.
2026-10-30 19:25:15 +01:00

161 lines
6.1 KiB
Nix

{
description = "Wayscriber - Screen annotation tool for Wayland";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
# Linux only. eachDefaultSystem also evaluates x86_64-darwin, which
# nixpkgs 26.11 dropped.
flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-linux" ] (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
version = cargoToml.package.version;
rustVersion = cargoToml.package.rust-version;
rustToolchain = pkgs.rust-bin.stable.${rustVersion}.default.override {
extensions = [ "rust-analyzer" ];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
};
servicePath = pkgs.lib.makeBinPath [ pkgs.grim pkgs.slurp pkgs.wl-clipboard ];
developmentInputs = with pkgs; [
rustToolchain
cargo-deny
cargo-nextest
util-linux
pkg-config
cairo
pango
wayland
libxkbcommon
gtk4
gtk4-layer-shell
libadwaita
];
in
# Instantiation (and CI `nix eval`) must fail before cargoBuildHook
# when the selected compiler lags Cargo.toml's rust-version.
assert pkgs.lib.assertMsg
(pkgs.lib.versionAtLeast rustToolchain.version rustVersion)
"selected rustc ${rustToolchain.version} is older than Cargo.toml rust-version ${rustVersion}; run `nix flake update rust-overlay`.";
{
packages = {
wayscriber = rustPlatform.buildRustPackage {
pname = "wayscriber";
inherit version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = with pkgs; [
pkg-config
wrapGAppsHook4
];
buildInputs = with pkgs; [
cairo
pango
wayland
libxkbcommon
gtk4
gtk4-layer-shell
];
postInstall = ''
install -Dm644 packaging/wayscriber.desktop $out/share/applications/wayscriber.desktop
install -Dm644 packaging/wayscriber.service $out/lib/systemd/user/wayscriber.service
substituteInPlace $out/lib/systemd/user/wayscriber.service \
--replace-fail "/bin/sh" "${pkgs.runtimeShell}" \
--replace-fail "/usr/bin/wayscriber" "$out/bin/wayscriber" \
--replace-fail "/usr/local/bin:/usr/bin:/bin" \
"${servicePath}:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:%h/.nix-profile/bin"
for size in 16 19 22 24 38 64 128; do
for category in apps status; do
install -Dm644 packaging/icons/wayscriber-$size.png \
$out/share/icons/hicolor/''${size}x''${size}/''${category}/wayscriber.png
done
done
install -Dm644 packaging/icons/wayscriber-128.png $out/share/pixmaps/wayscriber.png
install -Dm644 packaging/icons/wayscriber.svg \
$out/share/icons/hicolor/scalable/apps/wayscriber.svg
install -Dm644 packaging/icons/wayscriber-symbolic.svg \
$out/share/icons/hicolor/symbolic/apps/wayscriber-symbolic.svg
install -Dm644 config.example.toml $out/share/doc/wayscriber/config.example.toml
install -Dm644 README.md $out/share/doc/wayscriber/README.md
install -Dm644 LICENSE $out/share/licenses/wayscriber/LICENSE
'';
meta = with pkgs.lib; {
description = "Screen annotation tool for Wayland compositors";
homepage = "https://wayscriber.com";
license = licenses.mit;
platforms = platforms.linux;
mainProgram = "wayscriber";
};
};
wayscriber-configurator = rustPlatform.buildRustPackage {
pname = "wayscriber-configurator";
inherit version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
buildAndTestSubdir = "configurator";
nativeBuildInputs = with pkgs; [ pkg-config wrapGAppsHook4 ];
# GTK4/libadwaita GUI toolkit dependencies
buildInputs = with pkgs; [
cairo
pango
wayland
libxkbcommon
gtk4
libadwaita
];
postInstall = ''
install -Dm644 packaging/wayscriber-configurator.desktop \
$out/share/applications/wayscriber-configurator.desktop
for size in 24 64 128; do
install -Dm644 packaging/icons/wayscriber-configurator-$size.png \
$out/share/icons/hicolor/''${size}x''${size}/apps/wayscriber-configurator.png
done
install -Dm644 packaging/icons/wayscriber-configurator-128.png \
$out/share/pixmaps/wayscriber-configurator.png
install -Dm644 packaging/icons/wayscriber-configurator.svg \
$out/share/icons/hicolor/scalable/apps/wayscriber-configurator.svg
install -Dm644 README.md $out/share/doc/wayscriber-configurator/README.md
install -Dm644 LICENSE $out/share/licenses/wayscriber-configurator/LICENSE
'';
meta = with pkgs.lib; {
description = "GUI configurator for wayscriber";
homepage = "https://wayscriber.com";
license = licenses.mit;
platforms = platforms.linux;
mainProgram = "wayscriber-configurator";
};
};
default = self.packages.${system}.wayscriber;
};
devShells.default = pkgs.mkShell {
buildInputs = developmentInputs;
};
});
}