Skip to content

Commit dabd084

Browse files
authored
Merge pull request #161 from tharropoulos/flake
chore(nix): add flake
2 parents 36f845e + 89f3689 commit dabd084

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

‎flake.lock‎

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flake.nix‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
description = "typesense-python development shell";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
};
7+
8+
outputs =
9+
{ self, nixpkgs }:
10+
let
11+
systems = [
12+
"x86_64-linux"
13+
"aarch64-linux"
14+
"aarch64-darwin"
15+
];
16+
forAllSystems = nixpkgs.lib.genAttrs systems;
17+
in
18+
{
19+
devShells = forAllSystems (
20+
system:
21+
let
22+
pkgs = import nixpkgs { inherit system; };
23+
24+
# Starts a local server configured like the one in CI, which the test suite expects.
25+
typesense-dev = pkgs.writeShellApplication {
26+
name = "typesense-dev";
27+
runtimeInputs = [ pkgs.typesense ];
28+
text = ''
29+
root="''${TYPESENSE_DEV_DIR:-$PWD/.typesense}"
30+
mkdir -p "$root/data" "$root/analytics"
31+
exec typesense-server \
32+
--api-key=xyz \
33+
--data-dir="$root/data" \
34+
--enable-search-analytics=true \
35+
--analytics-dir="$root/analytics" \
36+
--analytics-flush-interval=60 \
37+
--analytics-minute-rate-limit=50 \
38+
--enable-cors \
39+
"$@"
40+
'';
41+
};
42+
43+
mkShell =
44+
python:
45+
pkgs.mkShell {
46+
packages = [
47+
python
48+
pkgs.uv
49+
pkgs.typesense
50+
typesense-dev
51+
];
52+
53+
env = {
54+
# Keep uv on the interpreter from this shell instead of fetching its own.
55+
UV_PYTHON = python.interpreter;
56+
UV_PYTHON_DOWNLOADS = "never";
57+
};
58+
59+
shellHook = ''
60+
unset PYTHONPATH
61+
'';
62+
};
63+
in
64+
{
65+
default = mkShell pkgs.python313;
66+
py311 = mkShell pkgs.python311;
67+
py312 = mkShell pkgs.python312;
68+
py313 = mkShell pkgs.python313;
69+
}
70+
);
71+
};
72+
}

0 commit comments

Comments
 (0)