0.1.1: .deb and Nix packages, builds for glibc 2.35 with zig

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-26 18:22:56 -06:00
commit 46ccb1df58
10 changed files with 247 additions and 36 deletions

2
Cargo.lock generated
View file

@ -782,7 +782,7 @@ checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
[[package]]
name = "damson"
version = "0.1.0"
version = "0.1.1"
dependencies = [
"alacritty_terminal",
"dirs",

View file

@ -1,6 +1,6 @@
[package]
name = "damson"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
description = "A Material You code editor with 462 languages built in"
license = "MIT"

View file

@ -80,19 +80,18 @@ Vi mode, spell checking, snippets, and reopening a file with a chosen encoding.
## Install a release
Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases): Linux x86_64 only. The binaries are built on Arch Linux and need
**glibc 2.43 or newer**, so they run on Arch and other up-to-date rolling distributions; older distributions
(Debian, Ubuntu LTS, Fedora releases with an older glibc) cannot run them and should build from source.
Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases) (Linux x86_64); check them against `SHA256SUMS-<version>`. The Linux builds
are made on Arch Linux and need a recent glibc (the version is named in the packages and checked by the installer),
so they run on Arch and other up-to-date distributions; on older ones, build from source.
- **Arch Linux:** `sudo pacman -U Damson-0.1.0-arch-x86_64.pkg.tar.zst` (package `damson-bin`; remove it with
`sudo pacman -R damson-bin`).
- **Installer (any distribution):** put `installer.sh` next to the downloaded tar.gz or AppImage and
`SHA256SUMS-0.1.0`, then run `sh installer.sh` (your home, `~/.local`, no root) or `sh installer.sh --system`
(`/usr/local`, sudo only for the copy). It checks the checksum and refuses, in plain words, when glibc is too old.
`sh installer.sh --uninstall` removes it; add `--purge` to delete settings and data too.
- **tar.gz:** unpack it, then `./install.sh` inside the folder (same options as `installer.sh`) and later
`./uninstall.sh` (`--purge` for settings and data).
- **AppImage:** `chmod +x Damson-0.1.0-x86_64.AppImage` and run it. System libraries are not bundled.
- **Arch Linux:** `sudo pacman -U Damson-<version>-arch-x86_64.pkg.tar.zst` (package `damson-bin`; remove it with
`sudo pacman -R damson-bin`). `packaging/arch/PKGBUILD` builds the same package from the release.
- **Debian, Ubuntu and other apt systems:** `sudo apt install ./Damson-<version>-amd64.deb`.
- **Nix:** `nix profile install git+https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson` (this repo is a flake), or `callPackage ./packaging/nix { }`.
- **Any distribution:** unpack `Damson-<version>-Linux-x86_64.tar.gz` and run `sh install.sh` inside (your home,
`~/.local`, no root) or `sh install.sh --system` (`/usr/local`). `sh uninstall.sh` removes it; `--purge` also
deletes settings and data. `installer.sh` from this repo does the same next to a downloaded tar.gz or AppImage.
- **AppImage:** `chmod +x Damson-<version>-x86_64.AppImage` and run it. System libraries are not bundled.
## Install from source

14
docs/releases/0.1.1.md Normal file
View file

@ -0,0 +1,14 @@
# Damson 0.1.1
First published release (0.1.0 was packaged but never uploaded). Linux x86_64 only.
A Material You code editor with 462 languages built in: the scrolling preview rail, multi-cursor, folding, split view,
find and replace, search in files, outline, a git panel, hot exit, and language servers when they are installed.
- **New icon colour:** the icon is leaf green instead of purple, so it stands apart from the other apps in a dock.
- **Packages:** AppImage, tar.gz with `install.sh`/`uninstall.sh`, Arch package `damson-bin`, Debian/Ubuntu `.deb`
and a Nix flake. `installer.sh` from the repository installs the tar.gz or AppImage into `~/.local` or `/usr/local`.
## Known gaps
- Built on Arch: needs a recent glibc (named in the packages); older distributions must build from source.
- Not done yet: vi mode, spell checking, snippets, reopening with a chosen encoding; one window per launch.

10
flake.nix Normal file
View file

@ -0,0 +1,10 @@
{
description = "Material You code editor with 462 languages built in";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
packages.x86_64-linux.default = pkgs.callPackage ./packaging/nix { };
apps.x86_64-linux.default = { type = "app"; program = "${self.packages.x86_64-linux.default}/bin/damson"; };
};
}

View file

@ -6,10 +6,10 @@
# Without FILE it uses the unpacked release folder it sits in, or Damson-*-Linux-x86_64.tar.gz or
# Damson-*-x86_64.AppImage next to it. SHA256SUMS-<version> beside the file is checked when present.
# --purge also deletes settings and data (~/.config/damson: settings and recovery copies). DESTDIR=dir stages under dir (no sudo).
# Needs glibc 2.43 or newer.
# Needs glibc 2.35 or newer.
set -eu
app=damson main=damson need=2.43
app=damson main=damson need=2.35
mode=install scope=user purge=0 prefix= url= file=
while [ $# -gt 0 ]; do
case $1 in

View file

@ -1,11 +1,11 @@
pkgbase = damson-bin
pkgdesc = Material You code editor with 462 languages built in
pkgver = 0.1.0
pkgver = 0.1.1
pkgrel = 1
url = https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson
arch = x86_64
license = MIT
depends = glibc>=2.43
depends = glibc>=2.35
depends = gcc-libs
depends = dbus
depends = fontconfig
@ -33,7 +33,7 @@ pkgbase = damson-bin
conflicts = damson
options = !strip
options = !debug
source = Damson-0.1.0-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases/download/v0.1.0/Damson-0.1.0-Linux-x86_64.tar.gz
sha256sums = b5c5b113b8c66f37de0b1ef02a83b918be8f15aef763ad128f072ad80b0156be
source = Damson-0.1.1-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases/download/v0.1.1/Damson-0.1.1-Linux-x86_64.tar.gz
sha256sums = 735e34e69160620da8cc9e930401d677eb938a68d7ffe4c505fa9d99b3af5d39
pkgname = damson-bin

View file

@ -2,14 +2,14 @@
# Built by tools/package.sh from the release tar.gz (TARBALL=file://… for an offline build); it keeps pkgver,
# sha256sums and the glibc floor current.
pkgname=damson-bin
pkgver=0.1.0
pkgver=0.1.1
pkgrel=1
pkgdesc='Material You code editor with 462 languages built in'
arch=('x86_64')
url='https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson'
license=('MIT')
# Linked: libc, libm, libgcc_s. dlopened (strings of the binary): libEGL/libGL (libglvnd), libwayland-client/-egl, libxkbcommon(-x11), libX11, libX11-xcb, libxcb, libXcursor, libXi, libXrender, libfontconfig, libdbus-1. Runs fc-match (fontconfig); git only for the git panel.
depends=('glibc>=2.43' 'gcc-libs' 'dbus' 'fontconfig' 'libglvnd' 'wayland' 'libxkbcommon' 'libxkbcommon-x11' 'libx11' 'libxcb' 'libxcursor' 'libxi' 'libxrender' 'hicolor-icon-theme')
depends=('glibc>=2.35' 'gcc-libs' 'dbus' 'fontconfig' 'libglvnd' 'wayland' 'libxkbcommon' 'libxkbcommon-x11' 'libx11' 'libxcb' 'libxcursor' 'libxi' 'libxrender' 'hicolor-icon-theme')
optdepends=(
'xdg-desktop-portal: open and save dialogs'
'git: the git panel and changed lines'
@ -26,7 +26,7 @@ provides=('damson')
conflicts=('damson')
options=('!strip' '!debug')
source=("Damson-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Damson-$pkgver-Linux-x86_64.tar.gz}")
sha256sums=('b5c5b113b8c66f37de0b1ef02a83b918be8f15aef763ad128f072ad80b0156be')
sha256sums=('735e34e69160620da8cc9e930401d677eb938a68d7ffe4c505fa9d99b3af5d39')
package() {
cd "$srcdir/damson-$pkgver"

33
packaging/nix/default.nix Normal file
View file

@ -0,0 +1,33 @@
# Damson for Nix, from the release tar.gz. Written by tools/package.sh (version and hash); edit the header there.
# nix build .#default or nix profile install . (from the repo), or callPackage this file.
{ lib, stdenv, fetchurl, autoPatchelfHook, makeWrapper, libGL, wayland, libxkbcommon, xorg, fontconfig, dbus }:
stdenv.mkDerivation rec {
pname = "damson";
version = "0.1.1";
src = fetchurl {
url = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases/download/v${version}/Damson-${version}-Linux-x86_64.tar.gz";
hash = "sha256-c1405pFgYg2ozJ6TBAHWd+uTimjX/+TFBfqdmbOvXTk=";
};
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
buildInputs = [ stdenv.cc.cc.lib ];
# Loaded with dlopen at run time, so autoPatchelf can't see them.
runtimeDependencies = [ libGL wayland libxkbcommon xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr fontconfig dbus ];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
for d in bin lib share; do [ ! -d $d ] || cp -R $d $out/; done
install -Dm644 README.md $out/share/doc/damson/README.md
runHook postInstall
'';
meta = {
description = "Material You code editor with 462 languages built in";
homepage = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson";
license = lib.licenses.mit;
platforms = [ "x86_64-linux" ];
mainProgram = "damson";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}

View file

@ -3,9 +3,15 @@
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
APP=damson NAME=Damson DESKTOP=damson.desktop
BINS=(damson)
URL=https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson
ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1)
build() { nice cargo build --release --locked -q -j 2; }
BINS=(damson)
LICENSE=MIT NIX_LICENSE=mit SUMMARY='Material You code editor with 462 languages built in'
DEB_DEPENDS='libgl1, libegl1, libwayland-client0, libwayland-egl1, libxkbcommon0, libxkbcommon-x11-0, libx11-6, libxcursor1, libxi6, libxrandr2, libfontconfig1, libdbus-1-3' DEB_RECOMMENDS='git, xdg-desktop-portal' DEB_SECTION=editors
NIX_ARGS='libGL, wayland, libxkbcommon, xorg, fontconfig, dbus' NIX_RUNTIME='libGL wayland libxkbcommon xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr fontconfig dbus' NIX_BUILD_INPUTS='stdenv.cc.cc.lib'
WIN=0 # Damson uses Unix sockets (Discord) and sudo saves; no Windows port yet
ZIG_GLIBC=2.35
build() { nice cargo zigbuild --release --locked -q -j 2 --target x86_64-unknown-linux-gnu.$ZIG_GLIBC; }
# share/ as it lands under the prefix
stage() {
local s=$1 b=$rel/damson
@ -19,28 +25,57 @@ stage() {
install -Dm644 assets/syntax/LICENSES.md "$s/licenses/damson/syntax-definitions.md"
install -Dm644 assets/syntax/KSyntaxHighlighting-MIT.txt "$s/licenses/damson/KSyntaxHighlighting-MIT.txt"
}
stage() {
local s=$1 b=$rel/damson
install -Dm644 packaging/damson.desktop "$s/applications/damson.desktop"
install -Dm644 packaging/damson.metainfo.xml "$s/metainfo/damson.metainfo.xml"
install -Dm644 packaging/damson.svg "$s/icons/hicolor/scalable/apps/damson.svg"
for n in 16 24 32 48 64 128 256 512; do
mkdir -p "$s/icons/hicolor/${n}x$n/apps"; "$b" --export-icon "$n" "$s/icons/hicolor/${n}x$n/apps/damson.png"
done
install -Dm644 LICENSE "$s/licenses/damson/LICENSE"
install -Dm644 assets/syntax/LICENSES.md "$s/licenses/damson/syntax-definitions.md"
install -Dm644 assets/syntax/KSyntaxHighlighting-MIT.txt "$s/licenses/damson/KSyntaxHighlighting-MIT.txt"
}
# ---------------------------------------------------------------- common part (same in every project)
# Builds into dist/: $NAME-<v>-Linux-x86_64.tar.gz (install.sh, uninstall.sh), $NAME-<v>-x86_64.AppImage (GUI only),
# $NAME-<v>-arch-x86_64.pkg.tar.zst (makepkg from that tar.gz, offline) and SHA256SUMS-<v>.
# It also writes the tar.gz checksum and version into $PKGDIR/PKGBUILD and .SRCINFO, and the glibc floor read
# from the binary into installer.sh and the PKGBUILD. Nothing is downloaded: appimagetool comes from
# ~/Projects/Mulberry/dist and runs extracted (no FUSE, no runtime fetch). Never writes to releases/.
# SKIP_BUILD=1 packages the existing build. CARGO_TARGET_DIR is honoured.
# Builds into dist/ (and never writes to releases/):
# $NAME-<v>-Linux-x86_64.tar.gz bin/ share/ [lib/] laid out like a prefix, with install.sh and uninstall.sh
# $NAME-<v>-x86_64.AppImage GUI apps (DESKTOP set); BUNDLE_LIBS=1 adds the non-desktop library closure
# $NAME-<v>-arch-x86_64.pkg.tar.zst makepkg from that tar.gz, offline ($PKGDIR/PKGBUILD gets version and checksum)
# $NAME-<v>-amd64.deb the same tree under /usr, for apt
# $NAME-<v>-Setup.exe and $NAME-<v>-Windows-portable.zip when WIN=1 (mingw cross build, Inno Setup in wine)
# SHA256SUMS-<v>
# It also writes packaging/nix/default.nix (fetches the release tar.gz; version and hash filled in here) and the
# glibc floor read from the binary into installer.sh, the PKGBUILD and the .deb. Nothing is downloaded: appimagetool
# and libmpv-2.dll come from ~/.local/opt/build-tools.
# SKIP_BUILD=1 packages the existing build, NO_WIN=1 skips Windows. CARGO_TARGET_DIR is honoured.
cd "$root"; PKGDIR=${PKGDIR:-packaging/arch}
tools=${BUILD_TOOLS:-$HOME/.local/opt/build-tools}
[ "${SKIP_BUILD:-}" = 1 ] || build
rel=${CARGO_TARGET_DIR:-$root/target}/release
tdir=${CARGO_TARGET_DIR:-$root/target}
rel=$tdir/release
# ZIG_GLIBC: built with cargo-zigbuild against that glibc, so the binary runs on older distributions too.
[ -z "${ZIG_GLIBC:-}" ] || rel=$tdir/x86_64-unknown-linux-gnu/release
out=$root/dist
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}"; work=$(mktemp -d "${XDG_CACHE_HOME:-$HOME/.cache}/package.XXXXXX"); trap 'rm -rf "$work"' EXIT
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git log -1 --format=%ct 2>/dev/null || date +%s)}
# hicolor PNGs from an SVG: icon_pngs <svg> <share dir> <icon name>
icon_pngs() {
install -Dm644 "$1" "$2/icons/hicolor/scalable/apps/$3.svg"
for n in 16 24 32 48 64 128 256 512; do
mkdir -p "$2/icons/hicolor/${n}x$n/apps"; rsvg-convert -w "$n" -h "$n" "$1" -o "$2/icons/hicolor/${n}x$n/apps/$3.png"
done
}
# glibc floor: the newest GLIBC_x.y symbol version any shipped binary (or EXTRA_ELF library) needs.
glibc=$(for b in "${BINS[@]}" ${EXTRA_ELF[@]+"${EXTRA_ELF[@]}"}; do objdump -T "$rel/$b"; done | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -n 1)
[ -n "$glibc" ] || { echo "could not read the glibc version from the binary" >&2; exit 1; }
sed -i "s/^app=$APP main=\([^ ]*\) need=.*/app=$APP main=\1 need=$glibc/; s/glibc [0-9.]* or newer\./glibc $glibc or newer./" installer.sh
sed -i "s/'glibc>=[0-9.]*'/'glibc>=$glibc'/" $PKGDIR/PKGBUILD
# tar.gz: bin/ and share/ laid out like a prefix, so installer.sh and the PKGBUILD just copy them.
# tar.gz: bin/ and share/ laid out like a prefix, so installer.sh, the PKGBUILD, the .deb and Nix just copy them.
rm -rf "$out"; mkdir -p "$out"
t=$work/$APP-$ver
mkdir -p "$t/bin" "$t/share" # stage may add $t/lib too
@ -59,6 +94,14 @@ if [ -n "${DESKTOP:-}" ]; then
a=$work/AppDir
mkdir -p "$a/usr"
cp -R "$t/bin" "$t/share" "$a/usr/"; [ ! -d "$t/lib" ] || cp -R "$t/lib" "$a/usr/"
if [ "${BUNDLE_LIBS:-0}" = 1 ]; then
# Libraries every desktop already has (glibc, graphics, windowing, sound servers, fonts) stay with the host.
skip='^(linux-vdso|ld-linux|libc|libm|libdl|libpthread|librt|libutil|libresolv|libnsl|libgcc_s|libstdc\+\+|libGL|libGLX|libGLdispatch|libEGL|libOpenGL|libGLESv2|libgbm|libdrm|libvulkan|libX11|libX11-xcb|libxcb.*|libXau|libXdmcp|libXext|libXfixes|libXrandr|libXrender|libXi|libXcursor|libXss|libXv|libXxf86vm|libXinerama|libwayland-.*|libxkbcommon.*|libfontconfig|libfreetype|libharfbuzz|libglib-2.0|libgobject-2.0|libgio-2.0|libgmodule-2.0|libdbus-1|libsystemd|libudev|libasound|libpulse.*|libpipewire-0.3|libjack|libsndio|libcap|libselinux|libpcre2-8|libffi|libz|libexpat|libnss.*)\.so'
mkdir -p "$a/usr/lib"
ldd "$rel/${BINS[0]}" | awk '/=> \//{print $3} $1 ~ /^\// {print $1}' | while read -r lib; do
name=$(basename "$lib"); [[ $name =~ $skip ]] || cp -L "$lib" "$a/usr/lib/$name"
done
fi
cp "$a/usr/share/applications/$DESKTOP" "$a/"
icon=$(sed -n 's/^Icon=//p' "$a/$DESKTOP" | head -n 1)
for ext in svg png; do
@ -68,10 +111,11 @@ if [ -n "${DESKTOP:-}" ]; then
cat > "$a/AppRun" <<RUN
#!/bin/sh
here=\$(dirname "\$(readlink -f "\$0")")
[ ! -d "\$here/usr/lib" ] || [ "${BUNDLE_LIBS:-0}" != 1 ] || export LD_LIBRARY_PATH="\$here/usr/lib\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}"
exec "\$here/usr/bin/${BINS[0]}" "\$@"
RUN
chmod +x "$a/AppRun"
cp ~/Projects/Mulberry/dist/appimagetool "$work/appimagetool"
cp "$tools/appimagetool" "$work/appimagetool"
(cd "$work" && ./appimagetool --appimage-extract >/dev/null)
ARCH=x86_64 "$work/squashfs-root/AppRun" --no-appstream "$a" "$out/$NAME-$ver-x86_64.AppImage" >"$work/ait.log" 2>&1 \
|| { tail -20 "$work/ait.log"; exit 1; }
@ -85,6 +129,117 @@ mkdir "$work/arch"; cp $PKGDIR/PKGBUILD "$work/arch/"
(cd "$work/arch" && TARBALL="file://$out/$tgz" makepkg -f -C --nodeps --noconfirm >"$work/makepkg.log" 2>&1) \
|| { tail -20 "$work/makepkg.log"; exit 1; }
cp "$work"/arch/"$APP"-bin-"$ver"-*-x86_64.pkg.tar.zst "$out/$NAME-$ver-arch-x86_64.pkg.tar.zst"
# .deb: the tar.gz tree under /usr (licenses go to /usr/share/doc/<pkg>/ as Debian expects).
d=$work/deb
mkdir -p "$d/root/usr" "$d/root/usr/share/doc/$APP" "$d/control"
for x in bin lib share; do [ ! -d "$t/$x" ] || cp -R "$t/$x" "$d/root/usr/"; done
if [ -d "$d/root/usr/share/licenses/$APP" ]; then
cp -R "$d/root/usr/share/licenses/$APP/." "$d/root/usr/share/doc/$APP/"; rm -rf "$d/root/usr/share/licenses"
fi
cp README.md "$d/root/usr/share/doc/$APP/"
{ echo "Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"; echo "Upstream-Name: $NAME"
echo "Source: $URL"; echo; echo "Files: *"; echo "License: $LICENSE"; } > "$d/root/usr/share/doc/$APP/copyright"
size=$(du -sk "$d/root" | cut -f1)
cat > "$d/control/control" <<CTL
Package: $APP
Version: $ver
Architecture: amd64
Maintainer: astar76 <[email protected]>
Installed-Size: $size
Depends: libc6 (>= $glibc)${DEB_DEPENDS:+, $DEB_DEPENDS}
${DEB_RECOMMENDS:+Recommends: $DEB_RECOMMENDS
}Section: ${DEB_SECTION:-misc}
Priority: optional
Homepage: $URL
Description: $SUMMARY
Built from $URL (version $ver). Needs glibc $glibc or newer.
CTL
(cd "$d/root" && find . -type f -printf '%P\n' | sort | xargs -d '\n' md5sum) > "$d/control/md5sums"
find "$d/root" "$d/control" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
echo 2.0 > "$d/debian-binary"
tar -C "$d/control" --sort=name --owner=0 --group=0 --numeric-owner -czf "$d/control.tar.gz" .
tar -C "$d/root" --sort=name --owner=0 --group=0 --numeric-owner -cJf "$d/data.tar.xz" .
deb=$out/$NAME-$ver-amd64.deb
(cd "$d" && ar rcD "$deb" debian-binary control.tar.gz data.tar.xz)
! command -v dpkg-deb >/dev/null || dpkg-deb --info "$deb" >/dev/null
# Nix: packaging/nix/default.nix fetches this release's tar.gz (flake.nix at the top calls it).
mkdir -p packaging/nix
sri=sha256-$(openssl dgst -sha256 -binary "$out/$tgz" | base64 -w0)
cat > packaging/nix/default.nix <<NIX
# $NAME for Nix, from the release tar.gz. Written by tools/package.sh (version and hash); edit the header there.
# nix build .#default or nix profile install . (from the repo), or callPackage this file.
{ lib, stdenv, fetchurl, autoPatchelfHook, makeWrapper${NIX_ARGS:+, $NIX_ARGS} }:
stdenv.mkDerivation rec {
pname = "$APP";
version = "$ver";
src = fetchurl {
url = "$URL/releases/download/v\${version}/$NAME-\${version}-Linux-x86_64.tar.gz";
hash = "$sri";
};
nativeBuildInputs = [ autoPatchelfHook makeWrapper${NIX_NATIVE:+ $NIX_NATIVE} ];
buildInputs = [ ${NIX_BUILD_INPUTS:-} ];
# Loaded with dlopen at run time, so autoPatchelf can't see them.
runtimeDependencies = [ ${NIX_RUNTIME:-} ];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p \$out
for d in bin lib share; do [ ! -d \$d ] || cp -R \$d \$out/; done
install -Dm644 README.md \$out/share/doc/$APP/README.md
runHook postInstall
'';
${NIX_EXTRA:-}
meta = {
description = "$SUMMARY";
homepage = "$URL";
license = lib.licenses.$NIX_LICENSE;
platforms = [ "x86_64-linux" ];
mainProgram = "${BINS[0]}";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}
NIX
[ -f flake.nix ] || cat > flake.nix <<FLK
{
description = "$SUMMARY";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
packages.x86_64-linux.default = pkgs.callPackage ./packaging/nix { };
apps.x86_64-linux.default = { type = "app"; program = "\${self.packages.x86_64-linux.default}/bin/${BINS[0]}"; };
};
}
FLK
# Windows: mingw cross build, a one-folder app zipped as the portable build, and a per-user Inno Setup installer.
if [ "${WIN:-0}" = 1 ] && [ "${NO_WIN:-}" != 1 ]; then
command -v x86_64-w64-mingw32-gcc >/dev/null || { echo "Windows needs mingw-w64-gcc (sudo pacman -S mingw-w64-gcc), or NO_WIN=1." >&2; exit 1; }
if [ -n "${WIN_DLLS[*]:-}" ] && [ "${WIN_MPV:-0}" = 1 ]; then
# import library for libmpv-2.dll, so the cross linker can link "mpv"
lib=$tools/winlib; mkdir -p "$lib"
if [ ! -f "$lib/libmpv.dll.a" ]; then
{ echo "LIBRARY libmpv-2.dll"; echo EXPORTS
x86_64-w64-mingw32-objdump -p "$tools/libmpv-2.dll" | sed -n '/\[Ordinal\/Name Pointer\] Table/,/^$/p' | awk '/^\s*\[ *[0-9]+\] \+base/ {print $NF}'; } > "$lib/mpv.def"
x86_64-w64-mingw32-dlltool -d "$lib/mpv.def" -D libmpv-2.dll -l "$lib/libmpv.dll.a"
fi
export RUSTFLAGS="${RUSTFLAGS:-} -L $lib"
fi
[ "${SKIP_BUILD:-}" = 1 ] || nice cargo build --release --locked -q -j 2 --target x86_64-pc-windows-gnu
w=$work/win/$NAME; mkdir -p "$w"
for b in "${BINS[@]}"; do install -m755 "$tdir/x86_64-pc-windows-gnu/release/$b.exe" "$w/"; done
for f in ${WIN_DLLS[@]+"${WIN_DLLS[@]}"}; do install -m644 "$tools/$f" "$w/"; done
install -m644 LICENSE "$w/LICENSE.txt"
find "$work/win" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
(cd "$work/win" && zip -qrX9 "$out/$NAME-$ver-Windows-portable.zip" "$NAME")
iscc="$HOME/.wine/drive_c/users/$USER/AppData/Local/Programs/Inno Setup 7/ISCC.exe"
WINEDEBUG=-all wine "$iscc" /Q "/DVersion=$ver" "/DSrc=Z:$w" "/DOut=Z:$out" "Z:$root/packaging/$APP.iss" >"$work/iscc.log" 2>&1 \
|| { tail -20 "$work/iscc.log"; exit 1; }
fi
(cd "$out" && sha256sum "$NAME-$ver"-* > "SHA256SUMS-$ver")
echo "glibc floor: $glibc"
ls -l "$out"