2020-12-20 16:28:44 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchzip
|
|
|
|
, fetchurl
|
|
|
|
, runCommandNoCC
|
|
|
|
, fcft
|
|
|
|
, freetype
|
|
|
|
, pixman
|
|
|
|
, libxkbcommon
|
|
|
|
, fontconfig
|
|
|
|
, wayland
|
|
|
|
, meson
|
|
|
|
, ninja
|
|
|
|
, ncurses
|
|
|
|
, scdoc
|
|
|
|
, tllist
|
|
|
|
, wayland-protocols
|
|
|
|
, pkg-config
|
|
|
|
, allowPgo ? true
|
|
|
|
, python3 # for PGO
|
2020-08-15 01:32:39 +02:00
|
|
|
}:
|
|
|
|
|
2020-12-20 16:28:44 +01:00
|
|
|
let
|
2021-02-12 23:30:50 +01:00
|
|
|
version = "1.6.4";
|
2020-12-20 16:28:44 +01:00
|
|
|
|
|
|
|
# build stimuli file for PGO build and the script to generate it
|
|
|
|
# independently of the foot's build, so we can cache the result
|
|
|
|
# and avoid unnecessary rebuilds as it can take relatively long
|
|
|
|
# to generate
|
|
|
|
stimulusGenerator = stdenv.mkDerivation {
|
|
|
|
pname = "foot-generate-alt-random-writes";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://codeberg.org/dnkl/foot/raw/tag/${version}/scripts/generate-alt-random-writes.py";
|
|
|
|
sha256 = "0pnc5nvqrbgx5618ylrkrs9fyxjh4jcsbryfk6vlnk8x4wyyaibz";
|
|
|
|
};
|
|
|
|
|
|
|
|
dontUnpack = true;
|
|
|
|
|
|
|
|
buildInputs = [ python3 ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
install -Dm755 $src $out
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
stimuliFile = runCommandNoCC "pgo-stimulus-file" { } ''
|
|
|
|
${stimulusGenerator} \
|
|
|
|
--rows=67 --cols=135 \
|
|
|
|
--scroll --scroll-region \
|
|
|
|
--colors-regular --colors-bright --colors-256 --colors-rgb \
|
|
|
|
--attr-bold --attr-italic --attr-underline \
|
|
|
|
--sixel \
|
|
|
|
--seed=2305843009213693951 \
|
|
|
|
$out
|
|
|
|
'';
|
|
|
|
|
|
|
|
compilerName =
|
|
|
|
if stdenv.cc.isClang
|
|
|
|
then "clang"
|
|
|
|
else if stdenv.cc.isGNU
|
|
|
|
then "gcc"
|
|
|
|
else "unknown";
|
|
|
|
|
|
|
|
# https://codeberg.org/dnkl/foot/src/branch/master/INSTALL.md#performance-optimized-pgo
|
|
|
|
pgoCflags = {
|
|
|
|
"clang" = "-O3 -Wno-ignored-optimization-argument -Wno-profile-instr-out-of-date -Wno-profile-instr-unprofiled";
|
|
|
|
"gcc" = "-O3 -Wno-missing-profile";
|
|
|
|
}."${compilerName}";
|
|
|
|
|
|
|
|
# ar with lto support
|
|
|
|
ar = {
|
|
|
|
"clang" = "llvm-ar";
|
|
|
|
"gcc" = "gcc-ar";
|
|
|
|
"unknown" = "ar";
|
|
|
|
}."${compilerName}";
|
|
|
|
|
|
|
|
# PGO only makes sense if we are not cross compiling and
|
|
|
|
# using a compiler which foot's PGO build supports (clang or gcc)
|
|
|
|
doPgo = allowPgo && (stdenv.hostPlatform == stdenv.buildPlatform)
|
|
|
|
&& compilerName != "unknown";
|
|
|
|
in
|
2020-08-15 01:32:39 +02:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "foot";
|
2020-12-20 16:28:44 +01:00
|
|
|
inherit version;
|
2020-08-15 01:32:39 +02:00
|
|
|
|
2020-12-20 16:28:44 +01:00
|
|
|
src = fetchzip {
|
|
|
|
url = "https://codeberg.org/dnkl/${pname}/archive/${version}.tar.gz";
|
2021-02-12 23:30:50 +01:00
|
|
|
sha256 = "0awv53l3039s1rnkhdkzc0gwawlnd1m8cl4qhaijhxzzq68w0dfb";
|
2020-08-15 01:32:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2020-12-20 16:28:44 +01:00
|
|
|
meson
|
|
|
|
ninja
|
|
|
|
ncurses
|
|
|
|
scdoc
|
|
|
|
tllist
|
|
|
|
wayland-protocols
|
|
|
|
pkg-config
|
|
|
|
] ++ lib.optional stdenv.cc.isClang stdenv.cc.cc.llvm;
|
|
|
|
|
2020-08-15 01:32:39 +02:00
|
|
|
buildInputs = [
|
2020-12-20 16:28:44 +01:00
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
pixman
|
|
|
|
wayland
|
|
|
|
libxkbcommon
|
|
|
|
fcft
|
2020-08-15 01:32:39 +02:00
|
|
|
];
|
|
|
|
|
2020-12-20 16:28:44 +01:00
|
|
|
# recommended build flags for performance optimized foot builds
|
|
|
|
# https://codeberg.org/dnkl/foot/src/branch/master/INSTALL.md#release-build
|
|
|
|
CFLAGS =
|
|
|
|
if !doPgo
|
|
|
|
then "-O3 -fno-plt"
|
|
|
|
else pgoCflags;
|
|
|
|
|
|
|
|
# ar with gcc plugins for lto objects
|
2020-08-15 01:32:39 +02:00
|
|
|
preConfigure = ''
|
2020-12-20 16:28:44 +01:00
|
|
|
export AR="${ar}"
|
2020-08-15 01:32:39 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
mesonFlags = [ "--buildtype=release" "-Db_lto=true" ];
|
|
|
|
|
2020-12-20 16:28:44 +01:00
|
|
|
# build and run binary generating PGO profiles,
|
|
|
|
# then reconfigure to build the normal foot binary utilizing PGO
|
|
|
|
preBuild = lib.optionalString doPgo ''
|
|
|
|
meson configure -Db_pgo=generate
|
|
|
|
ninja
|
|
|
|
./pgo ${stimuliFile} ${stimuliFile} ${stimuliFile}
|
|
|
|
meson configure -Db_pgo=use
|
|
|
|
'' + lib.optionalString (doPgo && stdenv.cc.cc.pname == "clang") ''
|
|
|
|
llvm-profdata merge default_*profraw --output=default.profdata
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2020-08-15 01:32:39 +02:00
|
|
|
homepage = "https://codeberg.org/dnkl/foot/";
|
2020-12-20 16:28:44 +01:00
|
|
|
changelog = "https://codeberg.org/dnkl/foot/releases/tag/${version}";
|
2020-08-15 01:32:39 +02:00
|
|
|
description = "A fast, lightweight and minimalistic Wayland terminal emulator";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.sternenseemann ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|