tally/nix/package.nix
Emil Lerch 3c9ec72b88
All checks were successful
Build / Engine, CLI and TUI (push) Successful in 1m56s
Build / Android (push) Successful in 5m59s
Build / Sign (push) Successful in 3m38s
Build / Publish (push) Successful in 12s
add nix flake/fix release mode tests
2026-10-04 15:01:16 -07:00

57 lines
2.2 KiB
Nix

{ lib, stdenv, zig, src }:
stdenv.mkDerivation (finalAttrs: {
pname = "tally";
# Kept in step with build.zig.zon.
version = "0.1.0";
inherit src;
__structuredAttrs = true;
strictDeps = true;
# Zig resolves build.zig.zon dependencies (libvaxis) over the network, which the
# build sandbox forbids. `fetchDeps` runs `zig build --fetch` inside a fixed-output
# derivation, so the fetch happens once against a known hash and the real build
# stays offline.
#
# This hash changes whenever build.zig.zon's dependencies change. To update it: set
# `lib.fakeHash`, run the build, and paste the hash nix reports.
zigDeps = zig.fetchDeps {
inherit (finalAttrs) pname version src;
fetchAll = true;
hash = "sha256-Wy/H3z2dBsF/WTF2LrCofOuE15pbgdwEJLSUrKCOQGI=";
};
postConfigure = ''
# A writable copy rather than a symlink into the store: Zig writes cache
# metadata alongside the fetched packages while it verifies them.
cp -rLT ${finalAttrs.zigDeps} "$ZIG_GLOBAL_CACHE_DIR/p"
chmod -R u+w "$ZIG_GLOBAL_CACHE_DIR/p"
'';
nativeBuildInputs = [ zig ];
# The zig setup hook's check phase runs `zig build test`, with the same flags as the
# build (ReleaseSafe): the engine, CLI, TUI, C ABI and JNI tests, and the C program
# linked through tally.h. None of them touch the network or anything outside the
# build directory, so every rebuild is a test run. (`jvm-test`, `coverage` and
# `android` are separate steps, not run here.)
doCheck = true;
meta = {
description = "Calculator with exact arithmetic, unit conversion and a programmer mode, as a CLI and TUI";
longDescription = ''
One Zig engine behind a command line, a terminal UI and an Android app:
exact rational arithmetic where the operations allow it, programmer mode
(8 to 128-bit integers in every base), unit conversion as part of the
expression language, and financial functions. This package is the CLI/TUI
binary, plus the engine as a static library and as a shared library with
its C header (tally.h).
'';
homepage = "https://git.lerch.org/lobo/tally";
license = lib.licenses.mit;
mainProgram = "tally";
platforms = lib.platforms.unix;
};
})