-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
167 lines (146 loc) · 5.6 KB
/
flake.nix
File metadata and controls
167 lines (146 loc) · 5.6 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
{
description = "Sub-15ms image-paste glue for terminal AI agents on GNOME Wayland";
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 = import nixpkgs { inherit system; };
lib = pkgs.lib;
# Runtime helpers expected on $PATH at flashpaste runtime.
# `ydotool` is the critical one — it powers the synthetic Ctrl+V.
runtimeDeps = with pkgs; [
wl-clipboard
xclip
xsel
ydotool
tmux
kitty
bash
coreutils
util-linux
];
flashpaste = pkgs.rustPlatform.buildRustPackage {
pname = "flashpaste";
version = "1.34";
src = ./.;
# Cargo workspace lives under rs/.
sourceRoot = "source/rs";
cargoLock = {
lockFile = ./rs/Cargo.lock;
};
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
buildInputs = with pkgs; [
glib
cairo
pango
libxkbcommon
];
# Build all binaries the workspace produces.
cargoBuildFlags = [ "--workspace" "--features" "flashpaste-overlayd/wayland" ];
# Tests need a live Wayland/ydotool session — skip in the sandbox.
doCheck = false;
# Ship the bash scripts + systemd units + examples alongside the
# Rust binaries. `buildRustPackage` already installed the Rust
# bins into $out/bin/ before `postInstall` runs.
postInstall = ''
# Bash helpers from bin/ → $out/bin/ (strip .sh)
for src in $src/bin/*.sh; do
[ -f "$src" ] || continue
base="$(basename "$src" .sh)"
install -Dm0755 "$src" "$out/bin/$base"
done
for src in $src/bin/wl-paste $src/bin/screenshot-to-clipboard $src/bin/flashpaste-capture-clip; do
[ -f "$src" ] || continue
install -Dm0755 "$src" "$out/bin/$(basename "$src")"
done
# paste_image.sh shared payload.
install -Dm0755 $src/bin/paste_image.sh \
"$out/share/flashpaste/paste_image.sh"
# systemd user units (Nix users typically wire these via
# home-manager; ship them under share/ for reference).
for unit in $src/systemd/clipboard-janitor.service \
$src/systemd/flashpaste-screenshot-watcher.path \
$src/systemd/flashpaste-screenshot-watcher.service \
$src/systemd/flashpasted.service \
$src/systemd/flashpaste-overlayd.service; do
[ -f "$unit" ] || continue
install -Dm0644 "$unit" "$out/lib/systemd/user/$(basename "$unit")"
done
# Desktop entries.
for desk in $src/share/applications/*.desktop; do
[ -f "$desk" ] || continue
install -Dm0644 "$desk" "$out/share/applications/$(basename "$desk")"
done
# Examples + docs.
install -Dm0644 $src/examples/tmux.conf.snippet \
"$out/share/flashpaste/examples/tmux.conf.snippet"
install -Dm0644 $src/examples/kitty.conf.snippet \
"$out/share/flashpaste/examples/kitty.conf.snippet"
install -Dm0644 $src/README.md \
"$out/share/doc/flashpaste/README.md"
# Wrap the user-facing entrypoints so runtime deps resolve
# without polluting the global environment.
for bin in flashpaste flashpasted flashpaste-dispatch \
flashpaste-trigger flashpaste-shoot flashpaste-mcp \
flashpaste-overlayd flashpaste-overlay flashpaste-doctor; do
if [ -x "$out/bin/$bin" ]; then
wrapProgram "$out/bin/$bin" \
--prefix PATH : ${lib.makeBinPath runtimeDeps}
fi
done
'';
meta = with lib; {
description = "Sub-15ms image-paste glue for terminal AI agents on GNOME Wayland";
homepage = "https://github.com/NagyVikt/flashpaste";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.linux;
mainProgram = "flashpaste";
};
};
in
{
packages = {
default = flashpaste;
flashpaste = flashpaste;
};
apps = {
default = {
type = "app";
program = "${flashpaste}/bin/flashpaste-doctor";
};
doctor = {
type = "app";
program = "${flashpaste}/bin/flashpaste-doctor";
};
daemon = {
type = "app";
program = "${flashpaste}/bin/flashpasted";
};
};
devShells.default = pkgs.mkShell {
name = "flashpaste-dev";
inputsFrom = [ flashpaste ];
packages = with pkgs; [
# Rust toolchain for hacking on the workspace.
cargo
rustc
rustfmt
clippy
rust-analyzer
# Runtime deps so `cargo run` works inside the shell.
] ++ runtimeDeps;
shellHook = ''
echo "flashpaste devshell — cargo + runtime deps on \$PATH"
echo " cargo build --release --manifest-path rs/Cargo.toml"
'';
};
formatter = pkgs.nixpkgs-fmt;
});
}