forked from tobi/qmd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
83 lines (68 loc) · 2.21 KB
/
flake.nix
File metadata and controls
83 lines (68 loc) · 2.21 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
{
description = "QMD - Quick Markdown Search";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
# SQLite with loadable extension support for sqlite-vec
sqliteWithExtensions = pkgs.sqlite.overrideAttrs (old: {
configureFlags = (old.configureFlags or []) ++ [
"--enable-load-extension"
];
});
qmd = pkgs.stdenv.mkDerivation {
pname = "qmd";
version = "1.0.0";
src = ./.;
nativeBuildInputs = [ pkgs.bun pkgs.makeWrapper ];
buildInputs = [ pkgs.sqlite ];
buildPhase = ''
export HOME=$(mktemp -d)
bun install --frozen-lockfile
'';
installPhase = ''
mkdir -p $out/lib/qmd
mkdir -p $out/bin
cp -r node_modules $out/lib/qmd/
cp -r src $out/lib/qmd/
cp package.json $out/lib/qmd/
makeWrapper ${pkgs.bun}/bin/bun $out/bin/qmd \
--add-flags "$out/lib/qmd/src/qmd.ts" \
--set DYLD_LIBRARY_PATH "${pkgs.sqlite.out}/lib" \
--set LD_LIBRARY_PATH "${pkgs.sqlite.out}/lib"
'';
meta = with pkgs.lib; {
description = "On-device search engine for markdown notes, meeting transcripts, and knowledge bases";
homepage = "https://github.com/tobi/qmd";
license = licenses.mit;
platforms = platforms.unix;
};
};
in
{
packages = {
default = qmd;
qmd = qmd;
};
apps.default = {
type = "app";
program = "${qmd}/bin/qmd";
};
devShells.default = pkgs.mkShell {
buildInputs = [
pkgs.bun
sqliteWithExtensions
];
shellHook = ''
export BREW_PREFIX="''${BREW_PREFIX:-${sqliteWithExtensions.out}}"
echo "QMD development shell"
echo "Run: bun src/qmd.ts <command>"
'';
};
}
);
}