-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathflake.nix
More file actions
110 lines (95 loc) · 3.63 KB
/
Copy pathflake.nix
File metadata and controls
110 lines (95 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
description = "Sessions that haunt your terminal. A GNU screen style terminal multiplexer built on libghostty.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
zig = pkgs.zig_0_15;
# Single source of truth for the version is build.zig.zon.
version = builtins.head (
builtins.match ''.*\.version = "([^"]+)".*'' (builtins.readFile ./build.zig.zon)
);
# Zig package cache containing every dependency pinned in
# build.zig.zon (libghostty and its transitive dependencies).
# Pre-fetched as a fixed-output derivation so the sandboxed
# build below needs no network access. When dependencies in
# build.zig.zon change, update outputHash (set it to
# lib.fakeHash, build, and copy the hash from the error).
deps = pkgs.stdenvNoCC.mkDerivation {
pname = "boo-deps";
inherit version;
src = ./.;
nativeBuildInputs = [ zig ];
dontConfigure = true;
dontBuild = true;
dontFixup = true;
installPhase = ''
export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache"
# Dependency hosts intermittently fail; retry like CI
# does. Zig resumes from its cache, so completed fetches
# are not repeated and the output stays reproducible.
for i in 1 2 3 4 5; do
zig build --fetch=all && break
if [ "$i" = 5 ]; then exit 1; fi
echo "fetch attempt $i failed; retrying in 10s" >&2
sleep 10
done
mv "$ZIG_GLOBAL_CACHE_DIR/p" "$out"
'';
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = "sha256-2dZHdZoAap25va9ka2SN5QqoQ2xcZITJKNzwfOGmvus=";
};
boo = pkgs.stdenv.mkDerivation {
pname = "boo";
inherit version;
src = ./.;
nativeBuildInputs = [ zig.hook ];
# zig.hook builds with --release=safe, matching the
# optimization mode of the published release binaries.
#
# The dependency cache is copied, not symlinked: some
# ghostty build steps run helper executables with a working
# directory inside the package cache and locate their
# outputs via relative paths, which resolve incorrectly
# through a symlink into the store.
postConfigure = ''
cp -r --no-preserve=mode ${deps} "$ZIG_GLOBAL_CACHE_DIR/p"
'';
# Runs `zig build test` (unit tests; no TTY required). The
# PTY integration tests stay in CI via `zig build test-all`.
doCheck = true;
meta = {
description = "Sessions that haunt your terminal. A GNU screen style terminal multiplexer built on libghostty";
homepage = "https://github.com/coder/boo";
license = lib.licenses.mit;
mainProgram = "boo";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
};
in
{
packages = {
default = boo;
inherit boo;
};
devShells.default = pkgs.mkShell {
packages = [ zig ];
};
formatter = pkgs.nixfmt-tree;
}
);
}