@@ -1,29 +1,41 @@
1−{ stdenv, fetchurl, fetchpatch, xorg, ncurses, freetype, fontconfig, pkgconfig, makeWrapper
2−, enableDecLocator ? true
3−}:
1+{ stdenv, fetchurl, fetchpatch, xorg, ncurses, freetype, fontconfig, pkgconfig
2+, makeWrapper, nixosTests, writeScript, common-updater-scripts, git, nixfmt, nix
3+, gnused, coreutils, enableDecLocator ? true }:
44
55stdenv.mkDerivation rec {
6− name = "xterm-353";
6+ pname = "xterm";
7+ version = "353";
78
89 src = fetchurl {
910 urls = [
10− "ftp://ftp.invisible-island.net/xterm/${name}.tgz"
11− "https://invisible-mirror.net/archives/xterm/${name}.tgz"
12− ];
11+ "ftp://ftp.invisible-island.net/xterm/${pname}-${version}.tgz"
12+ "https://invisible-mirror.net/archives/xterm/${pname}-${version}.tgz"
13+ ];
1314 sha256 = "0s5pkfn4r8iy09s1q1y78zhnr9f3sm6wgbqir7azaqggkppd68g5";
1415 };
1516
16− buildInputs =
17− [ xorg.libXaw xorg.xorgproto xorg.libXt xorg.libXext xorg.libX11 xorg.libSM xorg.libICE
18− ncurses freetype fontconfig pkgconfig xorg.libXft xorg.luit makeWrapper
19− ];
17+ buildInputs = [
18+ xorg.libXaw
19+ xorg.xorgproto
20+ xorg.libXt
21+ xorg.libXext
22+ xorg.libX11
23+ xorg.libSM
24+ xorg.libICE
25+ ncurses
26+ freetype
27+ fontconfig
28+ pkgconfig
29+ xorg.libXft
30+ xorg.luit
31+ makeWrapper
32+ ];
2033
21− patches = [
22− ./sixel-256.support.patch
23− ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl
24− (fetchpatch {
34+ patches = [ ./sixel-256.support.patch ]
35+ ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch {
2536 name = "posix-ptys.patch";
26− url = "https://git.alpinelinux.org/aports/plain/community/xterm/posix-ptys.patch?id=3aa532e77875fa1db18c7fcb938b16647031bcc1";
37+ url =
38+ "https://git.alpinelinux.org/aports/plain/community/xterm/posix-ptys.patch?id=3aa532e77875fa1db18c7fcb938b16647031bcc1";
2739 sha256 = "0czgnsxkkmkrk1idw69qxbprh0jb4sw3c24zpnqq2v76jkl7zvlr";
2840 });
2941
@@ -62,10 +74,44 @@ stdenv.mkDerivation rec {
6274 install -D -t $out/share/icons/hicolor/48x48/apps icons/xterm-color_48x48.xpm
6375 '';
6476
77+ passthru = {
78+ updateScript = let
79+ # Tags that end in letters are unstable
80+ suffixes = stdenv.lib.concatStringsSep " "
81+ (map (c: "-c versionsort.suffix='${c}'")
82+ (stdenv.lib.stringToCharacters "abcdefghijklmnopqrstuvwxyz"));
83+ in writeScript "update.sh" ''
84+ #!${stdenv.shell}
85+ set -o errexit
86+ PATH=${
87+ stdenv.lib.makeBinPath [
88+ common-updater-scripts
89+ git
90+ nixfmt
91+ nix
92+ coreutils
93+ gnused
94+ ]
95+ }
96+
97+ oldVersion="$(nix-instantiate --eval -E "with import ./. {}; lib.getVersion ${pname}" | tr -d '"')"
98+ latestTag="$(git ${suffixes} ls-remote --exit-code --refs --sort='version:refname' --tags git@github.com:ThomasDickey/xterm-snapshots.git 'xterm-*' | tail --lines=1 | cut --delimiter='/' --fields=3 | sed 's|^xterm-||g')"
99+
100+ if [ ! "$oldVersion" = "$latestTag" ]; then
101+ update-source-version ${pname} "$latestTag" --version-key=version --print-changes
102+ nixpkgs="$(git rev-parse --show-toplevel)"
103+ default_nix="$nixpkgs/pkgs/applications/terminal-emulators/xterm/default.nix"
104+ nixfmt "$default_nix"
105+ else
106+ echo "${pname} is already up-to-date"
107+ fi
108+ '';
109+ };
110+
65111 meta = {
66112 homepage = "https://invisible-island.net/xterm";
67113 license = with stdenv.lib.licenses; [ mit ];
68− maintainers = with stdenv.lib.maintainers; [vrthra];
114+ maintainers = with stdenv.lib.maintainers; [ nequissimus vrthra ];
69115 platforms = with stdenv.lib.platforms; linux ++ darwin;
70116 };
71117}