-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathflake.nix
More file actions
120 lines (107 loc) · 4.54 KB
/
Copy pathflake.nix
File metadata and controls
120 lines (107 loc) · 4.54 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
111
112
113
114
115
116
117
118
119
120
{
description = "luvus — mission control for your AI coding agents";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{ nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
# Tools luvus shells out to at runtime (see `Command::new(...)` in src):
# git — the git tab + worktrees
# gh — GitHub PR/issue views (degrades cleanly when absent)
# ps — agent *identity* detection reads pane processes; without it
# detection falls back to weaker text heuristics (procps on
# Linux; on Darwin the system `ps` is used, so it is omitted)
# ssh — `--remote` attach
# sh — spawning panes / resume commands
# NixOS has no implicit global PATH, so we bake these in with wrapProgram
# rather than hope the user installed them. The original PATH is still
# appended, so a user's own newer git/gh is preferred if present.
runtimeTools =
with pkgs;
[
git
gh
openssh
bashInteractive
coreutils
]
++ pkgs.lib.optionals stdenv.hostPlatform.isLinux [ procps ];
luvus = pkgs.rustPlatform.buildRustPackage {
pname = "luvus";
version = cargoToml.package.version;
# Only what cargo needs. Dropping `target/` (dirty build artifacts that
# would otherwise invalidate the build) and the Astro site (its
# `node_modules` is large and irrelevant to the crate) keeps the source
# copied into the store small and the build hash stable. Neither name
# occurs inside `src/`, so a plain basename match is safe.
src = pkgs.lib.cleanSourceWith {
src = ./.;
filter =
path: type:
let
name = baseNameOf path;
in
!(name == "target" || name == "website")
&& pkgs.lib.cleanSourceFilter path type;
};
# The committed lockfile pins every dependency, so the build is
# reproducible without a separate vendored hash to keep in sync.
cargoLock.lockFile = ./Cargo.lock;
nativeBuildInputs = [ pkgs.makeWrapper ];
# On macOS, Cargo.toml deliberately links the SYSTEM sqlite
# (/usr/lib/libsqlite3.dylib) instead of bundling it, so the crate
# passes `-lsqlite3` at the final link. The Nix build sandbox has no
# /usr/lib, so the link fails with `ld: library not found for
# -lsqlite3`. Provide nixpkgs' sqlite on Darwin: the link resolves, and
# the dylib lands in the runtime closure — more hermetic than the
# release binary, which depends on an impure /usr/lib path. Linux keeps
# rusqlite's bundled engine and needs nothing extra.
buildInputs = pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
pkgs.sqlite
];
# The suite spawns real PTYs, `ps`, and child processes, and reads
# $HOME — all awkward inside the Nix build sandbox. CI runs the full
# suite on every push (see .github/workflows/ci.yml); the package build
# just compiles the release binary.
doCheck = false;
postFixup = ''
wrapProgram $out/bin/luvus \
--prefix PATH : ${pkgs.lib.makeBinPath runtimeTools}
'';
meta = with pkgs.lib; {
description = "Mission control for your AI coding agents";
homepage = "https://luvus.dev";
license = licenses.asl20;
mainProgram = "luvus";
platforms = platforms.unix;
};
};
in
{
packages.default = luvus;
# `nix run github:RizRiyz/luvus`
apps.default = flake-utils.lib.mkApp { drv = luvus; };
# `nix develop` — a shell with the Rust toolchain and the runtime tools,
# so `cargo run -- --local` behaves the same as an installed luvus.
devShells.default = pkgs.mkShell {
packages =
with pkgs;
[
cargo
rustc
clippy
rustfmt
rust-analyzer
]
++ runtimeTools;
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
};
}
);
}