Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

88.19. fx-39.2.0

Interactive viewer and processor for JSON and YAML

Version 39.2.0, release 1
Shelf formats — Data-format and serialisation libraries (XML, JSON, YAML, TOML, INI, RDF, protobuf, thrift), plus data query and convert tools
Phase 41_system (System), 549 of 1047 in build order
Licence MIT
Homepage https://fx.wtf/
Build time 0.4 SBU
Installed size 14.1 MiB in 3 files
Recipe ports/core/formats/fx/kpkgbuild

About

fx is an interactive terminal viewer for JSON and YAML: it opens a document as a tree to fold, expand and search, and it also takes JavaScript expressions on the command line to transform the data. Where jq answers a question about a document whose shape is known, fx is for exploring one that is not. It is a single Go binary, built without cgo; the recipe writes a terminal desktop entry, “JSON Viewer”, that opens a file in it. The entry claims application/json and is NoDisplay=true: with no file fx prints its usage and exits, so it is offered under Open With and has no Start row. Kate stays the type’s default in kde-mimeapps.list.

Why it is in KDOS

The comment above it in script/phases/41_system/packages.d/formats.txt:

jq answers a question; this BROWSES the document — fold, search, and a JS expression when the shape is not known yet. Go, so no X clipboard crate follows it in.

Sources

Dependencies

Depends on: go.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install fx'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/formats/fx.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/formats/fx
echo 'cdb98177f956615c961bc615fab0b30e73167295152d4f2d4cb70b16cdf47d6e  fx-39.2.0.tar.gz' | sha256sum -c -
echo 'a5e2789a2f7052c21d3c2f88bfaffebf57134d92195fa3704470afee189110d9  fx-vendor-39.2.0.tar.xz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/fx
SRC=$SRC_ROOT/fx-39.2.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf fx-39.2.0.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz

export CGO_ENABLED=0
go build -mod=vendor -ldflags "-s -w" -o fx
install -Dm755 fx $PKG/usr/bin/fx

install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/fx.desktop" <<'ENTRY'
[Desktop Entry]
Type=Application
Name=JSON Viewer
GenericName=Data Viewer
Comment=Browse, fold and query JSON and YAML
Exec=fx %f
Icon=text-x-generic
Terminal=true
NoDisplay=true
MimeType=application/json;
Categories=Development;Utility;
Keywords=json;yaml;viewer;jq;query;fx;
ENTRY
chmod 644 "$PKG/usr/share/applications/fx.desktop"

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/fx, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf fx-39.2.0-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/fx, and runs the triggers its paths call for.

Contents

Installed programs: fx.

Installed directories: /usr/share/licenses/fx.

Notes

The Go modules come from the vendor bundle, fx-vendor-<version>.tar.xz, made by go mod vendor and pinned by its own sha256 = line; go build -mod=vendor builds from it offline (see Vendoring).