Parakeet is a Rust-based Bluesky AppServer aiming to implement most of the functionality required to support the Bluesky client
appview
atproto
bluesky
rust
appserver
1{
2 description = "Parakeet - a Rust-based Bluesky AppView for Bluesky client";
3
4 inputs = {
5 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6 crane.url = "github:ipetkov/crane";
7 flake-utils.url = "github:numtide/flake-utils";
8 rust-overlay = {
9 url = "github:oxalica/rust-overlay";
10 inputs.nixpkgs.follows = "nixpkgs";
11 };
12 };
13
14 outputs =
15 {
16 self,
17 nixpkgs,
18 crane,
19 flake-utils,
20 rust-overlay,
21 ...
22 }:
23 flake-utils.lib.eachDefaultSystem (
24 system:
25 let
26 pkgs = import nixpkgs {
27 inherit system;
28 overlays = [ (import rust-overlay) ];
29 };
30
31 inherit (pkgs) lib;
32 inherit (lib.fileset) toSource unions union;
33
34 craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default);
35 src = toSource {
36 root = ./.;
37 fileset = unions [ (craneLib.fileset.commonCargoSources ./.) ];
38 };
39
40 commonArgs = {
41 inherit src;
42 strictDeps = true;
43
44 nativeBuildInputs = with pkgs; [ pkg-config ];
45 buildInputs = with pkgs; [
46 clang
47 libclang
48 openssl
49 protobuf
50 ];
51
52 CLANG_PATH = "${pkgs.clang}/bin/clang";
53 LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
54 PROTOC = "${pkgs.protobuf}/bin/protoc";
55 PROTOC_INCLUDE = "${pkgs.protobuf}/include";
56 };
57
58 cargoArtifacts = craneLib.buildDepsOnly commonArgs;
59
60 individualCrateArgs = commonArgs // {
61 inherit cargoArtifacts;
62 inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
63 doCheck = false;
64 };
65
66 fileSetForCrate =
67 crate: add:
68 toSource {
69 root = ./.;
70 fileset = union (unions [
71 ./Cargo.lock
72 ./Cargo.toml
73 (craneLib.fileset.commonCargoSources ./crates/lexica)
74 (craneLib.fileset.commonCargoSources ./crates/parakeet-db)
75 (craneLib.fileset.commonCargoSources ./crates/parakeet-index)
76 ./crates/parakeet-index/proto
77 (craneLib.fileset.commonCargoSources crate)
78 ]) add;
79 };
80
81 parakeet-appview = craneLib.buildPackage (
82 individualCrateArgs
83 // {
84 pname = "parakeet";
85 cargoExtraArgs = "-p parakeet";
86 src = fileSetForCrate ./crates/parakeet (unions [
87 ./migrations
88 (craneLib.fileset.commonCargoSources ./crates/dataloader-rs)
89 (craneLib.fileset.commonCargoSources ./crates/parakeet)
90 ./crates/parakeet/src/sql
91 ]);
92 }
93 );
94
95 parakeet-consumer = craneLib.buildPackage (
96 individualCrateArgs
97 // {
98 pname = "consumer";
99 cargoExtraArgs = "-p consumer";
100 src = fileSetForCrate ./crates/consumer (unions [
101 ./crates/consumer/src/db/sql
102 ]);
103 }
104 );
105
106 parakeet-index = craneLib.buildPackage (
107 individualCrateArgs
108 // {
109 pname = "parakeet-index";
110 cargoExtraArgs = "-p parakeet-index --features server";
111 src = fileSetForCrate ./crates/parakeet-index (unions [ ]);
112 }
113 );
114 in
115 {
116 packages = {
117 default = parakeet-appview;
118 inherit parakeet-appview parakeet-consumer parakeet-index;
119 };
120
121 apps = {
122 parakeet-appview = flake-utils.lib.mkApp { drv = parakeet-appview; };
123 parakeet-consumer = flake-utils.lib.mkApp { drv = parakeet-consumer; };
124 parakeet-index = flake-utils.lib.mkApp { drv = parakeet-index; };
125 };
126
127 devShells.default = craneLib.devShell {
128 packages = with pkgs; [
129 diesel-cli
130 protobuf
131 ];
132 };
133 }
134 )
135 // flake-utils.lib.eachDefaultSystemPassThrough (system: {
136 nixosModules = {
137 default = import ./nix/services.nix {
138 inherit system;
139 parakeetSelf = self;
140 };
141 };
142 });
143}