Skip to content

Commit fc57640

Browse files
authored
feat(drift): package the drift git diff pager 0.0.1 (#580)
drift is a Rust TUI pager for `git diff` (MIT, aymanbagabas/drift). Source is the GitHub tag tarball rather than the gs:// staging mirror, so cargo resolves crates during the build and the spec declares `needs = { dns, internet }` -- same shape as starship/zoxide/hunk. Runtime deps were read off the built binary rather than guessed: it links only libc, libm and libgcc_s. Notably there is no oniguruma and no zlib, unlike delta, because syntect is built with the `default-fancy` feature (pure-Rust fancy-regex). git is a hard runtime dep -- every view drift renders comes from shelling out to git (src/git.rs). The upstream release profile already pins lto/codegen-units=1/strip, so build.sh adds only the --remap-path-prefix flags; two builds from different paths were verified byte-identical.
1 parent fc74e19 commit fc57640

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

packages/drift/build.ncl

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
let { standaloneTest, subsetOf, Attrs, BuildSpec, Local, Needs, OutputBin, Source, .. } = import "minimal.ncl" in
2+
let base = import "../base/build.ncl" in
3+
let rust = import "../rust/build.ncl" in
4+
let toolchain = import "../toolchain/build.ncl" in
5+
6+
let gcc = import "../gcc/build.ncl" in
7+
let git = import "../git/build.ncl" in
8+
let glibc = import "../glibc/build.ncl" in
9+
10+
let version = "0.0.1" in
11+
{
12+
name = "drift",
13+
build_deps = [
14+
{ file = "build.sh" } | Local,
15+
{
16+
url = "https://github.com/aymanbagabas/drift/archive/refs/tags/v%{version}.tar.gz",
17+
sha256 = "3ea14fc2dafc647d75305f5ee126362390f7aa7204c3a1904d9b1572dd0bc682",
18+
extract = true,
19+
strip_prefix = "drift-%{version}",
20+
} | Source,
21+
base,
22+
rust,
23+
toolchain,
24+
],
25+
26+
# drift is a pager for `git diff`: every view it renders comes from shelling
27+
# out to git (src/git.rs), so git is a hard runtime dep, not a convenience.
28+
# The library set is just what the binary actually links -- syntect is built
29+
# with the `default-fancy` feature (pure-Rust fancy-regex), so unlike delta
30+
# there is no oniguruma here, and nothing pulls in zlib.
31+
runtime_deps = [
32+
glibc,
33+
subsetOf gcc ["libgcc"],
34+
git,
35+
],
36+
37+
# Source archive is the plain GitHub tag tarball with no vendored crates, so
38+
# the build resolves its cargo deps over the network.
39+
needs =
40+
{
41+
dns = {},
42+
internet = {},
43+
} | Needs,
44+
45+
cmd = "./build.sh",
46+
47+
outputs = {
48+
drift = { glob = "usr/bin/drift" } | OutputBin,
49+
},
50+
51+
attrs =
52+
{
53+
upstream_version = version,
54+
license_spdx = "MIT",
55+
source_provenance = {
56+
category = 'GithubRepo,
57+
owner = "aymanbagabas",
58+
repo = "drift",
59+
},
60+
build_cost_multiple = 2,
61+
} | Attrs,
62+
63+
tests = {
64+
smoketest = standaloneTest "/bin/drift --version",
65+
},
66+
} | BuildSpec

packages/drift/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -ex
3+
export CC=gcc
4+
export LD=gcc
5+
export RUSTFLAGS="-C linker=gcc --remap-path-prefix=$(pwd)=/builddir --remap-path-prefix=$HOME/.cargo=/cargo"
6+
7+
# --locked: upstream ships a Cargo.lock, so pin to it rather than re-resolving.
8+
cargo build --release --locked
9+
10+
# The release profile already sets lto/codegen-units=1/strip, so no extra
11+
# determinism flags are needed beyond the path remapping above.
12+
install -D -m 0755 target/release/drift "$OUTPUT_DIR/usr/bin/drift"

0 commit comments

Comments
 (0)