Kieran's opinionated (and probably slightly dumb) nix config
1{ pkgs, lib, stdenv, fetchurl, autoPatchelfHook }:
2
3stdenv.mkDerivation rec {
4 pname = "zmx";
5 version = "0.1.0";
6
7 src = fetchurl {
8 url = if stdenv.isLinux then
9 (if stdenv.isAarch64 then
10 "https://zmx.sh/a/zmx-${version}-linux-aarch64.tar.gz"
11 else
12 "https://zmx.sh/a/zmx-${version}-linux-x86_64.tar.gz")
13 else if stdenv.isDarwin then
14 (if stdenv.isAarch64 then
15 "https://zmx.sh/a/zmx-${version}-macos-aarch64.tar.gz"
16 else
17 "https://zmx.sh/a/zmx-${version}-macos-x86_64.tar.gz")
18 else throw "Unsupported platform";
19
20 hash = if stdenv.isLinux && stdenv.isAarch64 then
21 "sha256-sv83lR4DLJE+gsMtqCk6VCFdo5n4lhI0P1loxAf0iOg="
22 else if stdenv.isLinux then
23 "sha256-c+wCUcm7DEO55wXuHq0aP0Kn908jj1FM5Z+JQJnKE0M="
24 else if stdenv.isDarwin && stdenv.isAarch64 then
25 "sha256-dM6MFikdbpN+n8BK6fLbzyJfi88xetCWL9H5VfGB07o="
26 else
27 "sha256-B52NC8NEjVPDNSG11qPb0uRNExB66bllnK7ivXMJbHk=";
28 };
29
30 nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
31
32 sourceRoot = ".";
33
34 installPhase = ''
35 runHook preInstall
36 mkdir -p $out/bin
37 cp zmx $out/bin/
38 chmod +x $out/bin/zmx
39 runHook postInstall
40 '';
41
42 meta = with lib; {
43 description = "Session persistence for terminal processes";
44 homepage = "https://zmx.sh";
45 license = licenses.mit;
46 platforms = platforms.unix;
47 };
48}